Inserting breakpoints or logging statements (such as NSLog) is relatively straightforward with an iPhone-only iOS app. But how do you log from the WatchKit Extension (aka Watch app)?
The good news is that logging isn’t filled with many complicated steps. The bad news is that the logging works intermittently.
- Add your NSLog statements in your WatchKit Extension. This is probably your InterfaceController.m
- Run the watch app on iOS Device + watchOS Device (in the WatchKit App scheme)
- Select Debug > Attach to Process > (click on your watch app name)
- Profit! You should see your NSLogs when they are triggered in the app lifecycle in Xcode
If logging isn’t working, try typical Xcode debug steps such as:
- deleting the app on your phone & re-running it in Xcode
- restarting the phone and/or watch devices
- clean Xcode (cmd + shift + k) and re-run the app
- quit & restart Xcode