简体   繁体   中英

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

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...

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM