3 Replies
      Latest reply on Sep 7, 2019 9:08 PM by suMac
      SwampDog Level 1 Level 1 (0 points)

        Folks;

         

        When I run an archived copy of my mac application on a test dev machine (not my main dev box) I see errors in the Console log that trouble me...

         

        1) I see this error immediately before any of my code executes!

        error 16:14:25.839821 -0700 [MYAPPNAME] Couldn't read values in CFPrefsPlistSource<0x6000000ed280> (Domain: [MYAPPBUNDLEID], User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: Yes): accessing preferences outside an application's container requires user-preference-read or file-read-data sandbox access, detaching from cfprefsd

         

        I open my standard defaults (a .plist) in -awakeFromNib like so:

            NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];

            [ud registerDefaults:[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"WhodoMacOSDefaults" ofType:@"plist"]]];

            [ud setObject:launch_Date forKey:kKudosLaunchDate];

         

        This activity throws 2 of these errors in the console:

        error 16:14:26.429881 -0700 [MYAPPNAME] attempt to set <private> for key in <private> in non-persistent preferences domain CFPrefsPlistSource<0x6000000ed280> (Domain: [MYAPPBUNDLEID], User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: Yes)

         

        Then subsequently every 'set' for NSUserDefaults throw another of these into the console log...

         

        Nothing fancy going on in this app: no app groups, no iCloud, no hardened runtime...

         

        I don't see a 'user-preference-read' option in the standard entitlement document.

         

        Am I missing some basic conguration setting?

        Is this all just a by-product of running a 'development' archive?

         

        Any thoughts appreciated!

        Steve

        • Re: macOS & NSUserDefaults
          john daniel Level 3 Level 3 (400 points)

          Have you done any hacking around on preferences? Is the a sandbox build?

           

          In either case, you should always do:

          killall prefsd

           

          if the preferences system seems flaky or if you have hacked around on things. See if that clears it up. Restarting would effectively do the same thing too.

            • Re: macOS & NSUserDefaults
              SwampDog Level 1 Level 1 (0 points)

              John;

               

              Well Thank-You!

               

              I quite the app and then used ActivityMonitor and 'ForceQuit' the 'root' instance and the instance running on the user account.

               

              Re-ran the app and no more of the errors described above.  Cool

                • Re: macOS & NSUserDefaults
                  suMac Level 1 Level 1 (0 points)

                  Have you found our what was the cause of the problem?

                  It happens to me now, all the time, when I run (debug) from Xcode, my App which is like yours - a simplistic Cocoa app (Document based) with no "extensions" or "groups" or whatever.

                   

                  It is, though, a sandboxed app (I set up the checkboxes to the best of my understanding, and archive it without diffuculty) but now I get these errors:

                  2019-09-07 19:49:09.598967+0300 PlanktoMetrix-II[84292:22916507] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x6000000eab80> (Domain: com.apple.PowerManagement, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): accessing preferences outside an application's container requires user-preference-read or file-read-data sandbox access, detaching from cfprefsd

                   

                  and I'm wondering what I have done to cause this. My app Does register a set of defaults from a plist resource I have in the app once, upon launch - but that's all. And as much as I can see - nothing related to PowerManagement.