Doing a real basic test in setting / receiving data using NSUserDefaults. My iPhone app is working and setting the data just fine, but on the watch, it's coming up null.
I have the App Group enabled for both and have verified that they are identical using the same group. The entitlement files for each are bit for bit the same.
In ViewController.m
defaults = [[NSUserDefaults alloc] initWithSuiteName:@"com.defaultmethod.share"];
[defaults setObject:playerName forKey:@"playerName"];
[defaults synchronize];
In InterfaceController.m
- (void)awakeWithContext:(id)context {
[super awakeWithContext:context];
// Configure interface objects here.
defaults = [[NSUserDefaults alloc] initWithSuiteName:@"com.defaultmethod.share"];
[defaults synchronize];
}
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
NSLog(@"playerName: %@", [defaults objectForKey:@"playerName"]);
}
And all I get back is:
playerName: (null)
I've got to be missing something so obvious. When I NSLog it on the iphone side, it comes out just fine, so I know it's saving correctly.
You need to make sure the following setting are in proper place.
You can test these setting under capabilities section of app and watchkit extension target.