3

Did anyone face an issue with Shared User Defaults via App Groups on iOS 11? I am saving a value in one of the extensions but I am not able to fetch same value via another extension.

In the first extension :

let defaults = UserDefaults.init(suiteName: Constants.commonSuite)
defaults.set("Sample", forKey: "SampleKey")
defaults.synchronize()

In the second extension :

let defaults = UserDefaults.init(suiteName: Constants.commonSuite)
let sampleString = defaults.object(forKey: "SampleKey")
print(sampleString)

Interestingly this thing works fine on iOS 10. Breaks on iOS 11

deej
  • 1,703
  • 1
  • 24
  • 26
mayuur
  • 4,736
  • 4
  • 30
  • 65
  • Hey @mayuur, I'm facing the exact same issue and haven't been able to find a solution for this. I've enabled App groups in my action extension as well as my host app. I'm still getting a standard error in console and i'm unable to access the values. Even trying to access the keys return a nil. – Karthik Kannan Feb 15 '18 at 11:19
  • I don't know if you got a solution, but this answer and its comments seem to have had success by making a new shared container. Admittedly it relates to pre-iOS11 but might be worth a try? – Chris Jul 03 '18 at 11:42

1 Answers1

0

Had the same issue.

Suitename needs to be the same value as your app group name, not some arbitrary value.

Hope that helps!

Mars
  • 2,505
  • 17
  • 26