Shared User Defaults via App Groups in iOS 11 not working

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

Replies

You need to have in both project and extension entitlements file the same App Groups, it can be done in Xcode Project > Capabilities.

Yes I have the same App Groups in both the entitlements. The current thing works fine in iOS 10. It only has issues with iOS 11.

Im seeing the same issue. I filed a bug report.

I am getting same issue in iOS 11.2.5 also, so breaking this functionality in iOS 11 but woring fine in iOS 10.

Does anyone know a solution to this, is this a bug or any wrong thinking on my side?
Thnaks for support.

Yes, I see the same thing. Even with the simplest and clearest test case like yours.