aps-environment is always development - ios

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>

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 9:

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.

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.

Related

Xcode 8.1 "No matching provisioning profiles found" after updating MacOS and Xcode

I'm testing my app with TestFlight but I can't upload my archives after updating to MacOS 10.12 and Xcode 8.1.
When I archive my app, click on "Upload to App Store...", select my Development, I get this error.
No matching provisioning profiles found for "Applications/app.app"
None of the valid provisioning profiles allowed the specified entitlements: application-identifier, beta-reports-active, keychain-access-groups.
What I've tried so far:
Reopening Xcode (Many times)
⌘+, > select team > remove every provisioning profile > re-download every provisioning profile (Reopening Xcode after each step)
Re-downloaded and installed my certificates and provisioning profiles
Removing every provisioning profile and building the app
I had this same error when my Xcode wildcard profile expired. Xcode didn't automatically renew it even though everything was set to automatic.
I logged in to the the portal, edited the XC: * profile, hit generate and then downloaded the resulting certificate. All good after that.
On Xcode's Capabilities screen, turning a capability On and then Off will fix the issue.
None of the other answers worked for me.
I had to delete all certificates from KeyChain, and also revoke them in Apple Developer portal. Then manually request a Distribution certificate in KeyChain. Upload it to the Developer portal.
XCode (8.3) must be stopped because it keeps creating certificates as they are being deleted from KeyChain.
Also, KeyChain burped and suddenly had a whole bunch of certificates and keys that it wasn't showing before. I don't know why that happened. Some were expired, which may have been causing the original problem. I deleted them all too.
Finally, XCode was happy to Archive, and Upload to iTunes. Only two hours wasted this time.
Use the automatic option provided in Xcode just add the relevant account team in the Xcode and let Xcode manage the signing process. Then go for Archive and select proper options while making archiving.
I was running into the same issue. As our project was automatically generated by Ionic and had to be build in a CI environment, opening the project and toggle automatic signing wasn't an option. I did a diff of the entitlements file before and after the toggle and found out that the dict value was sorted differently:
<!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>production</string>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
</array>
- <key>aps-environment</key>
- <string>production</string>
</dict>
</plist>
Even though from my understanding it shouldn't make a difference, the build was successfull after this change.
For everyone running into this in an Ionic project, the solution was to add this key-value pair to the config edit in the config.xml:
<config-file parent="keychain-access-groups" target="*-Release.plist">
<key>aps-environment</key>
<string>production</string>
<array>
<string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
</array>
</config-file>

The executable was signed with invalid entitlements 0xe8008016 - Distribution certificate

