WatchOS and location entitlement - ios

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.
I've added the entitlement in the watch app entitlements 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:
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.

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.

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.

Related

Entitlements for multiplatform applications in Xcode 14

When creating a Multiplatform Application prior to Xcode 14, Xcode would create a separate Entitlements-file for each target. Now, with Xcode 14, all targets use the same Entitlements file by default.
After adding the HealthKit capability to an Xcode 14 project and populating the "Privacy - Health Update Usage Description" Key with a string in Info.plist, then prompting a HealthKit authorization request, the screen asking the user to agree to the App using HealthKit data does not pop up. Moreover, the following error is printed in the console: Health request display failed: Missing application-identifier entitlement.
In an effort to fix this problem, I edited the Entitlements file manually to look like this:
Adding the application-identifier entitlement to the Entitlements file manually fixes the issue, however, as the same Entitlements file is also used by the macOS target, Xcode fails to automatically sign the app for macOS and gives the following error:
Provisioning profile "Mac Team Provisioning Profile: com.xx.xx" doesn't include the application-identifier entitlement.
Here you can see the error given in Signing & Capabilities:
What is the correct approach here? Should I manually create a second Entitlements file and separate them? If so, how would this be done? Or is there something else I'm missing?
Any help would be greatly appreciated.
Testing on a real device, without manually editing the entitlements file, the error disappears and the HealthKit permission request is shown appropriately.
Therefore, I believe the behavior above is just a Xcode/Simulator bug in the current beta.

Xcode crashes when capabilities are added to Watch Extension

I just added HealthKit to my project for which you need to add the entitlement in the Signing & Capabilities Section to the respective target.
However, whereas everything worked fine with my iOS App, Xcode crashed after adding the capability to the Watch App Extension. At first nothing happened, but when I clicked on the iOS target again, it crashed.
Did anyone experience something similar?
The entitlements file was missing. I created a property list and changed it to an entitlements file. The reference in the info.plist refered to a entitlements file short cut, which was leading nowhere.

Profile doesn't match the entitlements file's value for the application-identifier entitlement

