aps-environment is always development
Asked Answered
L

3

85

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>
Lough answered 17/2, 2017 at 7:54 Comment(1)
Its value is automatically updated by Xcode according to Apple documentationPeriod
P
113

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

Xcode 9: Xcode 9

Petaloid answered 17/2, 2017 at 9:4 Comment(9)
when i run my app from xcode, push notification works, but when i upload the build to appstore and download it for testing using testflight it won't work.Cockney
@AbhishekPandya on you push server you must change from developer to release certificates to test with TestFlight and make it work with official AppStore release.Petaloid
So true, that's why I keep seeing inconsistent behaviors between Xcode app and TestFlight appDairy
Isn't there a way to edit info.plist so you don't see this screen when uploading to the App Store?Symphonic
@Petaloid can you please tell me where i can find this screen in xcode 10 ?Lymphocytosis
It's automatically updated by Xcode according to Apple docPeriod
@Period Thanks, I've added the reference to the docs to my answer.Petaloid
> on you push server you must change from developer to release certificates I use Firebase. What's certificate for it??Inspan
@Inspan this in unrelated question to the topic, ask a new one.Petaloid
D
16

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.

Dictate answered 12/4, 2019 at 14:37 Comment(0)
D
14

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.

Direful answered 17/2, 2017 at 8:5 Comment(8)
If I do this am not able to archiveLough
great! my adhoc build was not getting uploaded to the device. After I changed from "development" to "production", it worked. Thanks a lot.Parasympathetic
Note that Xcode will automatically change development to production now when you archive for release. You can confirm this when you review the IPA for upload.Clearsighted
I'm on Xcode 10.3 and I still have this issue. Glad to know that it will automatically use production when archiving it.Tyrosine
There's no more error on Xcode 13 but the APN environment setting of "production" is not respected. Xcode always build the app with "development" setting in debug mode. You can verify it by opening the package of compiled app, and find the embedded.provisionprofile file inside of it.Cookbook
Is it possible to set APS Environment as production in a debug build and run in xcode? Or xcode ignores this and will it change to development automatically?Caftan
@Cookbook is there a way to make it stay on production while testing? I am trying to test my prod push notifications but I can't get it to stop returning BadDeviceToken and I know it is because of thisAerify
@Aerify I don't think so. I guess the system is designed to prevent developers from accidentally sending test notifications to end users from App Store.Cookbook

© 2022 - 2024 — McMap. All rights reserved.