UserDefaults and @AppStorage causing DeviceActivityMonitor to crash on iOS 17

I use App Groups to share UserDefaults data between my host app and DeviceActivityMonitor extension.

On iOS 17, it appears that reading @AppStorage variables are causing my DeviceActivityMonitor extension callback functions to crash. Weirdly, writing values is okay.

I see this in the extension logs:

Couldn't read values in CFPrefsPlistSource<0x10fe251d0> (Domain: GROUP_NAME, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd

However, through searching this log message on the internet and the fact that it also appears in my host app logs without crashing, this seems to be a warning - possibly indicating an issue but also a possible red herring.

But the fact remains that when I don't read UserDefaults values or variables decorated with @AppStorage in the DeviceActivityMonitor extension, everything works fine.

Are UserDefaults, and specifically @AppStorage decorators supported in the DeviceActivityMonitor extension?

Thank you for sharing this issue. I will attempt to reproduce it when I have time. Does the problem occur on all versions of iOS 17, or did it start with a specific version (e.g., 17.2)? Have you filed a bug report with Apple regarding this?

I'm having this same issue and it's extremely frustrating.

I use App Groups to share UserDefaults data between my host app and RichNotification extension.

On iOS 17.5.1 and Xcode 15.3.

Couldn't read values in CFPrefsPlistSource<0x10b6bb7a0> (Domain: GROUP_NAME, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd

How to find appropriate solution for this crash?

UserDefaults and @AppStorage causing DeviceActivityMonitor to crash on iOS 17
 
 
Q