Catalyst App and Userdefaults

I've created a Catalyst app that runs on WatchOS, iOS, iPadOS and MacOS. It stores some basic data in UserDefaults using Combine. The latest builds are starting to get the following error.

2020-05-25 12:10:30.535305-0400 Wasted Time[82077:918516] [User Defaults] Couldn't write values for keys (
    ApplicationAccessibilityEnabled
) in CFPrefsPlistSource<0x600002c15f00> (Domain: com.apple.Accessibility, User: kCFPreferencesCurrentUser, ByHost: No,
2020-05-25 12:10:30.538688-0400 Wasted Time[82077:918516] [User Defaults] Couldn't write values for keys (
    AccessibilityEnabled
) in CFPrefsPlistSource<0x600002c15f00> (Domain: com.apple.Accessibility, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
2020-05-25 12:10:30.539074-0400 Wasted Time[82077:918516] [User Defaults] Couldn't write values for keys (
    FullKeyboardAccessFocusRingEnabled
) in CFPrefsPlistSource<0x600002c15f00> (Domain: com.apple.Accessibility, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
2020-05-25 12:10:30.540987-0400 Wasted Time[82077:918516] [User Defaults] Couldn't write values for keys (
    ApplicationAccessibilityEnabled
) in CFPrefsPlistSource<0x600002c15f00> (Domain: com.apple.Accessibility, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access

 Container: (null), Contents Need Refresh: Yes): setting preferences outside an application's container requires useI I have

I have cofirmed that my App Sandbox settings are showing "File Access -> User Selected File -> Read/Write". The app has a custom suiteName for my UserDefaults, and apprears to actually make the updates. (I do see this error in both Xcode 11 and Xcode 11.5(11E608c).


How do I resolve this error?

Answered by DTS Engineer in 423916022

these errors just lead to a worsen developer experience

Fair enough, and hence this quote in the post I mentioned:

if you find it to be particularly irksome, file a bug report requesting that it be silenced.

Although, speaking for myself, I think the long-term solution here is for Xcode to support log filter using similar semantics to those provided by the Console app (r. 32863680).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Do these failures result in any problematic behaviour? At the UI level? Or even at the code level? If not, I think you should treat them as log noise.

I have cofirmed that my App Sandbox settings are showing "File Access -> User Selected File -> Read/Write".

FYI, that setting translates to the

com.apple.security.files.user-selected.read-write
entitlement, which enables your use of the standard open and save panels. It has no impact on user defaults.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

> Do these failures result in any problematic behaviour?


these errors just lead to a worsen developer experience that's getting worse and worse and worse with every Xcode update.

Accepted Answer

these errors just lead to a worsen developer experience

Fair enough, and hence this quote in the post I mentioned:

if you find it to be particularly irksome, file a bug report requesting that it be silenced.

Although, speaking for myself, I think the long-term solution here is for Xcode to support log filter using similar semantics to those provided by the Console app (r. 32863680).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
I have been seeing these errors, as well, in my catalyst app. I had been ignoring them up to this point. Unfortunately, it seems to be preventing the app from running on the Silicon. It produces a fault and the app will fail to start. I have read that it is produced from older code that was generated before the sandbox. How can one go about finding the code so that it can be upgraded?

Best,
Jaime

Unfortunately, it seems to be preventing the app from running on the Silicon.

Is this under Rosetta? Or running natively?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
I have same issue.
Code Block
2020-08-02 19:51:16.638526+0200 BkoolAuthApp[1742:42083] [User Defaults] Couldn't write values for keys (
    ApplicationAccessibilityEnabled
) in CFPrefsPlistSource<0x600002c00080> (Domain: com.apple.Accessibility, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: Yes): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
2020-08-02 19:51:16.640707+0200 BkoolAuthApp[1742:42083] [User Defaults] Couldn't write values for keys (
    FullKeyboardAccessFocusRingEnabled
) in CFPrefsPlistSource<0x600002c00080> (Domain: com.apple.Accessibility, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access



I am using CoreData, and UserDefaults, iOS 13, Xcode 11 and Catalina 10.15.6


Code Block <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<true/>
</plist>





Hi,
I also faced such error while tried to run my iOS app as the Mac app (converted by Catalyst).
I resolved this by lowing the Target version of iOS.
Initially I created an iOS app for Target iOS 13.7 and the Mac required macOS 10.15 (I'm running on Catalina 10.15.3).
Running the Mac app with these configurations failed with the error you mentioned.
Reducing the Target to iOS 13.0 solved the issue.
Your app -> TARGETS -> General -> Deployment Info -> Target
I solved the problem by editing the entitlements file directly, replacing

<key>com.apple.security.app-sandbox</key>
<true/>

with

<key>com.apple.security.app-sandbox</key>
<dict>
<key>user-preference-write</key>
<true/>
</dict>

Unfortunately, Xcode's capabilities UI does not support the change.

I also have this problem with UserDefaults in Catalyst.
I tried @daspoone 's solution of adding "user-preference-write" = TRUE to the entitlements file and POOF! the app crashes basically can not find entitlements file!

It may be that these warnings are just log noise as @Quinn suggests (my app's preferences seem to be read and written just fine), but with
every new release of Xcode, there is more and more unhelpful garbage in my debug console!
Catalyst App and Userdefaults
 
 
Q