I am currently writing a software product which involves a Camera Extension and a Cocoa application. I would like to share some files between the two components and as of my understanding this should be quite straightforward by putting both applications into the same App Group and then accessing the particular Group Container.
However doing so, does result in both components accessing different locations for the Group Container. I am using the following piece of code to create a new folder inside the container:
let directory = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.235ADAK9D5.com.creativetoday.camskool")!
let newDirectory = directory.appendingPathComponent("Mydir")
try? FileManager.default.createDirectory(at: newDirectory, withIntermediateDirectories: false)
If I run this I find that the Cocoa application is going to access the following Location and create the file there:
/Users/<username>/Library/Group Containers/<App Group>/"
Where as the Camera Extension will access the following Location and create the directory there:
/private/var/db/cmiodalassistants/Library/Group Containers/<App Group>/
If I create a file in one directory it does not appear in the other. I tried for both components to access the opposite directory but it results in an permission denied message.
What am I doing wrong?