app groups not functioning with Swift 2

Hi, I have an app group that worked fine between my watch and iPhone using Swift 1. Now, however, nothing is saving to my app group when I use the same code to save and synch the data (and thus nothing appears on my watch).


I believe the relevant code is here:

//in the AppDelegate
    var sharedData = NSUserDefaults(suiteName: "group.RxRemindMe")


//in my VC
        NSKeyedArchiver.setClassName("RxRemindMe.Medication", forClass: Medication.self)
        NSKeyedUnarchiver.setClass(Medication.self, forClassName: "RxRemindMe.Medication")
        appDelegate.sharedData!.setObject(savedAsData, forKey: "TheMedicationsShared")
        appDelegate.sharedData!.synchronize()


if I run the same .setObject command on a non-shared userDefault object, I see bytes saved (size changes to some positive bytes) and my phone app can access the data. However, when I execute line 4 above via the shared group object, the object remains nil in size and nothing has changed. I thus can't recall the data either on the phone or on the watch.


Is this a bug in Swift 2? Is there something else I need to be doing to make this work now?

Hi,


I guess it's not a metter of swift 1 oder swift 2 but because starting with WatchOS 2 the App Extension does not run on the phone any longer.

So while your AppDelegate uses an app group on the phone, the extension does the same but on the watch.


Dirk

Wait, so they can't share data anymore? I thought that was the point of app groups! And just to check I saved and then opened my shared app group on my phone app (not involving the watch at all)--still doesn't work. The issue is that when I use the .setObject command, nothing happens. It used to save my data into that object so I could retrieve it, but now nothing at all happens. Very frustrating since it took a working app and wrecked it (not the first or last time transferring to watchOS 2 and Swift too!).

Are you suggesting I have to use WCSession instead to pass data? Because.... wow, that'll be a pain in the butt since WCSession only supports primitives.

app groups not functioning with Swift 2
 
 
Q