Coder Social home page Coder Social logo

jrendel / swiftkeychainwrapper Goto Github PK

View Code? Open in Web Editor NEW
1.6K 43.0 339.0 358 KB

A simple wrapper for the iOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift.

License: MIT License

Swift 95.87% Ruby 1.27% Objective-C 2.86%

swiftkeychainwrapper's Introduction

โ›” [DEPRECATED] This library is not being kept up to date. This was created when Swift was first released as a simple way to work with the Keychain. But the approach was restricted and not suited to more advanced keychain usage.

SwiftKeychainWrapper

A simple wrapper for the iOS / tvOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift.

Provides singleton instance that is setup to work for most needs. Use KeychainWrapper.standard to access the singleton instance.

If you need to customize the keychain access to use a custom identifier or access group, you can create your own instance instead of using the singleton instance.

By default, the Keychain Wrapper saves data as a Generic Password type in the iOS Keychain. It saves items such that they can only be accessed when the app is unlocked and open. If you are not familiar with the iOS Keychain usage, this provides a safe default for using the keychain.

Users that want to deviate from this default implementation, now can do so in version 2.0 and up. Each request to save/read a key value now allows you to specify the keychain accessibility for that key.

General Usage

Add a string value to keychain:

let saveSuccessful: Bool = KeychainWrapper.standard.set("Some String", forKey: "myKey")

Retrieve a string value from keychain:

let retrievedString: String? = KeychainWrapper.standard.string(forKey: "myKey")

Remove a string value from keychain:

let removeSuccessful: Bool = KeychainWrapper.standard.removeObject(forKey: "myKey")

Custom Instance

When the Keychain Wrapper is used, all keys are linked to a common identifier for your app, called the service name. By default this uses your main bundle identifier. However, you may also change it, or store multiple items to the keychain under different identifiers.

To share keychain items between your applications, you may specify an access group and use that same access group in each application.

To set a custom service name identifier or access group, you may now create your own instance of the keychain wrapper as follows:

let uniqueServiceName = "customServiceName"
let uniqueAccessGroup = "sharedAccessGroupName"
let customKeychainWrapperInstance = KeychainWrapper(serviceName: uniqueServiceName, accessGroup: uniqueAccessGroup)

The custom instance can then be used in place of the shared instance or static accessors:

let saveSuccessful: Bool = customKeychainWrapperInstance.set("Some String", forKey: "myKey")

let retrievedString: String? = customKeychainWrapperInstance.string(forKey: "myKey")

let removeSuccessful: Bool = customKeychainWrapperInstance.removeObject(forKey: "myKey")

Subscript usage

Keychain can also be accessed with subscript as it is in dictionary. Keys can be predefined and listed in one place for convenience.

Firstly, let's define the key to use later.

extension KeychainWrapper.Key {
    static let myKey: KeychainWrapper.Key = "myKey"
}

And now we can use this key as follows:

KeychainWrapper.standard[.myKey] = "some string"

let myValue: String? = KeychainWrapper.standard[.myKey]

KeychainWrapper.standard.remove(forKey: .myKey)

Accessibility Options

By default, all items saved to keychain can only be accessed when the device is unlocked. To change this accessibility, an optional withAccessibility param can be set on all requests. The enum KeychainItemAccessibilty provides an easy way to select the accessibility level desired:

KeychainWrapper.standard.set("Some String", forKey: "myKey", withAccessibility: .AfterFirstUnlock)

Synchronizable Option

By default, all items saved to keychain are not synchronizable, so they are not synced with the iCloud. To change this, an isSynchronizable bool param can be set on all requests. You need the item to be synchronized with the iCloud if you want to have it on all of your devices:

KeychainWrapper.standard.set("Some String", forKey: "myKey", isSynchronizable: true)

Important: You can't modify value for key if it was previously set with different accessibility option. Remove the value for key and set it with new accessibility option. (Otherwise the value will not change).
For example:

KeychainWrapper.standard.set("String one", forKey: "myKey", withAccessibility: .AfterFirstUnlock)
KeychainWrapper.standard.removeObject(forKey: "myKey")
KeychainWrapper.standard.set("String two", forKey: "myKey", withAccessibility: .Always)

