Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WatchOS and location entitlement

I've been working on adding a watchapp to a fitness tracker I already have in the app store. I've been able to load it onto my physical phone and watch without trouble in the past.

I've recently added Location tracking to the watch app, so that I can track the path the user has run/biked and show it to them on the phone when they review the workout. Since doing that, I'v been getting errors from Xcode when I try to load the app to my phone; I think these are expected errors, but I'm having trouble understanding from the docs/interface of Xcode and developer.apple.com where to make the fix.

errors from xcode

I've added the entitlement in the watch app entitlements file:

entitlemnents file

As the error says, I've switched to manual signing and generated a new provisioning profile, but I get the same error. I don't see a place to add a location capability in the provisioning profile in developer.apple.com:

enter image description here enter image description here

It seems like the only way for the provisioning profile to get the entitlement is from Xcode, since there's not a place to add it in developer.apple.com? That seems wrong, and isn't working in any case. I'm not finding help for my case in the Xcode docs (or I'm looking in the wrong place). Any help would be greatly appreciated.

like image 201
Paul Degnan Avatar asked Dec 21 '18 21:12

Paul Degnan


People also ask

What is an Apple entitlement?

An entitlement is a right or privilege that grants an executable particular capabilities. For example, an app needs the HomeKit Entitlement — along with explicit user consent — to access a user's home automation network.

What does location requested on Apple watch mean?

Location-Based Alerts: Your iPhone and Apple Watch will use your location in order to provide you with geographically relevant alerts, such as a reminder to call someone when you get to a specific place, when to leave for your next appointment, or an app or shortcut recommendation based on where you currently are.

How do I check my entitlements?

Check the Entitlements In Your Build Log and App You'll find the name of the provisioning profile Xcode used to sign your app in the invocation of the codesign tool's command-line parameters. This command prints a plist that contains all of the entitlements built into the app.


2 Answers

I am using location services on iOS and watchOS, but I have nothing related to it in both entitlement files. The docs say:

Set entitlement values in order to enable iCloud, push notifications, Apple Pay, and App Sandbox.

They don’t mention location services.

So it might be enough to delete the Location entitlement, and enable automatic signing again.

Of course, you had to set in your iOS info.plist, as required, NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription, and in your watch extension info.plist NSLocationWhenInUseUsageDescription.

like image 163
Reinhard Männer Avatar answered Oct 21 '22 16:10

Reinhard Männer


Are you using latest Xcode? Did you set the entitlement in the target menus? They all have toggles now, from what I remember. Once you do that, normally Xcode can resolve signing issues for you. If you look at the signing section in Xcode, does it indicate a signing problem there? (And have you restarted Xcode at least once while trying to resolve the signing problem?)

Note that the location entitlement should be on your WatchKit Extension, not on the Watchkit App.

Have a look at the Capabilities tab (it is the one for control of Entitlements, so you do not have to edit the plist directly.)

Have you tried creating a new project as a test to see if that works? Your screenshot does not match target naming of what I see in Xcode for a WatchKit App. In Xcode 10.1, the WatchKit App plist editor will show 'app name' WatchKit App and the extension plist editor shows 'appname' WatchKit Extension. I see your screenshot showing 'blank' Watchapp Extension. Possibly you edited the project name and that is not an issue? Another thing to verify is that the plist is not corrupt.

like image 44
Cobra Avatar answered Oct 21 '22 16:10

Cobra