As title,my app was worked well before opened sandbox,after that,it can't read any data.How can I get access for ~/Library and it's sub folders?
-
show code and error message(s) – hoijui Aug 18 '15 at 10:10
-
@hoijui No error message.But after I closed sandbox option, it worked well.I think the problem will be on sandbox. – Lau Cherish Aug 18 '15 at 10:13
-
i don't know how sandbox works, but it sounds like it is meant to be a safe environment, thus it makes sense that it has no access to the normal system. maybe you can read about "cocoa sandbox modifying environment" or something like that. – hoijui Aug 18 '15 at 10:26
-
Yeah,thanks any way~ – Lau Cherish Aug 18 '15 at 10:38
-
@hoijui It seems to have to ask for permission from apple. – Lau Cherish Aug 18 '15 at 12:19
-
aha... you mean... i don't understand... you mean, if you want to enable some features in sandbox mode, you need to pay? – hoijui Aug 18 '15 at 14:24
-
@hoijui No, you should be ask for a permission in iTunes connect before you commit to Apple Store,it's free. – Lau Cherish Aug 18 '15 at 14:27
1 Answers
The purpose of the sandbox is to prevent an application accessing files without the users explicit permission.
To get that permission you need to display a standard open dialog and request the user select the file or folder you wish to access. You can customise the dialog to make your intentions clear.
Once the user has selected the file/folder you can save a bookmark to it allowing your app to access it in future without asking for the user's permission each time.
This is quite a large topic and one you need to understand to write applications for Apple's sandboxed environment.
You can find details on how to do all of this in Apple's documentation; read up on the sandbox, bookmarks etc. SO and the Apple Dev Forums are also good places for information. If you get stuck once you have some code ask another question showing your code and explain your problem.
HTH

- 52,522
- 5
- 70
- 86
-
Yes,it's a way to have permission,but I hope to access ~/Library/ and its subfolders without open folders and read some .plist file to get data.Is there any way? – Lau Cherish Aug 18 '15 at 14:58
-
No, you need to obtain the user's permission, as above. This is a cornestone of the sandbox design - no unrestricted access to user's files. – CRD Aug 18 '15 at 16:16
-
@CarlaCamargo - Not sure what you are asking, using the standard file dialog allows the user to select the file/folder and hence give the app access permission. If this doesn't answer your question you should create a proper question if you can't find an answer already on SO. – CRD Sep 24 '19 at 19:35