App extension write data The main target reads data.

I have an iOS app with a main target and an app extension. I want the app extension to write data to the SwiftData in App Groups, while the main target reads the data. However, currently, the app extension only has permission to read data, not to write it.Is the issue due to my incorrect configuration or an Apple-imposed restriction?

Answered by DTS Engineer in 855740022

As @mungbeans mentioned, not all extensions can write to an App Group container. A keyboard extension with no full access is an example of that kind.

The other possibility is you intentionally create your model container with readonly mode by using init(_:schema:isStoredInMemoryOnly:allowsSave:groupContainer:cloudKitDatabase:) with allowsSave being set to false. It doesn't look like the case though, based on your description.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

What type of extension is it? Some have read and write access, but others only have read access.

As @mungbeans mentioned, not all extensions can write to an App Group container. A keyboard extension with no full access is an example of that kind.

The other possibility is you intentionally create your model container with readonly mode by using init(_:schema:isStoredInMemoryOnly:allowsSave:groupContainer:cloudKitDatabase:) with allowsSave being set to false. It doesn't look like the case though, based on your description.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

App extension write data The main target reads data.
 
 
Q