Search code examples
iosxcodekeychainentitlements

Keychain Access Groups in entitlements for multi target iOS apps


I have an iOS application project with 2 separate targets. For example target A and target B. Now in xCode8 when I turned keychain sharing to ON the Xcode generates two A.entitlements and B.entitlements files. Unexpectedly both of them have the same value like this:

<plist version="1.0">
<dict>
    <key>keychain-access-groups</key>
    <array>
        <string>$(AppIdentifierPrefix)target1.bundle.identifier</string>
    </array>
</dict>
</plist>

I mean in both of the file uses bundle identifier of my first target; and When I manually try to change the value for one of them the other one changes too.

As you know the Xcode will not sign the app while the value in keychain-access-groups exactly match the bundle identifier of the provisioning profile you use for sign.

So I am wondering how we can have two separate values for two separate entitlements files of two separate targets?


Solution

  • I finally fixed this by using below code in my entitlements:

    <plist version="1.0">
    <dict>
        <key>keychain-access-groups</key>
        <array>
            <string>$(AppIdentifierPrefix)$(PRODUCT_BUNDLE_IDENTIFIER)</string>
        </array>
    </dict>
    </plist>