Installation

CocoaPods

You can use CocoaPods to install SwiftKeychainWrapper by adding it to your Podfile:

use_frameworks!
platform :ios, '8.0'

target 'target_name' do
   pod 'SwiftKeychainWrapper'
end

To use the keychain wrapper in your app, import SwiftKeychainWrapper into the file(s) where you want to use it.

import SwiftKeychainWrapper

Carthage

You can use Carthage to install SwiftKeychainWrapper by adding it to your Cartfile.

Swift 3.0:

github "jrendel/SwiftKeychainWrapper" ~> 3.0

Swift 2.3:

github "jrendel/SwiftKeychainWrapper" == 2.1.1

Swift Package Manager

You can use Swift Package Manager to install SwiftKeychainWrapper using Xcode:

  1. Open your project in Xcode

  2. Click "File" -> "Swift Packages" -> "Add Package Dependency..."

  3. Paste the following URL: https://github.com/jrendel/SwiftKeychainWrapper

  4. Click "Next" -> "Next" -> "Finish"

Manually

Download and drop KeychainWrapper.swift and KeychainItemAcessibility.swift into your project.

Release History

  • 4.1 Added conditional logic for CGFloat accessories for when package is used where CGFloat is not available

  • 4.0 Updated with SPM support and other community PRs. Minimum iOS version is now 9.0.

  • 3.4

  • Changed how Swift version is defined for CocoaPods

  • 3.3

  • Updates for Swift 5.0 and Xcode 10.2

  • 3.2

  • Updates for Swift 4.2 and Xcode 10

  • 3.1

    • Updates for Swift 3.1
  • 3.0.1

    • Added a host app for the unit tests to get around the issue with keychain access not working the same on iOS 10 simulators
    • Minor update to readme instructions
  • 3.0

    • Swift 3.0 update. Contains breaking API changes. 2.2.0 and 2.2.1 are now rolled into 3.0
  • 2.2.1 (Removed from Cocoapods)

    • Syntax updates to be more Swift 3 like
  • 2.2 (Removed from Cocoapods)

    • Updated to support Swift 3.0
    • Remove deprecated functions (static access)
  • 2.1

    • Updated to support Swift 2.3
  • 2.0

    • Further changes to more closely align the API with how NSUserDefaults works. Access to the default implementation is now done through a singleton instance. Static accessors have been included that wrap this shared instance to maintain backwards compatibility. These will be removed in the next update
    • Ability to change keychain service name identifier and access group on the shared instance has been deprecated. Users now have the ability to create their own instance of the keychain if they want to customize these.
    • Addtional options have been provided to alter the keychain accessibility for each key value saved.
  • 1.0.11

    • Update for Swift 2.0
  • 1.0.10

    • Update License info. Merged Pull Request with Carthage support.
  • 1.0.8

    • Update for Swift 1.2
  • 1.0.7

    • Determined that once provisioned correctly for access groups, using KeychainWrapper on the simulator with access groups works. So I removed the simulator related check and unit tests previously added.
  • 1.0.6

    • Support for Access Groups

    • SwiftKeychainWrapperExample has been updated to show usage with an Access Group: https://github.com/jrendel/SwiftKeychainWrapperExample

    • Access Groups do not work on the simulator. Apps that are built for the simulator aren't signed, so there's no keychain access group for the simulator to check. This means that all apps can see all keychain items when run on the simulator. Attempting to set an access group will result in a failure when attempting to Add or Update keychain items. Because of this, the Keychain Wrapper detects if it is being using on a simulator and will not set an access group property if one is set. This allows the Keychain Wrapper to still be used on the simulator for development of your app. To properly test Keychain Access Groups, you will need to test on a device.

  • 1.0.5

    • This version converts the project to a proper Swift Framework and adds a podspec file to be compatible with the latest CocoaPods pre-release, which now supports Swift.

    • To see an example of usage with CocoaPods, I've created the repo SwiftKeychainWrapperExample: https://github.com/jrendel/SwiftKeychainWrapperExample

  • 1.0.2

    • Updated for Xcode 6.1

