How to share keychain data between iOS applications
After some (a lot of) digging throughout the web, I found the answer. The access Group that you use when constructing your KeychainItemWrapper class must ALSO be specified in each of your application's Entitlements.plist file in the "keychain-access-groups" section.
It seems almost obvious now that I see "keychain-access-groups". However, I had no idea to even look there. Hope this helps others.
Actually it's not hard to do. Please follow the steps.
App1:
- Open your App's target Capabilities and enable KeyChain Sharing.
- Add a identifier. (eg : com.example.sharedaccess)
- Add "UICKeyChainStore" to your project.
- Be sure you have a team id added to your App1 project.
- Add Security.framework to your App1 project.
-
And add these codes to somewhere you need.
[UICKeyChainStore setString:@"someValue" forKey:@"someKey" service:@"someService"];
App2:
- Open your App's target Capabilities and enable KeyChain Sharing.
- Add a identifier. (eg : com.example.sharedaccess)
- Add "UICKeyChainStore" to your project.
- Be sure you have a team id added to your App2 project.
- Add Security.framework to your App2 project.
-
And add these codes to somewhere you need.
NSString *string = [UICKeyChainStore stringForKey:@"someKey" service:@"someService"];
Your TeamIDs should be same for both projects.
- I tried these steps on a real iPhone device.
- I also tried these steps with Automatic and iOs Development provisioning profile.
- My apps' bundle identifiers were like that : com.example.app1, com.example.app2.