Debug an iOS app while its WatchKit app is running
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:
- Build & run your iOS app in the simulator.
- Wait for it to finish launching, then hit the stop button in Xcode.
- Switch your active target to your WatchKit app, build, and run it.
- When the Watch app has finished launching, tap your iOS app’s icon in the main simulator window.
- In Xcode’s menu bar select Debug > Attach to Process.
- 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.