I was having trouble saving sensitive data in KeyChain while running in Xcode 8 in iOS 10 simulator. The following code returns NO if I run in Simulator and the same code returns YES when running in physical device / iPhone
+ (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName account:(NSString *)account error:(NSError *__autoreleasing *)error { SSKeychainQuery *query = [[SSKeychainQuery alloc] init]; query.service = serviceName; query.account = account; query.password = password; return [query save:error]; }
Above code is copied from SSKeyChain.m file
I got the error code -34018 (errSecMissingEntitlement) when started debugging further.
Solution is easy and simple: Enable KeyChain Sharing under Capabilities pane in the project editor for your target.