jrendel / SwiftKeychainWrapper

A simple wrapper for the iOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift.
MIT License
1.59k stars 339 forks source link

Incrementing and saving do not work properly #177

Open harmancode opened 2 years ago

harmancode commented 2 years ago

I am testing my app on my phone via Xcode 13.3.1.

I removeAllKeys upon launch, then set a new integer value for a consumable product.

KeychainWrapper.standard.integer(forKey: productIdentifier) ?? 0

  1. This value is zero (0) when I first read it.
  2. I read it, increment it by one and save it. Then read it again. It reads 2 instead of 1.
  3. If I repeat step 2, I still get 2.

Rebooting the phone changed nothing.

Does anybody experience something similar?

harmancode commented 2 years ago

There is no problem when I set the value like so:

KeychainWrapper.standard.set(value, forKey: key, isSynchronizable: true)

And remove the key-value like so:

KeychainWrapper.standard.removeObject(forKey: key, isSynchronizable: true)