0

I would like read access to the files in the iPhones music directory:

~/Media/iTunes_Control/Music/F**/*.{M4A,MP3}

1) I can't seem to figure out from the docs whether iOS apps are sandboxed such that I would or would not have this permission.

2) Is it necessary to ask for read or write permissions to directories outside the iOS App sandbox ? Only write permissions ? How does one do this, or is it just up to the discretion of the team that reviews the App for app store release ?

3) I have found a lot of information in the apple docs on sandboxing of OS X apps but not of iOS apps. Is there a similar sandboxing/entitlements process for iOS as for OS X apps ? Any useful links I should read ?

Update: as accepted answer says below, 1,2, and 3 are impossible, however it is possible to obtain a copy of a file in the media library, which is in some sense equivalent to having read access to the original - because of course the digital information is identical. This question contains code that does that: Application crashed while importing songs from Ipod library in Iphone for iOs 5.0

Community
  • 1
  • 1
Colin
  • 2,089
  • 25
  • 34
  • finally found some info on 3) - from Entitlement Key Reference: "Set entitlement values in order to enable iCloud, push notifications, and App Sandbox (only for OS X)." – Colin Oct 26 '12 at 15:38
  • With App Sandbox, your app has access... to locations that are POSIX world-readable... so it appears that OS X apps would have read access to the iTunes Music directory without needing an entitlement. The path of the iPhone's music files are similarly POSIX world-readable so looks good, unless app store reviewers decide it's not, I guess. – Colin Oct 26 '12 at 15:58
  • Weird, the Entitlement Key Reference defines an entitlement for read access to the Music folder, even though the Temporary Entitlements section makes the above statement about POSIX world readable locations. Those seem to conflict. – Colin Oct 26 '12 at 16:10
  • ah, another part says "certain world readable" locations including /bin, /sbin, /usr/bin, /usr/lib, /usr/sbin, /usr/share, /System [this is all for OS X] – Colin Oct 26 '12 at 17:10

2 Answers2

2
  1. You will not have permission to read/write outside your application.
  2. You will not have permission to read/write outside your application.
  3. You will not have permission to read/write outside your application.

You can use the Media Player framework to access information about the user's library, but nothing using the filesystem.

J2theC
  • 4,412
  • 1
  • 12
  • 14
  • really not even read are you sure ? is there a reference doc you'd recommend ? – Colin Oct 26 '12 at 16:00
  • check the media player framework linked on my answer. You can use that to access information from the iPod application. – J2theC Oct 26 '12 at 16:01
  • http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MediaPlayer_Framework/_index.html – J2theC Oct 26 '12 at 16:02
  • Although you can't read from the media directory, you can get iOS frameworks to do it for you and give you a copy of the files - see my edit to the question. – Colin Oct 30 '12 at 16:15
0

Sandboxing on iOS is done for you, there is no need to set that up.

You can not write files outside your applications sandbox.

I have not attempted to access music stored by the iPod app, but there is access to media types. It functions much like access photos.

Here is the link to the Apple docs for MPMediaPickerController.

Mike D
  • 4,938
  • 6
  • 43
  • 99