Today widget does not work - sharing data between containing app and extension is not working

We have developed an app extension (of type Today extension) which allows user to perform some basic functionality in the notification screen. And with this we're facing a strange issue. To give a short background, we have two different targets, one for in-house distribution and one for ad-Hoc and for each the bundle id and hence provisioning profiles are different. When we configure the targets (containing app and Today extension) to in-house distribution, everything works like a charm. But when we configure the targets to ad-Hoc version, the extension stops working. I'm unable to figure out how and what to to debug, any help in this respect is highly appreciated.

Details:

In-House-> group id used "group.com.tpvision.pta"

Ad-Hoc-> group id used "group.com.tpvision.philipstvapp"

There are pre-processor flags available to detect whether it is ad-Hoc build or not, and using that flag we handle the group id appropriately in both containing app and extension. My concern is that somehow the extension and containing app are looking at different shared folders only in case of ad-Hoc builds and thats why the today widget is not working as expected. But I'm unable to figure out a reason for this.


XCode version is 6.4, deployment target iOS 7.0.

Code snippets:

Extension is looking for a specific data "SELECTED_DEVICE" inside the shared folder. See below.


-(DBDevice *)getAppDevice{

NSUserDefaults *defaults = nil;

#ifdef APP_STORE_BUILD

defaults = [[NSUserDefaults alloc]

initWithSuiteName:@"group.com.tpvision.philipstvapp"];

NSLog(@"%s:%d<I>-Inside App_Store_Build", __PRETTY_FUNCTION__, __LINE__);

#else

defaults = [[NSUserDefaults alloc]

initWithSuiteName:@"group.com.tpvision.pta"];

NSLog(@"%s:%d<I>-Inside else of App_Store_Build", __PRETTY_FUNCTION__, __LINE__);

#endif

NSData *encodedObject = [defaults objectForKey:@"SELECTED_DEVICE"];

DBDevice *device = nil;

device = [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject];

return device;

}


This data is being provided by the containing app in following fashion:

NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:self.dbDevice];

NSUserDefaults *defaults = nil;

#ifdef APP_STORE_BUILD

defaults = [[NSUserDefaults alloc]

initWithSuiteName:@"group.com.tpvision.philipstvapp"];

#else

defaults = [[NSUserDefaults alloc]

initWithSuiteName:@"group.com.tpvision.pta"];

#endif

[defaults setObject:encodedObject forKey:@"SELECTED_DEVICE"];

[defaults synchronize];

Sorry to ask but are you sure the app group is properly set up and enabled for both groups in the capabilities tabs for each target?

Hi Kane, Yes I am pretty sure. I have taken a screenshot of XCode showing this, but I am new to developer forum and do not know to add it here.

Today widget does not work - sharing data between containing app and extension is not working
 
 
Q