In one of my iOS apps I'm developing I'm storing some info in the Keychain. To interact with the keychain I am using Locksmith (https://github.com/matthewpalmer/Locksmith)
In version v1 of my app, I was writing some data in the keychain by using
Locksmith.saveData(data: data, forUserAccount:"A1", inService: "S1")
Now, in v2, I realized that I would like to migrate my data from "S1" to "S2", so I've set on to writing a small migration script to achieve this.
Essentially, what I am doing:
// read the old data
if let d = Locksmith.loadDataForUserAccount(userAccount: "A1", inService: "S1") {
// write it in a new location
Locksmith.saveData(data: d, forUserAccount: "A1", inService: "S2")
}
This is an oversimplification of my code.
The problem is that d = nil
every time, although I know for sure it exists (when I am building the v1 of the app, I can see the data exists in that location).
Any ideas on this? Did somebody run into this problem before?
Some tech specs:
- Xcode 8.3
- Swift 3.1
- Locksmith 3.0 (via Carthage)
- iOS Simulator (iPhone 6s) running iOS 10.3
Didn't try on a real device.