I am getting error:
The executable was signed with invalid entitlements.
The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile. (0xE8008016).
on DISTRIBUTION CERTIFICATE & PROVISIONING Profile. Earlier, I was able to install the build using distribution profile, But, now I am not able to do so. It gives above error.
Below is my entielement contents:
<?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>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.myapp.xyz</string>
</array>
</dict>
</plist>
I have enabled PushNotification in my appid.
From past 2-3 days, I have gone through many such post on stackoverflow and tried various solutions. But none of them has worked.
Things I have done to resolve,
Created a new cert and provisionf profiles
Removed old certs from keychains and installed new ones
Removed old provision profiles from system and installed new ones (Manully and automatically through Xcode->Preferences->account->view Details-> download all)
Restareted XCode many times after removing certs adding new ones
Clean and build project
Cleared derived data
Kept Provisioning profile on automatic (but it builds with developer provisioning profile, dont know why)
According to error, I have matched my provision profile Application services (as per my appID in developer portal) with build capabilites in XCode. But its not working.
Does that .entitlements file has to do anything with "Build capabilites"? I tried removing .entitlementonce but no luck.
UPDATE:
I created a new project, New appID (The default ones are enabled. In-app and game center) and new distribution provisioning profile. Still gives same error. :(
UPADTE 2: Adding image of keychain
Look into the test target, the team should be the same in both the test target and the main target.
Issue is due to distribution provisioning profile try using development or Ad-Hoc provisioning,Hope it's work ,Good luck
In my case, before the build I have added a key ITSAppUsesNonExemptEncryption in Info.plist which may not included in the provisioning profile. After removing ITSAppUsesNonExemptEncryption from Info.plist I am able to build successfully.
I had this issue, and it was due to the existing builds in TestFlight expiring, so it's worth checking the build you've installed hasn't expired before doing any further investigation.

Apple Pre-Release app submission "Missing beta entitlement"

I was trying a long to give pre-release thru itunes connect, I have created the new Certificate for production / App Id / Adhoc provisional profile against newly created certificate. I was always met with missing beta entitlement during export build thru organizer.
I had tried with Application Loader to send the build to itunes but received warning as below.
"Missing beta entitlement.Your app does not include the beta-reports-active entitlement. If you intend to distribute this build via TestFlight for beta testing, please re-build this app with a newly generated provisioning profile."
Adding Entitlement.plist file was not worked out,
This issue swallowed my whole day, If anyone produce right solution here would be really appreciated.
Try using 'App Store Distribution Profile' instead of Ad-hoc. It will be still in pre-release state. You can add internal testers etc. This worked in my case.
You have 2 known options :
1 - edit your .plist file and add "beta-reports-active" line like below (Value must be true) :
<?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>production</string>
<key>get-task-allow</key>
<false/>
<key>beta-reports-active</key>
<true/>
<key>application-identifer</key>
<string>youridentifierhere</string>
</dict>
</plist>
2 - If didn't work, for some cases "create brand new provision profile" could work.
This got screwed up by Apple when they merged TestFlight into iTunes Connect. I'm assuming that you have an old certificate still. You need to regenerate your certificates and provisioning profiles and go through the signing process from the beginning.

During ios app submission to appstore/itunesconnect, getting warning as "Build xxxx does not contain the correct beta entitlement"

I have uploaded my first ever ios app 1 week before and it is in "waiting for review" status. Today i came to notice that when i clicked on "Prerelease" it is giving warning as "Build 1.1 does not contain the correct beta entitlement. For more information, see the iTunes Connect Developer Guide."
Can anyone pls let me know what will happen to my app? it will be approved or get rejected? since it is a warinig not error and i successfully uploaded this with this...
I came to solution that i need to recreate distribution provisioning profile and rebuild my app and resubmit... but it will again take 1 week to "review" so i dont want to go for that.
Anyone have come accross this issue please let me know what will be best solution for me... I am very much worried as i have only this week for this app to make it live.
Thanks.
Apparently, Apple created a new entitlement that is added when you regenerate your distribution certificate.
If your app is already "Waiting for Review", it should be fine.
If you want this warning to go away:
Regenerate you Provisioning Profile, download it, rebuild your IPA and upload the new Archived Binary.
Please make the file Entitlements.plist in your project Bundle and then paste this source. And after that just make a fresh build and upload the binary once again by changing the build no. Its not necessary to change the Version No.
<?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>production</string>
<key>get-task-allow</key>
<false/>
<key>beta-reports-active</key>
<true/>
<key>application-identifer</key>
<string>bkahblahblah</string>
</dict>
</plist>

Xcode 4.6 automatic entitlement not working - "no valid aps-environment"

I'm getting the famous error:
Failed to get token, error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x413be0 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}
I am able to fix it by editing the following file:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/Entitlements.plist
And manually adding the aps-environment key 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>
<key>application-identifier</key>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>aps-environment</key>
<string>development</string>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
</array>
</dict>
</plist>
Then, Xcode is generating correct Xcent file, which contains the aps-environment key at:
/Users/mySelf/Library/Developer/Xcode/DerivedData/myApp-buauvgusocvjyjcwdtpewdzycfmc/Build/Intermediates/myApp.build/Debug-iphoneos/myApp.build/myApp.xcent
And running the App on iPhone is able to produce device token for push.
This is the only way I found to fix the issue.
( you may use this info for your own troubleshooting in case you encounter this error )
Now, I have the same project running on another laptop (synced with git),
with the same Xcode version 4.6.
This problem does not occur on that laptop.
Project settings/provisioning profile,etc are all 100% the same on both machines.
( Please trust me on this one )
Did anyone encounter such issue with Xcode 4.6 ?
I should probably open a ticket at Apple's support as well.
Just wondering if another more elegant solution is available.
Update:
The above fix could be sufficient only for devel stage but not for release.
A more elegant solution for overriding the default Entitlements.plist is to make a copy of the default Entitlements.plist that you have editted, and put that in your project.
Then, set the Code Signing Entitlements for whichever target build you are having problems with (in this case I've set it for Debug).
This should then use this plist file for Debug builds (ie when simply pressing Run) and your device will register with the APNs development servers

Resources