Xcode 4.6 automatic entitlement not working - “no valid aps-environment”

别等时光非礼了梦想. 提交于 2019-12-24 02:19:05

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/15687887/xcode-4-6-automatic-entitlement-not-working-no-valid-aps-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!