How to allow permission for user's Home folder in cocoa application for mac

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 17:56:13

问题


I am having a mac app in which I am deleting some data from user's Home directory.

My app is rejected saying the below reason.

The app only finds files in the ~/Downloads folder. It would be appropriate to have the user grant access to the Home folder.

So I used NSOpenPanel for asking the access from the user but I have no idea about how to give access to user's hidden folders.

EDIT

I have successfully enabled sandboxing for my app but now on allow button, what should I do?

Please guide me on this...

Any help will be highly appreciated.

Thanks in advance...


回答1:


I spent some time researching this and I can say that if you want an easy solution for being able to access files outside your app's sandbox, it's just not going to be possible.

And even if you were willing to work on a tougher, more technical solution, it is still likely to not be possible.

You should look at this section in the Apple's App Sandbox Design Guide entitled "Accessing User Data", specifically this bit:

If your app requires access to the user’s home directory in order to function, let Apple know about your needs using the Apple bug reporting system. In addition, be sure to follow the guidance regarding entitlements provided on the iTunes Connect website.

The next paragraph says the same thing about other app's preferences. Since you're trying to manipulate -- or delete -- other app's files, you're going to have to ask Apple for permission and/or guidance to do this.

If this were my problem, the only workaround I might possibly attempt would be to come up with might involve Security-Scoped Bookmarks and Persistent Resource Access, but as you can see from the linked documentation, it's not trivial to setup.

Summed up: if you want your app to remain sandboxed, you may need to rethink what you are trying to accomplish.

More information can be found in this related question.



来源:https://stackoverflow.com/questions/31645372/how-to-allow-permission-for-users-home-folder-in-cocoa-application-for-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!