1

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.

tufyx
  • 163
  • 1
  • 8
  • Are you sure v2 has access to v1 keychain? Apps are sandboxed... – Jean-Baptiste Yunès Apr 11 '17 at 16:00
  • It's the same app, it has the same app identifier. v2 will be delivered as an update to v1. – tufyx Apr 11 '17 at 21:51
  • 1
    Ok, figured it out! Somehow, in the process of developing v2, I changed the Target > Capabilities > Keychain Sharing > Keychain Group value. Therefore, I was trying to access a wrong keychain group. Everything working as expected now – tufyx Apr 12 '17 at 09:07
  • I really thought that there was such a problem... – Jean-Baptiste Yunès Apr 12 '17 at 09:10
  • Yeah ... when you're wasting 4 hours trying to figure out what the problem might be ... this kind of stupid mistake evades your attention :) Nothing better than a 8 hour sleep to regain focus :)) – tufyx Apr 12 '17 at 09:11

0 Answers0