Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 950
Husein Behboudi Rad Avatar asked Sep 11 '16 14:09

Husein Behboudi Rad


People also ask

What is iOS group App?

App groups allow multiple apps produced by a single development team to access shared containers and communicate using interprocess communication (IPC). Apps may belong to one or more app groups. For iOS, format the identifier as follows: group.<group name>

What is keychain in Swift?

Keychain Services help you to securely store items, or small chunks of data, into an encrypted database on behalf of the user. From Apple's documentation, the SecKeychain class represents a database, while the SecKeychainItem class represents an item.


1 Answers

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>
like image 182
Husein Behboudi Rad Avatar answered Sep 22 '22 19:09

Husein Behboudi Rad