문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top