58

I tried to debug my WatchKit app on a real Apple Watch today. After hitting the Debug button in Xcode, the main iPhone app was installed properly, but the Apple Watch only displayed the message Failed to install xxx, error: Application Verification Failed. The WatchKit app doesn't install.

I was aware of this: WatchKit App Rejected for "Failing to Install" , but it didn't help because my Xcode project file is alright.

How to make debug work on a real Apple Watch?

Community
  • 1
  • 1
zavié
  • 4,301
  • 2
  • 34
  • 46

5 Answers5

80

It turns out you also have to add the UDID of the Apple Watch to the Apple Developer Portal, and update your Development provisioning profile to include this UDID.

The UDID can be obtained in Devices window of Xcode. After pairing, the info of the Apple Watch will automatically display below the info of your iPhone.

At the time of writing, this seems to be documented nowhere, and the error message on the Apple Watch wasn't particularly helpful. So I wish this try-and-error lesson would save you some hassle.

zavié
  • 4,301
  • 2
  • 34
  • 46
  • I laughed when you said "after pairing," because even though my apple watch IS paired with my iphone 6, xcode does not think it is. maybe you can help me figure out why that's the case and how to get xcode to believe the watch is paired. in the meantime is there another way to obtain the UDID while xcode doesn't believe the watch is paired? – Dave Kliman Apr 26 '15 at 14:39
  • @DaveKliman Hm that's unfortunate.. Maybe follow the recent trend, restart iPhone, restart Apple Watch, restart Xcode and restart you Mac? :P I couldn't find a way to get that string elsewhere, notice that there is a "SEID" in Settings > General, but that's not what Xcode is displaying as "Identifier". I used the displayed "Identifier". Maybe give the SEID a try if you have still some free slots in Portal? – zavié Apr 26 '15 at 14:46
  • I restarted everything... I did find the SEID... I added the apple watch with that as a device in the dev portal. but that seems to have done nothing... – Dave Kliman Apr 26 '15 at 15:40
  • @zavié how do u set the notification sash icon dynamically? is it possible? – iOSdev Apr 28 '15 at 06:59
  • @iOSdev I think u can only set that in Storyboard. Not programatically at runtime. – zavié Apr 28 '15 at 15:28
  • @DaveKliman Sorry I don't know other ways.. Maybe post a new question on StackOverflow? – zavié Apr 28 '15 at 15:28
  • @DaveKliman: I also ran into the scenario where XCode was not displaying Watch as paired in the Devices. It turns out that XCode 6.2 does not show the Watch data (or only shows sometimes only). I then used XCode 6.3 and I was able to see the Watch listed as paired in the Devices window. By any chance, are you using XCode 6.2? – rkwatra Apr 28 '15 at 19:03
  • Having the exact same error displayed on the watch when I try to install, but our app, extension, and watchkit app are all signed using an enterprise (in-house) profile, so I shouldn't have to add device ID's to the developer portal. Any ideas? – roperklacks May 21 '15 at 20:59
  • We also have an enterprise version of the watch app and it works, so enterprise shouldn't be the problem. Have u applied separate profiles for each target and bundle ID? Wild cards are not working – zavié May 21 '15 at 23:55
3

The UDID issue as described above can be the culprit, but in my case, that was handled automatically by Xcode. Looking at the device log (menu Window>Devices) showed:

companionappd[350] : failed to install WatchKit application, error: (Error Domain=LaunchServicesError Code=0 "The operation couldn’t be completed. (LaunchServicesError error 0.)" UserInfo=0x14e2f690 {Error=ApplicationVerificationFailed, ErrorDetail=-402620394, ErrorDescription=Failed to verify code signature of : 0xe8008016 (Entitlements found that are not permitted by provisioning profile)})

... a problem which didn't get caught in the build process, nor was explicitly shared with me in the on-screen errors.

So, I looked at the entitlements:

enter image description here

Yes, I did have to manually add that beta-reports-active in order to submit to TestFlight.

It seems that you needs the flag if you're using TestFlight (and anything other than the default Entitlements), but you need to not have the flag if you're debugging locally.

My solution to this contradiction therefore is to have two entitlements files, like so:

enter image description here

So far, so good. App and Watch Extension are running as expected.

SG1
  • 2,871
  • 1
  • 29
  • 41
3

Basically you need to perform two steps:

  • Add the UDID of your apple watch to the developer portal
  • Update your provisioning profile to support the watch

XCode can manage the whole process for you:

1. Deploy the App to your iPhone/iPad

enter image description here

2. Start the WatchKit App also on your iPhone/iPad (not in the simulator)

enter image description here

3. Choose Fix Issue, when the code signing error message appears

enter image description here

4. Select your Development Team and let XCode do the rest

I've also written a short tutorial for this.

Mohsin Khubaib Ahmed
  • 1,008
  • 16
  • 32
Stefan
  • 5,203
  • 8
  • 27
  • 51
2

Don't forget to scroll down in the "Devices" display in Xcode. Xcode -> Window -> Devices ->Select "NameOfiPhone" then in the "Device Information" Window to the right, scroll down. Then you will see the paired device. Yep, I'm admitting this:-)

1

You should have AppID for each. eg If your app's bundle identifier is "com.xyz" then you need three appids and provisioning profiles called

  1. com.xyz
  2. com.xyz.watchkitapp
  3. com.xyz.watchkitapp.watchkitextension

Create provisioning for each and assign to the related targets.

This will resolve this issue. Make sure your UUID for iphone and watch must be added to these profiles.

Also version for all the targets should be same.