I've been using an Objective-C based wrapper in my own projects for the past couple years. The original library I wrote for myself was based on the following tutorial:

http://www.raywenderlich.com/6475/basic-security-in-ios-5-tutorial-part-1

This is a rewrite of that code in Swift.

Carthage compatible

swiftkeychainwrapper's People

Contributors

adamskyle-ios avatar andreasboehm avatar coledunsby avatar dekwin avatar g00m avatar jamesmblair avatar jesster2k10 avatar johennes avatar jrendel avatar jrendel-dil avatar krummler avatar lexrus avatar markonikolovski avatar maryom avatar mattmaddux avatar mirek-inzura avatar nikolaygenov avatar petermichaux avatar readmecritic avatar rlester avatar rnewman avatar sbertix avatar tebs1200 avatar tiwoc avatar vatoko avatar watsonbox avatar zandor300 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftkeychainwrapper's Issues

Please upgrade to Swift 3

Please upgrade this project to swift 3 ASAP, it only will take a few minutes. Currently this breaks CocoaPod integration with Swift 3 and xCode 8.

Fails to retrieve stored values with odd error

I'm seeing an odd, intermittent error every once in a while. I'll try to retrieve a value as the app is launching (in application(_:... didFinishLaunchingWithOptions)) and just as it fails to retrieve the value I'll consistently get an error printed out to the console that I don't see otherwise making me believe the two are related. Here is the error:

2016-11-25 12:07:01.600167 (MY_APP_IDENTIFIER)[7172:1224012] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2016-11-25 12:07:01.609110 (MY_APP_IDENTIFIER)[7172:1224012] [MC] Reading from public effective user settings.

