4

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 Image

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

Manthan
  • 3,856
  • 1
  • 27
  • 58
  • Which hidden folders and wondering why? – zaph Jul 27 '15 at 05:18
  • I am deleting contents from some of those folders like application caches and mail downloads. But apple says for that "Need to ask user's permission. That is right also. I have seen that alert in one of the mac apps also... – Manthan Jul 27 '15 at 05:20
  • @zaph: Can you please help me on this??? – Manthan Jul 27 '15 at 05:48
  • Is your app sandboxed? Also, what files are you trying to delete from the user's home directory? If your app wrote them out, it should be able to delete them as well. – Michael Dautermann Jul 27 '15 at 18:54
  • @MichaelDautermann: Yes, My app is sandboxed. I am trying to delete the some of the hidden folders like application caches, mail downloads and application logs. So I used NSOpenPanel to ask permission but I don't know how to ask user that permission from user? – Manthan Jul 28 '15 at 04:04
  • I had a similar Problem creating a folder in "Application Support". See my answer here: https://stackoverflow.com/questions/33162116/permission-to-access-library-application-support-from-mac-app-bundle/74287803#74287803 – RED SOFT ADAIR Nov 03 '22 at 09:50

1 Answers1

3

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.

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215