Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find Keychain value when running from XCode

I'm using SSKeychain to store a session token. When I compile and run the app from XCode, sometimes the token cannot be found (seems like it works sporadically). However, if I unplug my device and run the app without XCode, the token is back, 10/10 times. I'm not sure if this is a problem with SSKeychain or with Keychain in general. The code I'm using to store and read values is the following:

- (void)setSecureValue:(NSString *)value forKey:(NSString *)key
{
    [SSKeychain setPassword:value forService:kServiceName account:key];
}

- (NSString *)secureValueForKey:(NSString *)key
{
    if (key != nil)
    {
        return [SSKeychain passwordForService:kServiceName account:key];
    }
    return nil;
}

Many issues revolving Keychain access seem to be resolved by realizing that the keychain is not a data storage and that it can be emptied at times (due to memory warnings, for example). However, since I always run on the same device, and the token is still there after unplugging and running again, I don't see how this could be the issue here.

like image 357
Daniel Larsson Avatar asked Oct 31 '22 08:10

Daniel Larsson


1 Answers

This is a bug of the keychain itself. If you are debugging the app on device, the app security needs to be breached to enable the debugging mode and that's why the keychain doesn't work somehow

like image 184
Pavel Smejkal Avatar answered Nov 15 '22 07:11

Pavel Smejkal