Sharing UserDefault between targets doesn't work. I have set App Group for both targets but the data is not available on watchOS. See my simplified code:
On iOS:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let defaults = UserDefaults(suiteName: "group.my-bundle-id")!
defaults.set(true, forKey: "testKey")
return true
}
On watchOS:
func applicationDidFinishLaunching() {
let defaults = UserDefaults(suiteName: "group.my-bundle-id")!
let uddata = defaults.bool(forKey: "testKey")
print(uddata) // Still returns false
}
This is the app group (which is set for EACH target!):