matthewpalmer / Locksmith

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

Not working using XCode 8 and Swift 2.3 #146

Open tarrgor opened 7 years ago

tarrgor commented 7 years ago

Hello, we are using Locksmith in our App and it is a great tool for handling the keychain. Unfortunately, since the update to XCode 8 and Swift-2.3 it suddenly stopped working. Usually we are storing users login information in the keychain and it should get loaded on App start. Now it suddenly doesn't get loaded anymore.

In our podfile we are using:

pod 'Locksmith', :git => 'https://github.com/matthewpalmer/Locksmith.git', :branch => 'swift-2.3'

Some debugging turned out that the problem could be here:

` private func performSecureStorageAction(closure: PerformRequestClosureType, secureStoragePropertyDictionary: [String: AnyObject]) throws -> [String: AnyObject]? { var result: AnyObject? let request = secureStoragePropertyDictionary let requestReference = request as CFDictionaryRef

    let status = closure(requestReference: requestReference, result: &result)

    let statusCode = Int(status)

    if let error = LocksmithError(fromStatusCode: statusCode) {
        throw error
    }

`

In this code, statusCode gets a value of -25300, which causes an exception to be thrown.

matthewpalmer commented 7 years ago

Just updated the swift-2.3 branch, so try again (weren't any changes that should affect this that much though).

Also maybe https://github.com/matthewpalmer/Locksmith/issues/147 will help?

DBassel commented 7 years ago

solution described in http://stackoverflow.com/questions/38456471/secitemadd-always-returns-error-34018-in-xcode-8-in-ios-10-simulator worked.

zackshapiro commented 7 years ago

Confirmed that @DBassel's link/solution worked for me. Using Xcode 8, Swift 2.3, Mac OS El Cap

tarrgor commented 7 years ago

Yes for me the entitlement solution also worked. XCode 8 is weird ;-)

fnakstad commented 7 years ago

I had the same problem, and the solution by enabling keychain sharing worked for me as well. However, is this really the correct solution to go with here? Keychain sharing is for sharing the keychain between separate apps as far as I know, so this seems like a workaround rather than a permanent solution...

M0rph3v5 commented 7 years ago

+1 for making an actual fix for this. Feels weird to turn on a feature you don't need to work around this.

tarrgor commented 7 years ago

Question is if this is really a bug in Locksmith, or in XCode 8? ;-)

M0rph3v5 commented 7 years ago

Yeah my colleague just explained it and it's basically a xcode bug where the simulator needs some form of entitlement to get code signed and thus access to the keychain...