Can I write to an App Group from an iOS Thumbnail Extension or QuickLook Extension?

Is it possible to write to an App Group's Container folder or UserDefaults from an iOS Thumbnail Extension or QuickLook Extension?
It doesn't work. It does work for a Widget extension.

I've added the App Group to the Entitlements of each extension.

For writing a file to App Group Container I get

Code Block
Error Domain=NSCocoaErrorDomain Code=513 "Du hast nicht die Zugriffsrechte, um die Datei „quicklook 01 current.log“ im Ordner „DocumentInvestigation“ zu sichern." UserInfo={NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/<redacted: the container UUID>/DocumentInvestigation/quicklook 01 current.log, NSUnderlyingError=0x28090bb10 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}


For setting App Group UserDefaults

Code Block
[User Defaults] Couldn't write values for keys (
example
) in CFPrefsPlistSource<0x2839cc700> (Domain: <redacted: the-group-identifier>, 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

The use case is, that we are investigating an issue and would like to log to a file which we then can have customers send us.

Replies

Were you able to resolve this? This still seems like an issue in iOS 15

I couldn’t. It seems that is intended for security reasons. That way you could read personal information out of files and send it somewhere else. But I cannot find any quote on this.

It seems that is intended for security reasons.

I suspect that’s true but…

But I cannot find any quote on this.

Likewise. I’d appreciate you filing a bug against the docs requesting that they clarify this situation. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"