Question

I am working on an app that stores a password in the keychain. Everything is working fine when I run the app from Xcode using a development profile - I can save a password, quit the app, relaunch and fetch the password from the keychain.

However, whenever I run the app using an Ad Hoc or App Store profile SecItemCopyMatching always returns errSecItemNotFound when I try to fetch the password from the keychain after relaunching the app.

Is there something I missing with the app ID, provisioning profile or entitlements?

Was it helpful?

Solution

Turns out I was being caught out by the Enable Foundation Assertions build setting. It seems to be set to No by default for release builds.

I was using code from Keychain Services Tasks for iOS in the Apple Docs which has a lot of the keychain calls (including SecItemAdd) wrapped in NSAssert() therefore they weren't getting called and nothing was getting saved to the keychain.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top