Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions iOS/Debugger/Core/AppDelegate+Debugger.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import UIKit


/// Extension to AppDelegate for initializing the debugger
extension AppDelegate {
/// Initialize the debugger
func initializeDebugger() {
// Initialize the debugger manager
DebuggerManager.shared.initialize()

// Log initialization
Debug.shared.log(message: "Debugger initialized", type: .info)
}
}
/// Extension for AppDelegate to initialize the debugger
extension AppDelegate {
/// Initialize the debugger
func initializeDebugger() {
// Initialize the debugger manager
DebuggerManager.shared.initialize()

// Log initialization
Debug.shared.log(message: "Debugger initialized", type: .info)
}

/// Add FLEX framework to the project
/// This method should be called in the Podfile or SPM dependencies
/// Example for Podfile:
/// ```
/// pod 'FLEX', :configurations => ['Debug']
/// ```
///
/// Example for SPM:
/// ```
/// .package(url: "https://github.com/FLEXTool/FLEX.git", from: "5.0.0")
/// ```
func addFLEXFramework() {
// This is just a placeholder method to document how to add FLEX to the project
// The actual integration happens through CocoaPods or Swift Package Manager
Debug.shared.log(message: "FLEX framework should be added via CocoaPods or SPM", type: .info)
}
}
49 changes: 47 additions & 2 deletions iOS/Debugger/Core/DebuggerManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public final class DebuggerManager {

/// The debugger engine
private let debuggerEngine = DebuggerEngine.shared

/// The FLEX debugger adapter
private let flexAdapter = FLEXDebuggerAdapter.shared

/// Current debugger view controller
private weak var debuggerViewController: DebuggerViewController?
Expand Down Expand Up @@ -54,6 +57,12 @@ public final class DebuggerManager {
public func initialize() {
logger.log(message: "Initializing debugger", type: .info)

// Initialize FLEX adapter
flexAdapter.initialize()

// Enable network monitoring by default
flexAdapter.enableNetworkMonitoring()

// Show the floating button
DispatchQueue.main.async { [weak self] in
self?.showFloatingButton()
Expand Down Expand Up @@ -149,6 +158,29 @@ public final class DebuggerManager {
self?.logger.log(message: "Floating debugger button removed", type: .info)
}
}

/// Show the FLEX explorer directly
public func showFLEXExplorer() {
flexAdapter.showExplorer()
}

/// Hide the FLEX explorer
public func hideFLEXExplorer() {
flexAdapter.hideExplorer()
}

/// Toggle the FLEX explorer visibility
public func toggleFLEXExplorer() {
flexAdapter.toggleExplorer()
}

/// Present a specific FLEX debugging tool
/// - Parameters:
/// - tool: The tool to present
/// - completion: Completion handler called when the tool is presented
public func presentFLEXTool(_ tool: FLEXDebuggerTool, completion: (() -> Void)? = nil) {
flexAdapter.presentTool(tool, completion: completion)
}

// MARK: - Private Methods

Expand Down Expand Up @@ -241,12 +273,25 @@ extension DebuggerManager: DebuggerViewControllerDelegate {
func debuggerViewControllerDidRequestDismissal(_: DebuggerViewController) {
hideDebugger()
}

func debuggerViewControllerDidRequestFLEXTool(_ viewController: DebuggerViewController, tool: FLEXDebuggerTool) {
presentFLEXTool(tool) {
// Optional: Handle completion if needed
}
}
}

// MARK: - UIApplication Extension

extension UIApplication {
private func findTopViewController(_ controller: UIViewController) -> UIViewController {
func topMostViewController() -> UIViewController? {
guard let keyWindow = keyWindow else { return nil }
return findTopViewController(keyWindow.rootViewController)
}

private func findTopViewController(_ controller: UIViewController?) -> UIViewController? {
guard let controller = controller else { return nil }

if let presentedController = controller.presentedViewController {
return findTopViewController(presentedController)
}
Expand All @@ -273,7 +318,7 @@ extension UIApplication {
if #available(iOS 13.0, *) {
return UIApplication.shared.connectedScenes
.filter { $0.activationState == .foregroundActive }
.first(where: { $0 is UIWindowScene })
.first(where: { $0 is UIWindowScene })?
.flatMap { $0 as? UIWindowScene }?.windows
.first(where: { $0.isKeyWindow })
} else {
Expand Down
Loading
Loading