SecureDefaults icon indicating copy to clipboard operation
SecureDefaults copied to clipboard

Crashes when using keychainAccessGroup

Open blursolo opened this issue 9 months ago • 1 comments

First I implemented this library successfully in an app extension but sharing stored values between my app and the extension didn't work. Then I tried setting the .keychainAccessGroup as well:

self.defaultsAppGroupSecure = SecureDefaults(suiteName: "group.com.company.appname.AppGroup")
self.defaultsAppGroupSecure!.keychainAccessGroup = "com.company.appname.KeyChain"
        
if !self.defaultsAppGroupSecure!.isKeyCreated {
     self.defaultsAppGroupSecure!.password = "password"
}
        
self.defaultsAppGroupSecure!.set(true, forKey: "storedValue")

It throws "SecureDefaults.swift:218: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value". It seems like the internal key property isn't set. I had tried to set it manually but it wouldn't work.

What am I doing wrong?

blursolo avatar Apr 14 '25 15:04 blursolo

I forgot to include the TEAM-ID at the beginning of the keychainAccessGroup parameter so it doesn't crash but still can't get to share the same parameters between the app and the extension.

blursolo avatar Apr 14 '25 22:04 blursolo