KeychainItemWrapper error while specifying access group

For some time now I have been successfully reading and writing private keychain items using the ARC version of KeychainItemWrapper.

I am now working on converting my iOS app to use a shared group so the keychain objects can be accessed by my two apps that use the same app prefix. In the "Features" section, I added the keychain group "MYAPPPREFIX.MYSHAREDACCESSNAME"

I am using these lines to write my variable to the keychain group:

keychainItemWrapper = [[KeychainItemWrapper alloc] initWithIdentifier:key accessGroup:@"MYAPPPREFIX.MYSHAREDACCESSNAME"];
[keychainItemWrapper setObject:value forKey:(__bridge id)(kSecAttrAccount)]; // store the new value in the keychain


If accessGroup is nil it works fine. However, if I specify an access group, I get a crash with the following error in the debug log:

Confirmation failed at - [KeychainItemWrapper writeToKeychain], .... / KeychainItemWrapper.m: 329 Application terminated due to unreported 'NSInternalInconsistencyException', reason: 'Failed to add Keychain item'.

The resulting OSStatus error code is -25243, which I was unable to track down for more information.

Is there anything else you can do to write to the shared group?


source to share

1 answer

In case it helps others, I was able to identify the problem. In Xcode's 'Capabilities', I needed to omit the app id prefix. However, when identifying an access group, you must include the Application ID prefix.

So, in capabilities, I named the group "myAccessGroup".

In my code, I am including the prefix as such:

keychainItemWrapper = [[KeychainItemWrapper alloc] initWithIdentifier:key accessGroup:@"xxxxxxxx.myAccessGroup"];




All Articles