And sometimes (I can't seem to find a pattern) this one is printed as well:

2016-11-25 12:40:37.032139 (MY_APP_IDENTIFIER)[7195:1232649] [MC] Invalidating cache

I've been looking into this and people are attributing this message to either user permissions settings or app groups (neither of which I am using.) Have you seen this happening at all? Ideas? Like I said, it's intermittent and extremely difficult to try to debug and is causing my users quite a bit of a headache as it automatically logs them out of my app.

Support SecClass values other than kSecClassGenericPassword

Flexibility could be provided by supporting the other possible values (internet password, certificate, key, identity). An enum could be used to wrap the CFString constant values and the KeychainWrapper public methods could either be overloaded or take an optional parameter.

To take this even further, an "options" type could be used as a parameter to wrap the SecClass and any other useful options, such as whether the device must be unlocked for access and whether TouchID is needed to retrieve the item.

I've begun implementation of these features in my own fork and can provide samples (or a pull request) if you're open to these ideas.

Support MacOS

Is there a reason to restrict this to iOS? Can't it pretty easily support macOS as well?

removeObjectForKey and removeAllKeys always returns false

When I open the app, In App Delegate I can see that there is a value in Keychain and KeychainWrapper is successfully fetching it.

But when I try to remove it [ Using that specific key ] it always return false. So I tried removeAllKeys method that also returns nil. I have tried re-booting my system, tried in different computers. Don't know what's happening in here.

It's a Cocoa App. Deployment Target : 10.10

 if let _ = KeychainWrapper.defaultKeychainWrapper().stringForKey(UserDefaults.TokenSet_Secret.rawValue)
        {
            // Always here - Value is there
        }
        else
        {
            // 
        }


let success = KeychainWrapper.defaultKeychainWrapper().removeObjectForKey(UserDefaults.TokenSet_Secret.rawValue)

        if success {

            // Dismiss

            self.delegate?.clickedOnDismiss()
            dismissController(self)
        }
        else {

           //  Always comes here :(

            // Show Alert

            self.presentAlertController(UserConstants.alertTitle_Oops, message: UserConstants.WritingTweets.CoultNotGetToken.rawValue)
        }

Please guide me, and let me know if I miss anything.

Odd bug

Haven't fully investigated but there is a rather odd bug with this Wrapper. Some phones will save to keychain using SwiftKeychainWrapper, others will not. There is no correlation between phones or versions, some iPhones 5s's the wrapper works, other it does not. This applies to all devices - 6, 6 plus, 4s.

To further describe - Saving to keychain in our test group worked for an iPhone 5s on 8.1.3 - on another 5s on 8.1.3 it did not. One iPhone 6 it did not work for (also on 8.1.3), on an iPhone 5 on 8.1.2 it did work.

Bug is also not related to settings or anything related to settings within said app, it is isolated to SwiftKeychainWrapper.

add a removeAllKeys or similar

First, congrats for the wrapper. Simple and efficient.

I just missed out one function: a removeAllKeys() function that would erase all Keychain items. That is very useful to clean the Keychain on the app first run.

Cannot seem to save two keys

If I do the following code:

        KeychainWrapper.serviceName = "com.yaddayadda.whatever"

        if KeychainWrapper.setString(tokenField.stringValue, forKey: "apiKey") {
            println("Saved \(tokenField.stringValue) to apiKey")
        } else {
            println("Failed to save apiKey: \(tokenField.stringValue)")
        }

        if KeychainWrapper.setString(urlField.stringValue, forKey: "apiURL") {
            println("Saved \(urlField.stringValue) to apiURL")
        } else {
            println("Failed to save apiURL: \(urlField.stringValue)")
        }

The apiURL will always fail no matter what. Is it just that this lib only allows saving of a single item?

KeychainWrapper with Swift Compiler optimizations "Fastest"

When packaging up a release IPA (IE: for testflight) KeychainWrapper.stringForKey() returns a nil value. It passes without error, but the value is blank.

For instance:

KeychainWrapper.setString("APPLE", forKey: "FRUIT")
var fruit = KeychainWrapper.stringForKey("FRUIT")
var alert:UIAlertView = UIAlertView(title: "FRUIT", message: "\(fruit)", delegate: self, cancelButtonTitle: "Ok")
alert.show()

Took a lot of searching, but I stumbled across: http://stackoverflow.com/questions/26355630/swift-keychain-and-provisioning-profiles

Disabling the optimizations for the release target remedied the problem, but I am wondering if there is something that can be done to fix whatever is breaking when optimized away. (Might just have to wait for an apple fix?)

Problem with Swift 3

        KeychainWrapper.defaultKeychainWrapper.set("ads", forKey: "boh")
        print(KeychainWrapper.defaultKeychainWrapper.string(forKey: "boh"))

That code actually prints nil.

Keychain access group

Can you add support for saving to a specific keychain access group? This way we can share the keychain between multiple apps and/or extensions.

Copyright statement

MIT copyright
My understanding is that the MIT copyright statement included in the project needs to be included in the code to be in effect, as it stands the code is copyrighted by yourself with no mention of the MIT copyright.

Carthage support

This project support cocoapod and it's good.
And then why not adding carthage support?

34 Failing Tests?

I'm running Xcode 8.0 (8A218a)

I downloaded the devel branch and opened up the xcodeproj file

Everything builds fine, but when I run the tests I get 34 failures. Basically, it looks like nothing is getting set.

  • Is this a known issue?
  • Do I need to make and configuration changes to make the tests work?

Thanks!

Under swift, do I need to import the security framework manually to use the keychain?

Hello there,
following some tutorial videos I copied the KeychainWrapper.swift file to my project and started using the provided functions to store some strings. Everything works fine but now I wonder about the need for the security framework which I didn't import manually. Is this something I still need to do in swift? I can Cmd+click those kSec keys in the wrapper and it sends me to the security framework - does this mean it's "built in" into swift now or something like that?

If I do need that framework why does it work right now "without" it? Are my strings saved but not encrypted or something like that?

Btw: I asked that on SO as well but the answers weren't completely satisfying thats why I ask here now.

Thanks a lot in advance

Missing description under title

screen shot 2016-08-03 at 5 55 05 pm

Should be something like:

A simple static wrapper for the iOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift.

2.0 not available on CocoaPods

When I try 'pod install'

[!] Unable to satisfy the following requirements:

  • SwiftKeychainWrapper (~> 2.0) required by Podfile

None of your spec sources contain a spec satisfying the dependency: SwiftKeychainWrapper (~> 2.0).

I of course tried 'pod repo update'.

Syntax changes for next update.

Thanks for the quick swift 3 update. Could you please do the following syntax changes for the next update to make it even more swift 3 like and closer to NSUserDefaults.

Change the singleton access to either default, standard or shared. So instead of

KeychainWrapper.defaultKeychainWrapper.set(...)

it reads

KeychainWrapper.default.set(...)
or
KeychainWrapper.standard.set(...)
or
KeychainWrapper.shared.set(...)

Change the remove method from

...remove(key: ....)

to

...removeObject(forKey: ...)

xCode8 with Swift2.3 returns false

Hi @jrendel ,
I have a problem with saving values to Keychain, below is the line I'm using, and it always returns false in xCode8 and Swift2.3 (I can't use Swift 3 at the moment because some other frameworks are not updated)
Just to mention, it all worked with xCode7 and Swift2.2 on iOS9.3 simulator, but now I'm using iOS10 simulator, maybe this could be the issue? (downloading 9.3 simulators at the moment)

