How to debug Apple watch app on actual device?
Asked Answered
S

2

7

I want to debug both the apple watch app (foreground) and the iOS app (background)

The reason is because I'm using this code in Apple watch extension to open the iOS app in background to make a service call:

    [WKInterfaceController openParentApplication:@{@"key":@"loadRecentData"} reply:^(NSDictionary *replyInfo, NSError *error) {...

And I want to set a breakpoint inside here to check if there's a reply:

- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply {

enter image description here

Suggested solution by Jesse Tayler gives this error:

enter image description here

Slipcover answered 22/5, 2015 at 9:58 Comment(0)
G
3

use the -> Debug -> Attach to process... menu and you'll be able to debug

Gamb answered 27/5, 2015 at 15:54 Comment(3)
can you please list out the steps one by one? What I did was, 1) Run the iOS app on the iPhone from Xcode, 2) The iPhone app will be launch and watch app will be installed on the watch. 3) I need to tap the watch app to launch it. 4) When I select Debug -> Attach to process, I can only see "My app name" (already being debugged)Slipcover
you can simply type the full and complete name of your process. if you don't know it, try ps -axww in terminal and try to find the process running there and paste the name into Xcode. Good luck!Gamb
using ps in the terminal will only list processes on the mac, useful if you're running the Watch simulator, but it won't list processes running on an actual iPhone or Watch.Ternate
C
3

Select watchkit app from schemes. Run this in your " Paired iPhone + Watch ". Launch the app in watch. Now you can debug your code. I tried this and is working for me. I am using xcode 7.2.

Clayberg answered 9/2, 2016 at 6:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.