Specific constraints of iOS sandboxing - ios

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

You will not have permission to read/write outside your application.
You will not have permission to read/write outside your application.
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.

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.

Related

Audiio fiiles inside an iOS application

Is there a way inside an iOS Swift app of mine, to access the sound files I already have available in my itunes library on the same device?
Browsing the net I came accross something called File-Sharing and the UIFileSharingEnabled key, but that does not seem to be quite what I am looking for.
The files? I’m not sure.. if so only those you downloaded or bought on iTunes. For access to Apple Music you probably want to look into MusicKit.
However, there’s a way to get MediaItems via MPMediaPickerController (docs)

Swift - how to access all pdf files on device

I am trying to build an app that will allow users to see all pdf files that are on the device (in some kind of a list with a preview) [Regardless of which app it belongs to on the device, all should be shown]. Is there anyway to achieve this?
Sorry but this is not possible on an iOS device because of a feature called sandboxing. Apple does not allow an app to access the sandbox of another app. Each app sits inside a sandbox of its own. This is iOS's security feature. There is no way to go around this feature.
Reference - About App Sandbox

How to access all the files(pdf, doc etc) in iOS?

How can I find out programmatically all the files present in iOS device and list them out to user? Also I need to download the file in my local application database?
How this can be achieved with Objective-C.
You cannot access all files in an iOS device outside the sandbox of the app. But there are other ways you can achieve this. What you can do is:
Access all the files in Gallery using UIImagePickerController.
Access all the user files in network- Dropbox/Google drive/iCloud. They all have separate public APIs that can be downloaded and used to download/upload files in network.
In this way, you can access most of the user files and use the same in your application.
Simple answer : you can't (on a non-jailbroken device).
Each app is launched is in own sandbox and can't interact with the others apps, expect using API provided by Apple for app-communication (ex: extension)
You should look at that Apple guide about App Sandboxing, which is valid for OSX and iOS apps.
The main difference between these two OS, as quoted directly from the doc :
iOS Note: Because it is not for user documents, an OS X container
differs from an iOS container—which, in iOS, is the one and only
location for user documents. In addition, an iOS container contains
the app itself. This is not so in OS X.
You cannot access all the files outside the app sandbox. But, if they are available at some shared location(network), you can use third party libraries to access them. For eg.
1. For iCloud- iOS provides inbuilt framework of UIDocument
2. For dropbox- DropBoxAPI is available
3. For Google drive- there is a separate library to access files in the drive.
Hope this helps :)

ios copy file to another apps file directory

Is there anyone that got an idea of how to copy files to another apps file directory in ios? I need a service for this so I can from my app simply hit a button and what my app does is copy a file to another apps directory? will that be possible? I am ready to pay for a person that can help me with this?
iOS apps are sandboxed and are not able to directly access the contents of another app's data. There are ways for apps to interact with each other, but these require user interaction and are limited to specific use cases. For more info, here are some docs from Apple on inter-app communication:
Document Interaction Programming Topics for iOS
Inter-App Communication

Unofficial API - Access other apps bundle and icons - iOS

I've seen this which pulls the app from the internet and this which is what I'm looking for, but I'm not publishing to the app store.
So is there a way to do the following:
Go into app bundles on the device and extract the icons for those apps using official and/or unofficial APIs ?
As #Gavin specified: Jailbreaking is not an option for this particular case.
Apps are sandboxed on iOS, so even if you're not submitting to the app store, your app is still prevented from accessing files outside your sandbox, which includes the files of other apps on the device.
Now if you wanted to jailbreak your device, you could access files outside of the sandbox. But you didn't state that you were willing to do that, so I am assuming this is out of the question for you.

Resources