let isSaveSuccessfulToken: Bool = KeychainWrapper.defaultKeychainWrapper().setString(token, forKey: "token")

I'm using Carthage and I tried with the following
github "jrendel/SwiftKeychainWrapper"
github "jrendel/SwiftKeychainWrapper" "master"
github "jrendel/SwiftKeychainWrapper" == 2.1.0
github "jrendel/SwiftKeychainWrapper" "Swift2.3"

all compiled to Swift2.3 using
carthage update --platform iOS --toolchain com.apple.dt.toolchain.Swift_2_3 SwiftKeychainWrapper which builds successfully (also used with some other frameworks that work now)

Tnx

Cocoao Pods support for tvOS

Please can you integrate this project in cocoa pods for tvOS. This helper works flawlessly on tvOS but without the cocoaPod integration its a bit of a hassle when having a universal iOS and tvOS project.

Swift 3 Clearance

It seems it has converted properly on XCode 8 for Swift 3.
However there are some warnings as XCode issues them for unused results from function calls now.
e.g. "Result of call to 'deleteKeychainSecClass' is unused"

Cheers

object(forKey:..) does not work anymore or has a new behaviour in swift 3.

Hey,

So I have done some more testing with your updated version and its not saving data anymore.

It returns a successful bool on the set method but on next launch all data is gone again. So ...object(forKey: ...) doesnt work anymore.

Have you made any changes because when I upgraded the project to swift 3 myself I did not have that problem.

Whats going on?

How to set Date() in Keychain (Swift 3)

Is it possible to set object in Keychain with Swift 3, this is how I used it before:

KeychainWrapper.defaultKeychainWrapper().setObject(expiresIn, forKey: "expiresInDate")
is there something like:
KeychainWrapper.standard.set(expiresIn, forKey: "expiresInDate")

Calling stringForKey sometimes returns nil for keys that previously worked

I'm getting some strange behavior when accessing data. I have a static method that I use to retrieve a stored auth token for an API call. This static method is called a couple times and returns the data I expect. From one of my view controllers though it's returning nil.

I make the exact same call for the exact same keys. Two calls return data and the last one does not. I'm getting a return status of -34018. I'm not sure what that error code is.

watchOS 2 support

When trying to add SwiftKeychainWrapper to a WatchKit Extension target using Cocoapods an error occurs stating the following:

[!] The platform of the target cosy WatchKit Extension (watchOS 2.0) is not compatible with SwiftKeychainWrapper (1.0.11), which does not support watchos.

Definition used in the Podfile

target 'cosy WatchKit Extension' do
  platform :watchos, '2.0'
  pod 'SwiftKeychainWrapper'
end

Installation section

Hey, your library is really interesting.

The only problem I found was the README.md, which lacks an Installation Section
I created this iOS Open source Readme Template so you can take a look on how to easily create an Installation Section
If you want, I can help you to organize the lib.

What are your thoughts? ๐Ÿ˜„

KeychainWrapper.swift crashes

On this line:
keychainQueryDictionary[SecAttrAccessible] = accessibility.keychainAttrValue

screen shot 2016-09-23 at 11 05 27

This happens very rarely, but do you have any ideas why it could happen?

