Search code examples
iosdebuggingionic-frameworkcapacitor

Not able to debug ionic 3 app on safari simulator IOS 16.4


I am Not able to debug ionic capacitor app on safari simulator IOS 16.4 showing no inspectable applications. I tried to add below line of code inside AppDelegate file

let webConfiguration = WKWebViewConfiguration()
let webView: WKWebView = WKWebView(frame: .zero, configuration: webConfiguration)

also added below line of code before return inside func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { function

#if DEBUG
    if #available(iOS 16.4, *) {
       webView.isInspectable = true
    }
#endif

After doing above steps it's giving me Application name in safari but target is about:blank. While clicking on about:blank it's showing only blank body tag in inspector.


Solution

  • I have done this to adding few lines of code into AppDelegate.swift file in Xcode.

    #if DEBUG
      if #available(macOS 13.3, iOS 16.4, tvOS 16.4, *) {
            DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
                if let vc = self.window?.rootViewController as? CAPBridgeViewController {
                   vc.bridgedWebView?.isInspectable = true;
                }
            }
      }
    #endif
    

    inside func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    Note- This code will only work if you are using Capacitor