matthewpalmer / Locksmith

A powerful, protocol-oriented library for working with the keychain in Swift.
MIT License
2.92k stars 268 forks source link

loadDataForUserAccount returning nil when restarted #97

Open RyanKim01 opened 8 years ago

RyanKim01 commented 8 years ago

Hi, I am saving a key-value pair in a closure using Locksmith. Code is like below:

screen shot 2015-12-27 at 12 47 35 am

I see that only one key-value pair is being saved. Let's say I save ["last_name": "McDonalds"] first and save ["first_name" : "Ryan"] next. Then, I expect to see two different key-value pairs in Locksmith.loadDataForUserAccount("Account"). But I only see the second pair ("first_name"). And when the app is restarted, it is always empty. Is this a bug or am I doing something wrong? I see a similar closed issue( #74 ) but it seems like it has been resolved for a user who opened that issue.

@matthewpalmer, it would be great if you can take a quick look! Thnx.

matthewpalmer commented 8 years ago

Only one piece of data is stored under an account, so when you call updateData it will overwrite whatever's currently stored for that account. Re the second issue, if you can provide a reliable way to reproduce the issue then I will take a look :) Thanks very much Matt

jbejar commented 8 years ago

I also get Locksmith.loadDataForUserAccount() to return nil. I think it happens when there are many processes in the background even without restarting it.

alexanderedge commented 8 years ago

Likewise here – occurring without restarting. I haven't investigated in detail, yet.

alexanderedge commented 8 years ago

Potentially linked: https://forums.developer.apple.com/thread/4743#14441

jyoung84 commented 8 years ago

I was also seeing this on 2.0.6. I just upgraded to 2.0.8 and it seems to be fixed, but I'm still testing. Thanks for the link @alexanderedge , I'll look it over

thecritic commented 8 years ago

same here (2.0.8)

lucasleongit commented 8 years ago

I agree with @alexanderedge, it might be from Apple. We can consider a work around - combining with NSUserDefault and KeyChain and request info to Keychain if NSUserDefault doesn't have the info. we can vastly decrease the hit rate of this bug. We might need to encrypt content saved into NSUserDefault.

PawelLukasiak commented 7 years ago

Locksmith.loadDataForUserAccount() in iOS 10 returns nil, but in iOS 9.3 return my credentials... Someone knows what happens?

RohitKanade commented 7 years ago

Locksmith.loadDataForUserAccount() in iOS 10 returns nil @PawelLukasiak same here. do you get the solution ?

PawelLukasiak commented 7 years ago

Hello ! I have solution how to fix that problem in iOS 10. Chose your target i project, then select Capabilities -> Keychain Sharing to ON. xCode will create for you entitlements file. This is all ! Sorry about my english ! Greetings matthewpalmer

2016-10-22 16:57 GMT+02:00 Rohit Kanade notifications@github.com:

Locksmith.loadDataForUserAccount() in iOS 10 returns nil @PawelLukasiak https://github.com/PawelLukasiak same here. do you get the solution ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/matthewpalmer/Locksmith/issues/97#issuecomment-255533156, or mute the thread https://github.com/notifications/unsubscribe-auth/AKZy6J0LVV7sntJzH_dbeaAWg9Tu4_Xnks5q2iRwgaJpZM4G7je8 .

ghowen commented 7 years ago

@PawelLukasiak Thank you, this did it for me!

comatose-turtle commented 7 years ago

Any ideas on how to accomplish this for a local framework? The unit tests fail on iOS 10 because the loaded data is always nil, but there is no setting for "Capabilities" on a framework, and probably no concept even of an entitlements file.