I am trying to upload an app to the app store and I am getting this error on the page that has the certs. As far as I can tell I have changed the field so they have matched, but I am missing something.
Any help would be greatly appreciated.
I'm not sure why this fixed it, but I went into my Target's Capabilities tab, turned iCloud ON, tried to do an archive build, it failed, I turned iCloud OFF again, tried to do an Archive build and it succeeded, and after that it was able to automatically resolve certificates again.
Rightclick on Finder -> Go to Folder...
~/Library/MobileDevice/Provisioning
For Xcode 11
~/Library/MobileDevice/Provisioning Profiles/
Delete all provisioning profiles, done.
The app you created has an incorrect application-identifier value, for what the provisioning profile is expecting. The cert for appID com.example.foo for the team 2ABCDEFG will be expecting application-identifier: 2ABCDEFG.com.example.foo, your app declared that its appID was com.example.foo, but the application-identifier didn't match, either you are using the wrong team-prefix, or you have the bundleID misconfigured.
In my case, I am using build schemes to allow me to build a prod app and a qa app. com.example.foo for prod, and com.example.foo.qa for QA.
I had set my bundleIdentifier in the Info.plist to $(PRODUCT_BUNDLE_IDENTIFIER)$(BUNDLE_SUFFIX), which works great in the simulator and on device for having different apps, however, when the app generates its application-identifer during the archive phase, it must not be reading the bundleIdentifier generated by the Info.plist.
To remedy the situation, I edited FooProject.xcodeproj/project.pbxproj (with a text editor) to change my QA buildSettings PRODUCT_BUNDLE_IDENTIFIER to com.example.foo.qa
You can see Apple's Technical Q&A and this page to see their in depth dive into solving this. Once you run the following on your exported app:
codesign -d --entitlements :- ./Payload/myApp.app
and see what application-identifier your app was just built with, it should be pretty quick to realize what your are doing wrong.
I didn't find that page in my Google searching, because they don't actually use the phrase from the error message or call the application-identifier by its full name, but instead say App ID.
Also, the solution to this problem isn't to generate a new provisioning profile that has the application-identifier entitlement, it does have that entitlement, however, the value in the provisioning profile, and your app have to match.
Maybe the {project}.entitlements file was missing. Doing what #samkass mentioned will auto generates the file and it will work.
So basically just go to capabilities tab, enable anything, and disable it.
Changing the iCloud toggle to on, building, and disabling iCloud, got rid of the error saying that:
Profile doesn't match the entitlements file's values for the application-identifier and keychain-access-groups entitlements.
In Xcode 11, this could happen when a .entitlement file is not present for your project. The solution would be to add any random capability by clicking on '+ Capability' under 'Signing & Capabilities' (which leads to the creation of an .entitlement file) and then removing the capability. This will let you automatically provision a certificate too.
I'm developping a Flutter app with Flavors that use the --dart-define command.
I've been very inspired by this great article.
However I've encountered this 'application-identifier' issue when deploying.
I've tried a lot of options.
This solution is the one that worked for me.
It's very close to #n8tr's comment, but the difference was the 'instead'.
To resume, just set the Product Bundle Identifier to your.id.here$(DEFINEEXAMPLE_APP_SUFFIX) under Packaging in Build Settings instead of in Info.plist.
Please check your application features which required for your application like In app purchase , push notification , Inter App audio , Siri kit etc.
This is the only cause for this type of error.
Make sure that in your App id the above flags should be on.
Most of time it happens when you not configured push notification , In App purchase in you development App ID.
I went into my Target's Capabilities tab, turned Keychain Sharing ON and it starts working
For me, the trick was to
add/remove a capability for the target (in my case a Widget);
make sure the created entitlements file is listed in the build settings;
and to add the "APS Environemnt" key with value "development" to the entitlemenets file.
In Xcode 10, I got it working by moving the entitlements file to correct folder in Project Navigator. I didn't have the entitlements file, but I managed to get one by toggling features on capabilities tab.
I got this same error and none of the solutions above solved the problem in my case.
What did work for me was to change the "Can be debugged" setting in the "Entitlements.plist" file from "NO" to "YES."
In my case the issue was following: provisioning profile used for build step was created for different app id than provisioning profile used for export step.
So make sure you're using the same provisioning profile for build and export step.
What worked for me was that I made the archive in XCode 11, and did the upload in it Xcode 12 beta.
Just have a look, whether the "Sign in with Apple" capability is added along with other capabilities such as "Background Modes" & "Push Notifications"!
In my case, it was there.
So after deleting the "Sign in with Apple" capability, it got removed from the 'project.entitlements' file and the provision profiles got synced immediately.
Cross check capabilities in the app with options you enabled for your App Id in your developer account.
I tried a few options listed in the answers here but none helped, however, toggling the checkbox "Automatically manage signing" off and on fixed the problem.
TL;DR: check your App ID and make sure the services are matching what's in your target.
What happened to me was that I let Xcode 10.1 help me create an App ID, and after that, I run into the problem as described here. (I selected whildcard app ID when I created the app in iTunesConnect, so I didn't even realized this was done.) When I opened iOS developer portal, the new app ID has Game Center and In App Purchase enabled automatically.
Since I couldn't enable Game Center in your Target -> Capabilities, I enabled In App Purchase, and then my app could be signed and uploaded.
When we faced the same issue, we tried all the above things but none of it worked.
What worked for us is changing the bundle identifier so that it was not identical to the previous one, for example "com.name.App" to "com.name.App2"; let xcode attempt to fetch/create provisioning profile and then chance it back to the original one.
Got this idea from this thread on Apple's developer forums- https://forums.developer.apple.com/thread/114539
I came across this page recently after trying to create a duplicate target - none of the suggestions were working for me. Further investigation, and some amount of hair pulling, eventually led me to scouring through the build settings for my app to try and figure out what was wrong.
It turned out that my project was still pointing to the entitlements file of the ORIGINAL target, rather than having one of its own. To resolve this, I navigated to the original entitlements file in Finder (e.g. ${SRCROOT}/MyProject/Entitlements/TargetName.entitlements), created a copy within the same folder and then renamed it (e.g NewTargetName.entitlements).
Then, I opened my new entitlements file and changed the application-identifier field to match the ending of my new target's bundle identifier (e.g. ABCDEFGH.US.co.fake-company.superduperapp-newtargetname).
Finally, I updated the 'Code Signing Entitlements' field in the build settings to the path of my entitlements file (for me, this was something along the lines of ${SRCROOT}/MyProject/Entitlements/TargetName.entitlements).
I returned to the Signing & Capabilities tab, and lo, the issue was fixed. Hope someone out there finds this useful.
Go to Xcode's Info tab and change Bundle identifier field - after changing app name it didn't change even though I changed Bundle Identifier on the General tab. The above fixes did not work for me but this one did instantly.
I had this issue with a brand new app, in Xcode 12 beta 3 (app submissions started today).
Xcode had "Automatically manage signing" on. However, the Team ID displayed in the "Signing Certificate" didn't match the Team ID displayed in iTunes Connect website. This was the root cause preventing the app from being uploaded.
How I fixed it:
I manually created a provisioning profile for App Store distribution
In Xcode, I tapped on "Download manual profiles" in Preferences -> Account
Then, I turned off "Automatically manage signing".
Once I selected the provisioning profile in the dropdown, the correct Team ID appeared under "Signing Certificate"
I ran into the same issue while setting up a Gitlab pipeline that runs exportArchive cmd and uploads to AppStore. I was able to get it to work by changing the DEVELOPMENT_TEAM in Build Settings to the same Team selected in Signing & Certs.
Because previously it was set to blank which was using another DEV TEAM id by default which was incorrect and didn't match and it was complaining about the "application-identifier" = 12331232.com.bannana.apples.peach not matching. Which lead me to setting the correct DEV TEAM and it worked.
Xcode ver: Version 11.3.1
I hope this helps somebody.
Our Setup
Multiple targets:
sub-apps
watch
app clip
today widget
...and use iCloud.
Turning iCloud on and off was not an option for us. We already use it in production and rather not mess with it... I got the original question's message and this variation at some point as well:
Profile doesn't match the entitlements file's values for the
application-identifier and keychain-access-groups entitlements.
Solution
Hinted from other responses here, We made sure that all targets would have a .entitlements file. If the target had none we created an empty one like so:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
...and pointed it's target Code Signing Entitlement in Build Settings to the empty .entitlements file.
Solved!
Delete all profiles located in ~/Library/MobileDevice/Provisioning Profiles/
in my case , I had to put :
<key>aps-environment</key>
<string>development</string>
in all files with extension .entitlements
In my case I am creating multiple apps from one code base using --dart-define, and building flavors in flutter app.
I have done everything right but only one
as mentioned in the comment above
https://stackoverflow.com/a/65292545/8787695
I have already written app_suffix in the build settings (PRODUCT_BUNDLE_IDENTIFIER = com.flutter.myapp$(APP_SUFFIX)).
but I have also written app_suffix in the info tab to the Bundle identifier.
I have the same problem because I had a wrong value in iCloud Key-Value Store inside the entitlements file. I set the following value and the error was solved:
iCloud Key-Value Store = $(TeamIdentifierPrefix)$(CFBundleIdentifier)
Removing this fixed the issue on my side.
OTHER_CODE_SIGN_FLAGS = "--deep";
My main target had this build setting and that way it overwrote the code signing entitlement of the embedded application with the parent code signing entitlement.

Invalid code signing entitlements - specifically value 'dns-proxy' for key 'com.apple.developer.networking.networkextension'

I am working an existing app on the App Store. The only thing I have to do is update the splash screen and icon.
However, when I try to upload iTunes Store I get the error:
"Invalid code signing entitlements - specifically value 'dns-proxy' for key 'com.apple.developer.networking.networkextension' in 'Payload/AppName.app/AppName' is not supported."
I'm new to building IOS apps - can someone please point in the right direction to fix this?
I solved this problem by adding the Network Extensions capability, which seems to only appear in Xcode 8.3.3, for all related targets in the Capabilities Tab.
I found the solution.
Go to the You Apps on Apple Developer.
Go to your Idetifiers (App IDS) and uncheck Network Extensions.
Try again to upload.
I guess you need to update your developer certificate in your XCode and patch it again.Try to validate it before you upload it.

iTunes Connect - entitlement error

Apps that use the entitlements [com.apple.developer.homekit] must have a privacy policy URL for [English, Turkish]. If your app doesn’t use these entitlements, remove them from your app and upload a new binary.
I didn't choose home kit entitlement in App ID. Where will I remove from this entitlement ?
First check that HomeKit is off in your app's capabilities pane in Xcode:
Then remove HomeKit.framework from link step in the Build Phases pane:
Then in the developer portal, in Certificates, Identifiers and Profiles, make sure HomeKit is disabled in your App's Identifier:
Clean your project and remove derived data.
I exactly have done all of this. But still it gives me same error. Im sure the app doesn't include anything about homekit. Maybe it can be different solution for this, can't be ?

Resources