matthewpalmer / Locksmith

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

Crashing on Swift 3 #156

Open johnpaulmanoza opened 7 years ago

johnpaulmanoza commented 7 years ago

Hi Im having a trouble loading the keychain data. App crash when loadDataForUserAccount is called. xcode stops here Locksmith.swift (Line 84). Thank you for any help.

screen shot 2016-10-26 at 2 07 16 pm

Locksmith 3.0.0 Xcode 8.0

ibeleliev commented 7 years ago

This error occurs to me too. It is happening when i use Locksmith.loadDataForUserAccount for account that was previously deleted by using Locksmith.deleteDataForUserAccount. So it tries to read from something that doesn't exist in the keychain and returns error with statusCode -25300 / Locksmith.LocksmithError notFound /.

rlam3 commented 7 years ago

@johnpaulmanoza were you able to resolve this problem? I'm having a similar issue as well...

johnnyoin commented 7 years ago

I have this issue as well but the app doesn't crash. Locksmith complains about a duplicate but still does the job. I'm not saying I don't want it to be fixed though 😄

Micke5 commented 7 years ago

Any progress on this issue? I'm having the same problem :(

rlam3 commented 7 years ago

@johnnyoin Were you able to resolve this issue?

johnnyoin commented 7 years ago

@rlam3 I didn't have to since the app doesn't crash in my case. It stops on the Swift Error breakpoint but still works properly.

iwasrobbed commented 7 years ago

The whole point of throw is for devs to use try and catch those errors so it won't crash. If you're doing try! instead of try then you're causing the crash, not Locksmith.

rlam3 commented 7 years ago

@iwasrobbed are we assuming that the throw is only used for development and not for production?

getaaron commented 7 years ago

@rlam3 no, there may be keychain errors at any time. Your app should handle failure cases gracefully. Using try! is not graceful.

rlam3 commented 7 years ago

@getaaron Could you please kindly provide an example of a more graceful approach? Thanks!

iwasrobbed commented 7 years ago

@rlam3 Look at the do catch section: https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/ErrorHandling.html

getaaron commented 7 years ago

@rlam3 I would be happy to provide a code sample. Can you post a full stack trace and the method you're calling so I can see how you're getting this to occur?