Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6e121fb39b | |||
| 4c8a519c4f | |||
| d3d12e2450 | |||
| 062f74a429 | |||
| c8468823c0 | |||
| c19df26edc | |||
| d1227ee522 | |||
| 97a6ae0899 | |||
| 4b0f9e149a | |||
| 20f88c739f | |||
| 98a66af9b2 | |||
| 19f2302f13 | |||
| 308a25f6db | |||
| 40614dffec | |||
| 245d6f0310 | |||
| 349d7359eb | |||
| 37e0ab6323 | |||
| 1ea0dc7026 | |||
| a9db186136 |
Binary file not shown.
|
Before Width: | Height: | Size: 14 MiB After Width: | Height: | Size: 10 MiB |
@@ -2,7 +2,7 @@
|
||||
|
||||
Welcome to LocalConsole! This Swift Package makes on-device debugging easy with a convenient PiP-style console that can display items in the same way ```print()``` will in Xcode. This tool can also dynamically display view frames and restart SpringBoard right from your live app.
|
||||
|
||||
<img src="https://github.com/duraidabdul/LocalConsole/blob/main/Demo.gif?raw=true" width="250">
|
||||
<img src="https://github.com/duraidabdul/LocalConsole/blob/main/Demo.gif?raw=true" width="320">
|
||||
|
||||
## **Setup**
|
||||
|
||||
@@ -32,8 +32,11 @@ localConsoleManager.isVisible = false
|
||||
// Print items to the console view.
|
||||
localConsoleManager.print("Hello, world!")
|
||||
|
||||
// Clear text in the console view.
|
||||
// Clear console text.
|
||||
localConsoleManager.clear()
|
||||
|
||||
// Copy console text.
|
||||
localConsoleManager.copy()
|
||||
```
|
||||
|
||||
```swift
|
||||
@@ -43,8 +46,6 @@ localConsoleManager.fontSize = 5
|
||||
|
||||
|
||||
## **To-Do**
|
||||
* Custom console view size
|
||||
* Support for iOS 13
|
||||
* Screen edge console hiding
|
||||
* Custom pinch to resize gesture
|
||||
* Make console view reactive to landscape/portrait switch
|
||||
|
||||
@@ -55,7 +55,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
let consoleTextView = UITextView()
|
||||
|
||||
/// Button that reveals menu.
|
||||
var menuButton: UIButton!
|
||||
lazy var menuButton = UIButton()
|
||||
|
||||
/// Tracks whether the PiP console is in text view scroll mode or pan mode.
|
||||
var scrollLocked = true
|
||||
@@ -90,21 +90,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
override init() {
|
||||
super.init()
|
||||
|
||||
// Configure console window.
|
||||
let windowScene = UIApplication.shared
|
||||
.connectedScenes
|
||||
.filter { $0.activationState == .foregroundActive }
|
||||
.first
|
||||
|
||||
if let windowScene = windowScene as? UIWindowScene {
|
||||
consoleWindow = ConsoleWindow(windowScene: windowScene)
|
||||
consoleWindow?.frame = UIScreen.main.bounds
|
||||
consoleWindow?.windowLevel = UIWindow.Level.statusBar
|
||||
consoleWindow?.isHidden = false
|
||||
consoleWindow?.addSubview(consoleView)
|
||||
|
||||
UIWindow.swizzleStatusBarAppearanceOverride
|
||||
}
|
||||
configureWindow()
|
||||
|
||||
consoleSize = CGSize(width: UserDefaults.standard.object(forKey: "LocalConsole_Width") as? CGFloat ?? consoleSize.width,
|
||||
height: UserDefaults.standard.object(forKey: "LocalConsole_Height") as? CGFloat ?? consoleSize.height)
|
||||
@@ -185,11 +171,58 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
menuButton.tintColor = UIColor(white: 1, alpha: 0.75)
|
||||
menuButton.menu = makeMenu()
|
||||
menuButton.showsMenuAsPrimaryAction = true
|
||||
consoleView.addSubview(menuButton!)
|
||||
consoleView.addSubview(menuButton)
|
||||
|
||||
UIView.swizzleDebugBehaviour
|
||||
}
|
||||
|
||||
/// Adds a LocalConsole window to the app's main scene.
|
||||
func configureWindow() {
|
||||
var windowSceneFound = false
|
||||
|
||||
// Configure console window.
|
||||
func fetchWindowScene() {
|
||||
let windowScene = UIApplication.shared
|
||||
.connectedScenes
|
||||
.filter { $0.activationState == .foregroundActive }
|
||||
.first
|
||||
|
||||
if let windowScene = windowScene as? UIWindowScene {
|
||||
|
||||
windowSceneFound = true
|
||||
|
||||
consoleWindow = ConsoleWindow(windowScene: windowScene)
|
||||
consoleWindow?.frame = UIScreen.main.bounds
|
||||
consoleWindow?.windowLevel = UIWindow.Level.statusBar
|
||||
consoleWindow?.isHidden = false
|
||||
consoleWindow?.addSubview(consoleView)
|
||||
|
||||
UIWindow.swizzleStatusBarAppearanceOverride
|
||||
}
|
||||
}
|
||||
|
||||
fetchWindowScene()
|
||||
|
||||
/// Ensures the window is configured (i.e. scene has been found). If not, delay and wait for a scene to prepare itself, then try again.
|
||||
for i in 1...10 {
|
||||
|
||||
let delay = Double(i) / 10
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [self] in
|
||||
|
||||
guard !windowSceneFound else { return }
|
||||
|
||||
fetchWindowScene()
|
||||
|
||||
if isVisible {
|
||||
isVisible = false
|
||||
consoleView.layer.removeAllAnimations()
|
||||
isVisible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
public var isVisible = false {
|
||||
@@ -336,7 +369,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
||||
let viewFrames = UIAction(title: debugBordersEnabled ? "Hide View Frames" : "Show View Frames",
|
||||
image: UIImage(systemName: "rectangle.3.offgrid"), handler: { _ in
|
||||
self.debugBordersEnabled.toggle()
|
||||
self.menuButton?.menu = self.makeMenu()
|
||||
self.menuButton.menu = self.makeMenu()
|
||||
})
|
||||
|
||||
let respring = UIAction(title: "Restart SpringBoard",
|
||||
|
||||
Reference in New Issue
Block a user