Search code examples
iosxcode8entitlementsios-app-groupcode-signing-entitlements

Xcode 8: different entitlements for each scheme causing errors


I found an issue with Xcode 8 where .entitlements files are not being referenced properly for each scheme. Basically, my Debug .entitlements file is being referenced for my Release scheme. This is causing an issue because we implemented the new Rich push notification logic and that requires the use of App groups.

I am using two different teams (Development and Production), so there will be two specific App Groups.


Solution

  • I found a solution. Make one .entitlements file add this:

    <key>aps-environment</key>
    <string>$(APS_ENVIRONMENT)</string>
    <key>com.apple.security.application-groups</key>
    <array>
        <string>$(APP_GROUP)</string>
    </array>
    

    Then in Target > Build settings Set the same .entitlements file in Signing > Code Signing Entitlements Add User-Defined Setting for APS_ENVIRONMENT and APP_GROUP setting the correct group for each target.

    So, based on the target Xcode will use what you set for APS_ENVIRONMENT and APP_GROUP.

    You can do this in plist too...did some amazing clean up today.