aps-environment is always development

IosObjective CApple Push-Notifications

Ios Problem Overview


I have created the app id with APNS enabled and I configured both development and production certificate

Now when I create entitlements it is always displaying development even If I change the Provisioning profile to iTunes deployment also the entitlements is displayed as development

<?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>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>

Ios Solutions


Solution 1 - Ios

You can't use a production certificate in debug/development. Even if you do it, then, when you 'Archive', Xcode will automatically set it to production (Apple reference). You can see this when you try to submit your app to iTunes connect for TestFlight/Review or for Adhoc deployment.

Xcode 8: ![Xcode 8][2]

Xcode 9: ![Xcode 9][3]

[2]: https://i.stack.imgur.com/4tJQv.png "Xcode 8" [3]: https://i.stack.imgur.com/q7XfG.png "Xcode 9"

Solution 2 - Ios

There is a known bug in Xcode whereby manually setting this to 'production' causes Xcode to display an error next to your entitlements config with a 'Fix Issue' button. Clicking this sets it back to 'development' This is not intended functionality. As I said it is a known issue and I believe I filed a radar when I first discovered it.

It has been fixed in Xcode 8.3 beta 2. In the meantime, manually set it to 'production' and then ignore the error Xcode gives you, your project will work just fine.

Solution 3 - Ios

XCode 10.2:

If you change your target to "Generic iOS Device" before Archive it will set the aps-environment variable to production. If you archive with the target set to your device it will archive with the aps-environment variable set to development.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAJ SanjayView Question on Stackoverflow
Solution 1 - IosShebukaView Answer on Stackoverflow
Solution 2 - IosJacob KingView Answer on Stackoverflow
Solution 3 - IospizzamonsterView Answer on Stackoverflow