anyone can help me
codesourse opened this issue · 13 comments
UICKeyChainStore *keychain = [UICKeyChainStore keyChainStoreWithService:@"xh.english.brush"
accessGroup:@"test.hello"];
keychain[@"user_name"] = loginView.userNameField.text;
keychain[@"pass_word"] = @"123456";
keychain[@"downDataFlag"] = [returnValue.D ObjectForKey:@"downDataFlag"];
keychain[@"usFlag"] = [returnValue.D ObjectForKey:@"usFlag"];
keychain[@"usGroupid"] = [returnValue.D ObjectForKey:@"usGroupid"];
keychain[@"usId"] = [returnValue.D ObjectForKey:@"usId"];
keychain[@"usName"] = [returnValue.D ObjectForKey:@"usName"];
keychain[@"usSessionId"] = [returnValue.D ObjectForKey:@"usSessionId"];
keychain[@"usType"] = [returnValue.D ObjectForKey:@"usType"];
keychain[@"usUid"] = [returnValue.D ObjectForKey:@"usUid"];
NSLog(@"keychainpass_word=%@",keychain[@"pass_word"]);
keychainpass_word is nil
It seems really weird. Other values, like"user_name", "downDataFlag", are stored correctly? Are there any error messages in Xcode console?
UICKeyChainStore *keychain = [[UICKeyChainStore alloc]initWithService:@"xh.english.brush" accessGroup:@"hello"];
keychain[@"pass_word"] = @"21e12e";
NSLog(@"keychainpass_word=%@",keychain[@"pass_word"]);
----------------------方法: __31-[LoginViewController loginAct]_block_invoke279
----------------------行数: 153---------------------
----------------------内容:keychainpass_word=(null)
Could you please share reproducible project?
you wait a minute,I create a new project.
2015-08-08 15:56:32.345 testKeyChain[2374:281142] OSStatus error: [-25243] Security error has occurred.
2015-08-08 15:56:32.348 testKeyChain[2374:281142] keychainpass_word=(null)
handsome boy help me.
@codesourse There is no code using UICKeyChainStore in the project. Did you forgot to commit your code?
sorry,i commit it again.
Because you specify access group, you should make entitlements for allowing to access the access group.
To make entitlements,
- Select project settings, then click capability tab
- Turn ON Keychain Sharing
- Input access group name that you use in your app (your example is 'hello')
Then, the entitlements file will be like following:
You should specify access group with "App ID prefix". So the code is to be like following:
(27AEDK3C9F
is my App ID prefix. You have different one.)
UICKeyChainStore *keychain = [[UICKeyChainStore alloc]initWithService:@"xh.english.brush"
accessGroup:@"27AEDK3C9F.hello"];
Why it is ok,when running on the simulators?
Any simulators do not have access group. When running on simulators, the access group automatically set to test
despite of you specifying any other text. So most keychain library ignore access group settings when running on simulators. Of course this library also does so.
Thank you very much!