I have a widget extension that needs to use some UserDefaults written from my host app. I didn't want to use UserDefaults(suiteName:) since it's an optional, so I used the following property from [this article]:(https://www.swiftbysundell.com/articles/the-power-of-userdefaults-in-swift/)
extension UserDefaults {
static var shared: UserDefaults {
let combined = UserDefaults.standard
combined.addSuite(named: appGroupName)
return combined
}
}
But when I call it in the extension, the values are not present. Is this expected behavior?
For the record, I am 100% sure I have the right app groups. I also made a new project only to test this and it's behaving identically.
And I'm not calling .synchronize()
for UserDefaults anywhere, but I don't think that's needed.