Restated: Mac Sandbox Container Folder Creation Problem
Posted: Sun Sep 25, 2016 5:42 pm
I'm restating this issue from my previous post because I understand the issue better now and can explain it more clearly.
For an app to be sandboxed for the Mac App Store, data files need to be stored within the app's container (<bundle_id> = app's container) in the directory shown here...
~/Library/Containers/<bundle_id>/Data/Library/Application Support/<app_name>/
Or, to be specific to my app...
~/Library/Containers/com.classroomquizshow.classroomquizshow/Data/Library/Application Support/Classroom Quizshow/
reference: https://developer.apple.com/library/con ... ndbox.html
Those folders are created automatically by MacOS for sandboxed apps--except that final folder, <app_name>, or in my case "Classroom Quizshow" must be created by the application code.
Problem: The LiveCode folder creation method "create folder" does not work FOR CREATING THIS FOLDER once the app becomes sandboxed.
Here's now I'm using "create folder"...
put specialFolderPath("Home") & "/Library/Containers/com.classroomquizshow.classroomquizshow/Data/Library/Application Support/Classroom Quizshow" into gMacLibraryDefaultFolder
create folder gMacLibraryDefaultFolder
Here is my evidence that "create folder" does not work FOR CREATING THIS FOLDER once the app becomes sandboxed. :
1. Build LiveCode standalone.
2. It functions properly, including creating the "Classroom Quizshow" folder for my data files if I delete the folder before running the app.
3. However, this standalone isn't yet seen by MacOS as being sandboxed. If I check the Mac utility app "Activity Monitor", it says "No" in the Sandbox column.
4. Now I codesign and sandbox the app. If I check the Mac utility app "Activity Monitor", it now says "Yes" in the Sandbox column (though it doesn't function--as described next).
5. If I then delete the "Classroom Quizshow" folder in the Container (because the folder wouldn't exist for a new user), the "Classroom Quizshow" folder is not recreated. Consequently, the app doesn't function.
6. I've tested extensively and determined that the code before the "create folder" line runs fine. Code AFTER the "create folder" line also runs fine, provided it doesn't rely on the existence of the never-created folder.
Therefore I believe "create folder" is not allowed by MacOS to create the <app_name> folder within a sandboxed app's Container.
I believe this is a problem LiveCode needs to address--unless LiveCode already has a method to create this special folder, and I'm just unaware of it. While it's true not all Mac App Store apps use data files like mine does (so others might say, "but my Mac App Store app works just fine"), those that do are supposed to store them in this specific location.
Help? If any of my reasoning is faulty, I'm all ears. I am far from being an expert.
Thanks,
Steve
For an app to be sandboxed for the Mac App Store, data files need to be stored within the app's container (<bundle_id> = app's container) in the directory shown here...
~/Library/Containers/<bundle_id>/Data/Library/Application Support/<app_name>/
Or, to be specific to my app...
~/Library/Containers/com.classroomquizshow.classroomquizshow/Data/Library/Application Support/Classroom Quizshow/
reference: https://developer.apple.com/library/con ... ndbox.html
Those folders are created automatically by MacOS for sandboxed apps--except that final folder, <app_name>, or in my case "Classroom Quizshow" must be created by the application code.
Problem: The LiveCode folder creation method "create folder" does not work FOR CREATING THIS FOLDER once the app becomes sandboxed.
Here's now I'm using "create folder"...
put specialFolderPath("Home") & "/Library/Containers/com.classroomquizshow.classroomquizshow/Data/Library/Application Support/Classroom Quizshow" into gMacLibraryDefaultFolder
create folder gMacLibraryDefaultFolder
Here is my evidence that "create folder" does not work FOR CREATING THIS FOLDER once the app becomes sandboxed. :
1. Build LiveCode standalone.
2. It functions properly, including creating the "Classroom Quizshow" folder for my data files if I delete the folder before running the app.
3. However, this standalone isn't yet seen by MacOS as being sandboxed. If I check the Mac utility app "Activity Monitor", it says "No" in the Sandbox column.
4. Now I codesign and sandbox the app. If I check the Mac utility app "Activity Monitor", it now says "Yes" in the Sandbox column (though it doesn't function--as described next).
5. If I then delete the "Classroom Quizshow" folder in the Container (because the folder wouldn't exist for a new user), the "Classroom Quizshow" folder is not recreated. Consequently, the app doesn't function.
6. I've tested extensively and determined that the code before the "create folder" line runs fine. Code AFTER the "create folder" line also runs fine, provided it doesn't rely on the existence of the never-created folder.
Therefore I believe "create folder" is not allowed by MacOS to create the <app_name> folder within a sandboxed app's Container.
I believe this is a problem LiveCode needs to address--unless LiveCode already has a method to create this special folder, and I'm just unaware of it. While it's true not all Mac App Store apps use data files like mine does (so others might say, "but my Mac App Store app works just fine"), those that do are supposed to store them in this specific location.
Help? If any of my reasoning is faulty, I'm all ears. I am far from being an expert.
Thanks,
Steve