How to debug an iOS app while the associated WatchKit app is running

Brian GilhamEssays

Since the introduction of openParentApplication:reply: I’ve seen developers struggle to debug their iOS app while running a WatchKit app in the simulator.

If you haven’t worked with extensions before, the solution may not be obvious. Here’s how to pull it off:

  1. Build & run your iOS app in the simulator.
  2. Wait for it to finish launching, then hit the stop button in Xcode.
  3. Switch your active target to your WatchKit app, build, and run it.
  4. When the Watch app has finished launching, tap your iOS app’s icon in the main simulator window.
  5. In Xcode’s menu bar select Debug > Attach to Process.
  6. Select your iOS app from the list. Chances are you’ll find it under Likely Targets.

If you take a look in the Debug Navigator (⌘ + 6), you’ll notice the debugger is now attached to both your iOS app and the WatchKit extension. You can click on each target in the navigator window to select which console output you’d like to view. If Xcode encounters a breakpoint it will automatically switch to the correct target.

Keep in mind that you’ll have to repeat this process each time you re-run your WatchKit app.