I have updated my app to support Share Extension and it requires share keychain between containing App and extension, so that I need create a keychain access group. The app was working fine in simulator, but it will crash with the above exception in a real device. When debugging, I found the reason code is -25243.
The keychain wrapper i was using is from this link. https://gist.github.com/dhoerl/1170641
After troubleshooting for a few days, i found that the reason is that I was accessing using the wrong keychain access group.
-25243 is related to keychain permission and I didn’t see this error in simulator because simulator app wasn’t signed
For the sake of context, i set the keychain access group in Target->Keychain sharing, then directly accessed the keychain with the group name. This is wrong because the actual keychain access group should be $(AppIdentifierPrefix)whatever.you.set. You can find it from entitlements.plist.