Values not always persisted in App group between companion app & app extension

Originator:nickbarfoot
Number:rdar://17969471 Date Originated:Aug 9, 2014
Status:Open Resolved:NO
Product:iOS Product Version:8
Classification:Critical Reproducible:No
 
Summary:
From time to time, but not always (I have had this working for a bit), the app/extension gets in a state where I can't read a flag set in my App Group between my companion app and my app extension. Don't know how it gets in this state or why the values differ, but it's ***critical*** to my application these always be in sync.

**Companion app viewDidLoad**:


    NSUserDefaults *myAppSettings = [[NSUserDefaults alloc] initWithSuiteName:@"group.myapp"];

    .....

    [myAppSettings setBool:true forKey:@"myBool"];
        
    [myAppSettings synchronize];
    
    NSLog([myAppSettings boolForKey:@"myBool"] ? @"Companion app - bool TRUE" : @"Companion app - bool FALSE");


**App extension viewDidLoad**

    NSUserDefaults *myAppSettings = [[NSUserDefaults alloc] initWithSuiteName:@"group.myapp"];
        
    [myAppSettings synchronize];
    
    NSLog([myAppSettings boolForKey:@"myBool"] ? @"App extension app - bool TRUE" : @"App extension - bool FALSE");

**Console output**

    Companion app - bool TRUE
    App extension - bool FALSE

I also synchronize before my companion app will enter background. I have my app group set up in the portal etc.

**EDIT**

Apparently others having this problem too:
https://devforums.apple.com/message/977151#977151

> "I think that this is currently very glitchy.
 
> Sometimes the data sharing works, then a change and all of a sudden the widget can't see the shared data anymore (both on Simulator and device).
 
> Annoying and hope it's a bit more reliable in next beta!"

Steps to Reproduce:
Use NSUserdefaults with group suite to set a bool, read the bool from an app extension

Expected Results:
Bool value should always be set/read accurately, and it's sometimes inconsistent

Actual Results:
Sometimes inconsistent data, e.g. companion app shows it in one state, app extension shows it in another

Version:
iOS 8 Beta 5

Notes:


Configuration:
iPhone 5, iPhone 5S, iPhone 4S

Attachments:


It occurred to me that this could be because the keyboard is losing it's RequestOpenAccess privileges, either because it crashed, or just over time.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!