I recently updated to macOS Catalina so I could update some of my apps with Mac support using Catalyst. Whenever I run the app and it tries to access the CloudKit data (I use CloudKit to sync Core Data, Data if an iCloud Account is available), it then crashes with the following error. [User Defaults] Couldn't write values for keys ( ApplicationAccessibilityEnabled ) in CFPrefsPlistSource<0x600002c07700> (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
I have tried changing Permissions and Access in App SandBox settings in my Signing and Capabilities, to read/write. I have also tried changing incoming and outgoing connections to on.
I am not exactly sure what code I should show so here is the area is crashes in.
if isICloudContainerAvailable() { print("iCloud Available") let container = NSPersistentCloudKitContainer(name: "Shopping_App") container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") } }) return container }
I except the app to create/get the CoreData data and if available (which is in this case) to connect to the CloudKit synced data. But it crashes right now before it even brings up any views which leads me to think that it is crashing in the AppDeleget somewhere.
Update Oct. 14 -- I found that if I force Jump Over the Breakpoint where the app crashes, I can continue into the app and it works fine. Which leads me to think that the error is really in the AppDeleget especially saying that the UI does not appear until after I jump over the breakpoint it sets at the crash.
Update Nov. 4 -- So this problem gets even stranger. I forgot I was using a beta version of Xcode, so ok, it could have just been that after I realized that last week. I tried running the app through the public version and the app never stopped for a breakpoint but instead completely crashes with Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
. This error is just really odd. Would this be an error that I should report to Apple? I thought about doing that but I decided not to because it seemed to me like something I could have been doing, but now rethinking whether I should or not. I wish I could find the solution to this problem because I would like to release the macOS version to the public, but have not had any luck finding a solution.
Update Nov. 8 -- In Xcode 11.2.1 GM seed the problem still persists. I have yet to find the exact reason this problem occurs but will continue to try. I have also been unable to reproduce the error written in the update on Nov. 4, on any Xcode version. I have not found anything else but wanted to update this with information about the GM seed and if this still happens.
Update Nov. 13 -- I decided to just go ahead and upload the app to Apple for approval since building the app and running it independently from Xcode worked just fine. Apple approved the app without any complaints of this issue. This just seems to be an Xcode issue. I will continue to update this however and if/when I find a solution I will post the solution to this problem but have not found anything more to workaround or solve this problem.
Update Nov. 20 -- On Xcode 11.3 Beta Build 11C24b, the problem still occurs. Nothing else has changed and I have not found anything else to solve this problem. I will continue to keep this updated but have not found anything else yet.
Update Dec. 11 -- On Xcode 11.3 Public 11C29 the problem still continues. However, now it is not consistent and sometimes I have to go over the breakpoint twice instead of just once for the application to continue launching. It still does not occur though if ran independently from Xcode.
Update Jan. 2, 2020 -- Still occurs but now verified that it occurs on a real iOS 13 device. No other solutions or stepovers found though. I will continue to update this post however with any other information.
Update Feb. 17, 2020 -- Not much of an update but still occurring on Xcode 11.4 Beta (11N111s). Will continue updating this post however not much has changed. (Fixed some misstakes on this post as well)
Update March 10, 2020 -- I did not realize that Xcode beta 11N132i was released but after testing it still occurs. However, though it may still be occurring, it is at least less consistent. Now instead of it happening and doing this every time, it appears to be somewhat random.
Update April 18, 2020 -- Sorry for not updating this post, I have been unable to program until now. I still have not figured out this issue but it seems that now it is not really happening. It still happens just rarely now. This also is on Xcode 11.4.1 (11E503a), and I am not sure why still. I will continue to try and update this post. Thank you. If you have any suggestions to try to find the cause, I am open to hearing them.
Update May 14, 2020 -- Xcode 11.5 Beta 2 (11N605f) This problem still occurs randomly, but now it seems to not always include the error yet still points to that portion of code. Thank you for your support of this post, and I will continue updating it as I find more about this problem.
Update Jun 5, 2020 -- I am sorry for not updating this any sooner, I completely forgot when I had updated Xcode. On Xcode 11.5 this problem still persists like it has been. I have also updated to Catalina 10.15.5 and have seen little to no changes. However, like the comments have said, Catalina 10.15.4 did help this has I heard, but 10.15.5 seemed to not change anything, which is strange.
Update Jun 27, 2020, and July 22, 2020, and Aug 10, 2020 -- I have updated my project to now support Xcode 12 and it appears to still have the same issue. Nothing has really changed and the log is the exact same. I appeaciate everyone willing to contiune in helpin fix this issue as well. This is also the same on Xcode 12 Beta 2. The excat same for betas 3 and 4.
Update Sep 28, 2020 -- This is still an issue on the GM and Public versions of Xcode 12. I have not updated to Xcode 12.0.1 because I am waiting for macOS Big Sur, but at this point, I doubt that would solve it. I really do not have any updates, other then it still is occurring and I cannot find the issue.
Update Nov 3, 2020 -- This still appears to be an issue on Xcode 12.1.1 Release Candidate. Sorry for not updating this for so long, I was holding out updating Xcode as I previously stated, but I decided to go ahead and update. However, updating to the Release Candidate has not changed anything, or not at least that I can notice. One change I did notice; however, was that it seemed to show this issue sooner, but that could just be that it compiles it quicker. To summarize, no major changes to this problem and nothing has really changed with it in a while.
UPDATE Nov 16, 2020
I have since updated to macOS Big Sur 11.0.1 and updated Xcode to 12.3 beta. The problem still seems to occur after having to change a few random things to get it working on Big Sur. However, most everything I changed I think is unrelated because it was mostly related to the UI elements. This may just be Big Sur but it compiles much faster, and the error now shows much quicker; however it still is the same error.
Overview. The App Sandbox is an access control technology that macOS provides and enforces at the kernel level. The sandbox's primary function is to contain damage to the system and the user's data if the user executes a compromised app.
To recap, Catalyst allows a developer to take an iPad app and tweak it to run on both Apple silicon and Intel Macs. These apps can pick up a lot of native Mac UI and UX features along the way. Messages, for example, is a Catalyst app as of macOS Big Sur.
MasterChief96, you are not alone. Here is my setup:
MacOS 10.15.3 Xcode 11.4.1
I create a brand new SwiftUI "Hello World" project, enable Mac as a target device, a.k.a. Catalyst.
I set the iOS deployment target to 13.2 (otherwise I get a MacOS runtime error saying I need Catalina 10.15.4)
Set the scheme to "My Mac", compile and run and get:
[User Defaults] Couldn't write values for keys ApplicationAccessibilityEnabled AccessibilityEnabled FullKeyboardAccessFocusRingEnabled setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
Since it refers to the sandbox, I change the "Signing and Capabilities" setting for App Sandbox to include Read/Write for User Selected and Downloads File Access.
I quite Xcode, delete the project's Derived Data, open the project and run. The error messages persist when running on MacOS. (I do not see the messages when running on iOS.)
Just guessing here, but this appears to be yet another bug in the Catalyst environment? Maybe this bug is fixed in Catalina 10.15.4 but that update was such a disaster for me I had to back port to 10.15.3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With