Saving JSON object in KeyChain

I want to save a JSON object in Keychain with DataType JSON without changing it to string.
Please help how to save a json object in keychain using this library?

Integrate SwiftyKeychainWrapper with KeychainItemWrapper

In this app I'm working on we are using Apple's KeychainItemWrapper to interact with the keychain, but we would like to move from that implementation to SwiftKeychainWrapper. Is it possible to access the existing keychain data with SwiftKeychainWrapper?

Shared keychain doesn't work in 1.0.11

Also, it's very inconvenient that accessGroup is a class property - what if you need to access several keychains (for several access groups)?

When used:

KeychainWrapper.accessGroup = "..."
let c1 = KeychainWrapper.dataForKey("CustomerToken")

nil is stored in c1

But when I use

    func getFromKeychain(itemKey: String) -> NSData? {
        let keychainAccessGroupName = "..."

        let queryLoad: [String: AnyObject] = [
            kSecClass as String: kSecClassGenericPassword,
            kSecAttrAccount as String: itemKey,
            kSecReturnData as String: kCFBooleanTrue,
            kSecMatchLimit as String: kSecMatchLimitOne,
            kSecAttrAccessGroup as String: keychainAccessGroupName
        ]

        var result: AnyObject?

        let resultCodeLoad = withUnsafeMutablePointer(&result) {
            SecItemCopyMatching(queryLoad, UnsafeMutablePointer($0))
        }

        if resultCodeLoad == noErr {
            if let result = result as? NSData {                
                return result
            }
        } else {
            print("Error loading from Keychain: \(resultCodeLoad)")
        }

        return nil
    }

Correct data is returned from method.

Framework name

My understanding is convention dictates this should be in the form XXXKeyChainWrapper where XXX is a unique prefix associated with the developer. While the name as it stands is descriptive it is not conventional. Really nice piece of code and would like to be able to use it but site naming conventions preclude this, any chance you will consider renaming it?

Possible issue with incorrect errno usage

As you know errno provides error code of the latest system code failed. So in the following method:
public class func dataForKey(keyName: String) -> NSData? { ...
probably this was meant here:
return status == errSecSuccess ? result as? NSData : nil
instead of this:
return status == noErr ? result as? NSData : nil

Set-function returning false?

Hi there,

My code has been working fine until now, suddenly these lines returns false:

let ops: Bool = KeychainWrapper.defaultKeychainWrapper.set(ops, forKey: "ops")
let jop: Bool = KeychainWrapper.defaultKeychainWrapper.set(jop, forKey: "jop")

I use cocoapods, and this in the Podfile:

pod 'SwiftKeychainWrapper', :git => 'https://github.com/jrendel/SwiftKeychainWrapper.git', :branch => 'master'

Any ideas?

KeychainWrapper.standard.set always returning false

I have installed branch Swift2.3 via cocoa pods.

I am calling the following code:
let saveSuccessful: Bool = KeychainWrapper.standard.set("username123", forKey: "username")
But saveSuccesful is always returning false. I have tried with different strings. I have also tried calling:
let retrievedString: String? = KeychainWrapper.standard.string(forKey: "username")
To double check it's not just the wrong value being returned but retrievedString is always nil.

Am I doing something wrong? Any help would be appreciated.

Use String for SecAttrAccount key, not data

Currently, the KeychainWrapper.swift uses Data type as a "key" to store records. We got our head scratching for quite some time and we could not find any actual benefit of the current code.

// Uniquely identify the account who will be accessing the keychain
let encodedIdentifier: Data? = key.data(using: String.Encoding.utf8)

// ...

keychainQueryDictionary[SecAttrAccount] = encodedIdentifier

link to code

Why don't you simply use String, like Apple does?

You use String everywhere up until that point, then you convert it to Data just before storing the record...

hasValueForKey Return nil in background state

When application in background state, hasValueForKey return nil therefore it is not possible to query for existing value when app is in background state.

Is there any workaround for this or am I doing something wrong?

update docs

the usage in current docs is all depreciated...

what's the correct current usage?

i'm not sure what you mean by "access via keychainWrapper.standardKeychainAccess()"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.