How to fix “no valid 'aps-environment' entitlement string found for application” in Xcode 4.3?

前端 未结 23 1899
长情又很酷
长情又很酷 2020-11-27 10:43

I\'ve been trying very very hard to create a simple simple iOS app which can recieve push notifications. My only reason for doing this is to establish a procedure for some

相关标签:
23条回答
  • 2020-11-27 10:54

    XCode 6.1.1, and multiple apple developer accounts

    Another answer for this already fairly comprehensive mix: I came across this issue again today, and this time it was due to my having multiple apple accounts. I needed to first add the 2nd developer account in XCode > Preferences > Accounts > +

    Ensure that the Push Notification Capability is ON

    Next I needed to actually explicitly enable In-App Purchase in the app (I did not need to do this previously). XCode > (the app window) > Targets > Capabilities > In-App Purchase ON (and at this stage I was given the option to choose the correct certificate)

    Note that I had already added the Push enabled certificate by double clicking it in Finder.

    0 讨论(0)
  • 2020-11-27 10:57

    This error may occur when your certificate has expired.

    The solution is to renew certificate and sign the application with it.

    0 讨论(0)
  • 2020-11-27 10:57

    There seem to be something quirky with the 'automatic' entitlements in Xcode 4.6.

    There is an Entitlement.plist file for each SDK at:

    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/Entitlements.plist
    

    A workaround solution I came up with was to edit this file and add the sneaky aps-environment key manually 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
    

    You can locate where your Xcent file is created using Xcode's Log Navigator,
    look for "ProcessProductPackaging".

    Unfortunately, this is the only way I found that fixes the issue.
    (and finally able to properly get push token now)

    Just wondering if another more elegant solution is available.
    Please see my SO question for more details on that:
    Xcode 4.6 automatic entitlement not working - "no valid aps-environment"

    0 讨论(0)
  • 2020-11-27 11:00

    Before deleting and regenerating AppIDs/Profiles, make sure your Library and Device have the same (and correct) profiles installed.

    I started seeing this error after migrating to a new computer. Push had been working correctly prior to the migration.

    The problem was (duh) that I hadn't imported the profiles to the Xcode library on the new machine (in Organizer/Devices under Library->Provisioning Profiles).

    The confusing part was that the DEVICE already had the right profiles and they showed up as expected in build settings, so everything looked correct there, but the XCode LIBRARY didn't have them, so it was signing the app with...???

    0 讨论(0)
  • 2020-11-27 11:01

    The answer was: start over, do everything the same but create a new provisioning profile, and install it. That worked. Inspecting all the details (entitlements in mobile provision) looks exactly the same as everything in my question here. But now it works. Apple: WAT?

    Of course, it would have been obvious to do this if it was possible to delete provisioning profiles. But since that's not possible, I didn't want to clutter our team with a bunch of test profiles. Still, finally lost patience and tried it anyway, and it ended up working. Whatevs.

    0 讨论(0)
  • 2020-11-27 11:01

    Ran into this same issue myself. For me, the issue was that my product name ($TARGET_NAME) was not capitalized the same way presented in the certificate provided by apple. For example, i had com.companyid.APNDemo whereas the Apple cert was using com.companyid.apndemo.

    I changed my target to be lowercase and it worked. Note: The clue for me was the codesigning setting in Build Settings was set to my default developer certificate; not the APNTest provisioning profile.

    0 讨论(0)
提交回复
热议问题