32

I'm running the just-released macOS 10.12.2, Xcode 8.2, Swift 3.

I have a strange error that comes up in all my sandboxed macOS apps. When I run the apps from Xcode and click on the Apple Menu (top left), the following error logs to the console in Xcode,

2016-12-13 19:30:55.867046 Project-X[3430:411160] [User Defaults] Failed to read values in CFPrefsPlistSource<0x6100000e3f00> (Domain: com.apple.PowerManagement, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null)): accessing preferences outside an application's container requires user-preference-read or file-read-data sandbox access, detaching from cfprefsd

If I create a build, save it to my Mac as a local app and run it from there, I see the same error as above listed in the macOS console, in addition to this error listed as a FAULT under the cfprefsd process:

rejecting read of { com.apple.PowerManagement, kCFPreferencesAnyUser, kCFPreferencesCurrentHost, no container, managed: 0 } from process 3384 because accessing preferences outside an application's container requires user-preference-read or file-read-data sandbox access

..and this under the kernel process:

SandboxViolation: Project-X(3384) deny(1) file-read-data
/Library/Preferences/com.apple.PowerManagement.plist

If I create a build without sandboxing, the error doesn't show up anywhere.

My entitlement settings are just these two:

  • App Sandbox
  • com.apple.security.files.user-selected.read-write

I had the same issue in 10.12.1 and thought it might be resolved in 10.12.2, but it persists. It's strangely specific, because it only presents if I click on the Apple Menu when the app is running.

Thanks very much for any insights!!

Anjali Kevadiya
  • 3,567
  • 4
  • 22
  • 43
Geozeke
  • 431
  • 4
  • 4
  • If a question concerns Cocoa sandbox, you will probably have better luck getting an answer at Apple'd developer forums. – El Tomato Dec 14 '16 at 02:21
  • Great idea! Thanks. I'll post it there too. – Geozeke Dec 14 '16 at 11:17
  • 1
    I met the same problem, have you solved it? – melody5417 Dec 21 '16 at 09:16
  • Not yet, but thanks very much for your reply -- it's nice to know that I'm not the only one. I posted this on the Apple Developer Forums, but my post is still in the "pending" queue waiting for a moderator to approve it. If I find out anything else, I'll update the information here. – Geozeke Dec 21 '16 at 15:12
  • See here: http://stackoverflow.com/questions/38275395/failed-to-read-values-in-cfprefsplistsource-ios-10 but the news isn't good. – MichaelR Jan 05 '17 at 01:45
  • Thanks. I did see that, but thought it might be unique to iOS. Looks like it affects macOS as well. – Geozeke Jan 05 '17 at 09:05
  • 5
    I have seen this a few times now.. A computer reboot solves it for me for a while. – ICL1901 Mar 09 '17 at 00:14
  • Thanks for the update! Anyone testing the 10.12.4 beta know if this has been fixed? – Geozeke Mar 10 '17 at 01:11
  • From what I can see, the problem persists in 10.12.4 & Xcode 8.3 :-( – Geozeke Mar 27 '17 at 22:22

1 Answers1

1

If the error persists, you may use a temporary exeption entitlement key to access the plist in question.

<key>com.apple.security.temporary-exception.files.absolute-path.read-only</key>
<array>
        <string>/Library/Preferences/com.apple.PowerManagement.plist</string>
</array>
Richard Barber
  • 5,257
  • 2
  • 15
  • 26