Xcode 8 APS Environment Entitlement won't set to production
Asked Answered
S

4

40

I have push notifications working on my app.
I went to go submit a new app update and I ran into an error with APS environment not being set.
I hit fix issue and it created the entitlement file with APS environment set to development.

To submit the app I obviously want this set to production. I change the value to production and proceed to archive the app for submission.
It throws an error in the capabilities section for push notifications with the last past "Add the Push Notifications entitlement to your entitlements file" being red.

So when I hit fix issue, it then changes the value of APS environment to development.
I came across a suggestion to inspect the provisioning profile and look for the APS environment property.
I went through the process of archiving and selected "Upload to App Store".

When I finally reached the summary, I clicked on the provisioning profile attached to the binary and entitlements.
I open the provisioning profile in a text editor and looked for the APS environment property.
I did find the property and it is set to production in the provision profile.
I decided to try another suggestion, which was to recreate the distribution provisioning profile.
I did make a new one and that solution doesn't work either.

From what I understand, the APS environment property is based on the value in your provisioning profile.

Any help would be appreciated. Thanks.

Spectrometer answered 21/9, 2016 at 19:43 Comment(0)
G
18

Turn off the "push notifications" in Capabilities then re-build.

Update

After hours of debugging, no matter how you configure Xcode8 or build with whatever scheme(debug or production), you will always get a deviceToken for development environment from APNS. I tried to remove my app on my test device which build directly from Xcode8.1 with production scheme. Then I installed my app from AppStore, which was archived from Xcode8.1 with same configuration two weeks ago, the AppStore version's notification service works fine, which proves that Xcode did set the right entitlement value for production environment. So, the solution is: leave the entitlements file alone, and keep "Push Notifications" switch on in Capabilities, do any fixes Xcode asked for. Hope this would help you.

Grivation answered 29/11, 2016 at 4:32 Comment(3)
This is so confusing from Apple. I did a quick search for documentation on the aps-environment entry and the information provided is practically none. Do you know of any other resources? Some SO answer, perhaps?Christelchristen
Unfortunately I don't, sorry about that. I do have read some related threads about it, but none of these article mentioned or quoted any official documents from Apple.Grivation
I can confirm, that this description is correct. The trigger whether APN sandbox or production servers are used, seems to be the certificate (e.g. provisioning profile) which has been used to sign the app (dev = sandbox / ad-hoc & distribution = production).Viguerie
C
7

For me XCode 8 'Automatically manage signing' feature do it automatically & correctly when archiving according to provisioning profile we select for deployment method.

Chinkapin answered 19/10, 2016 at 14:8 Comment(0)
B
4

Try to re-enable "Push Notifications" capabilities in , it worked for me, if this don't help, try to delete file with entitlements in your project, and again re-enable "Push Notifications" capabilities in your project settings

Bushcraft answered 22/9, 2016 at 13:37 Comment(6)
I tried both of your suggestions and still can't get the entitlement on the summary when I archive. Thanks for your help.Spectrometer
Maybe it will be useful to read those pewpewthespells.com/blog/migrating_code_signing.html #39491105Bushcraft
As i understanded with the new Apple signing, that is you don't need to change ***.entitlements file by yourself. The XCode make it for you, when you archive build, and export ( via organizer ) is like ad-hoc or distribution to App Store. It will be setted correct environment.Bushcraft
Thanks for the help Mr.Fingers, I do agree with what your saying based off my own research.Spectrometer
If I compile an ipa for the enterprise distribution and then i open it the integrate entitlements file say development under the key aps-enviroment....Stevestevedore
@Bushcraft yeah, that is what I see too. Unfortunately, depending on undocumented behaviour can be 🤔Herson
R
0

After trying all the answers in stack over flow found out the problem is in entitlement.plist file can be debugged flag was set to TRUE.

  1. Try to disable and re-enable push notifications in Xcode target capabilities.
  2. Can be debugged flag should be set to NO to submit it to AppStore.

Build and archive. You should be able to see environment set to production.

Rajasthan answered 18/5, 2018 at 5:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.