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

user1872384
  • 6,886
  • 11
  • 61
  • 103

2 Answers2

3

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

  • 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) – user1872384 May 28 '15 at 03:57
  • 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! – Jesse Tayler Jul 01 '15 at 20:41
  • 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. – progrmr Sep 25 '18 at 00:58
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.