Search code examples
xcodexcode10

Xcode 10 no breakpoints are hit and app launches blank


Just updated to Xcode 10 :( and nothing works anymore.

private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    window = UIWindow()
    window?.rootViewController = UIViewController()
    window?.makeKeyAndVisible()
    return true
}

App launches and turns black right away.

  • I'm running a debug scheme
  • Code optimization is turned off
  • I have removed main.storyboard from my app setting

It doesn't even hot my breakpoints, I have a breakpoint on the first line of Appldegate and it's not getting hit


Solution

  • I have a breakpoint on the first line of Appldegate and it's not getting hit

    Exactly so. The breakpoint is not being hit because your method is not being called. It's not being called because Cocoa can't see that it's there. Cocoa can't see that it's there because you have hidden it!

    It's all about the relationship between Objective-C and Swift, and how Objective-C sees what's in your Swift code.

    The problem is the keyword private. This causes Cocoa (which is Objective-C) to be unable to see that you have implemented application:didFinishLaunchingWithOptions:. It can't see it so it doesn't call it. Delete that keyword and you're good to go.