iOS开发-使用KeyChain保存密码等信息

  • 最近使用了KeyChain实现保存密码等敏感信息的功能,使用了SAMKeychain,但是出现了保存密码信息失败的问题,最后在stackoverflow上找到了答案。

SAMKeychain setPassword is failing

NSLog(@"SETTING VALUE %@", value);
[SAMKeychain setPassword:value forService:SERVICE_NAME account:key];
NSLog(@"READING VALUE %@", [SAMKeychain passwordForService:SERVICE_NAME account:key]);

I am always getting (null) after setting a value. This wasn't happening before I updated XCode.
Does anyone has any idea what can be the problem?

The iOS 10 keychain has been buggy since the early beta of iOS 10. As a (hopefully temporary) workaround, enable the Shared Keychain entitlement in your app. This bug affects every keychain wrapper out there, and not only SAMKeychain.

你可能感兴趣的:(iOS开发-使用KeyChain保存密码等信息)