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.