Accessing iOS App's Shared Files without iTunes - ios

Apps that set their UIFileSharingEnabled flag to true enable iTunes to browse their Document folder for so-called shared files.
Is there a way to browse these files without iTunes?
To clarify, how does PhoneView allow browsing the Apps Document folders?
Are there any APIs that do this?

I believe PhoneView can do what you're asking. See the example below browsing my GBA4iOS Documents folder. This works with all devices (I am not jailbroken).
The Document Picker API may help you access these files.

Related

How to view document directory in iOS emulator?

I wrote a React Native application that downloads a file and saves it to the document directory.
The application gives me a path like this:
/Users/laurent/Library/Developer/CoreSimulator/Devices/SOMEID/data/Containers/Data/Application/SOMEID/Documents
and using macOS Finder I can see that the file has indeed been created.
My problem is how to view this file from the iOS emulator? If I click on the Files app for instance, I can't see that file. Basically is this file available to the user from somewhere and, if so, where? Or maybe I need to save it to a different directory?
Your iOS app is sandboxed by default, meaning that no other app can access its resources. The simulator is very different since it runs on your mac and stores your files there so you can easily access them.
That said, it is very simple to expose your Documents folder by adding the appropriate keys to your app's info.plist:
Add the UISupportsDocumentBrowser key to grants access to all the documents in the app’s Documents directory and have them appear in the Files app (iOS 11 and above). When this is enabled, other apps can also have access to your documents when using UIDocumentBrowserViewController.
Add the UIFileSharingEnabled key to expose the app’s Documents directory to the desktop iTunes app. When combined with the LSSupportsOpeningDocumentsInPlace key, it will also enable Files app support and document browser as mentioned above.
By default any files your application downloads are only available from within that app, they will not show up in the file system of the device.
As far as I know there is no react-native library which allows you to access the iOS file system, so you will need to make use of native iOS code to solve your problem. Besides pointing you to the official documentation, there is not much more I can do to help.

iOS: Support App Group folders in local file provider

I understand that if I provide the UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace keys in Info.plist for my iOS app, files in my app's Documents folder are shown in Files.app ("On This iPad") and the documents browser.
Now my question - aside from writing a File Provider extension - is there any way to add an app group's folder or replace the Documents folder with a folder in the app group's folder?
For sharing between my extensions, I save everything in the App Group folder instead of Documents, but then, of course, Files.app doesn't have access to those files, that's why I'm asking.
I tried creating symbolic links from the documents folder to the actual file, and they are shown, but don't work correctly ("file doesn't exist").
I've also created a File Provider extension, but it was rejected by Apple because my extension isn't cloud-backed and was only for local files. According to my reviewer, a File Provider extension must be cloud-storage backed.
Thank you for your help and insights,
-Matt
It's pretty simple: No. :(
We are struggling with the same issue and its simple: You can't participate in the files app (or iTunes File Sharing) if you don't store your files in the Documents folder.
It seems like this is not well thought out. You should not integrate as a file provider unless you are actually providing a file system such as dropbox, at least that's what we've been told at WWDC. On the other side you should support stuff like iMessage extensions, today extensions,... which only are possible if your files are accessible through an app group. But this then automatically breaks the use of the Files.app as well as iTunes Filesharing.
We filed radars for that, any duplicate would help, I guess.

how do you export a file out of iOS when using cordova file plugin?

I'm using https://github.com/apache/cordova-plugin-file on an iOS device and I'm attempting to write files. I can write files ok but according to the iOS file system layout, all of these locations where I write are private.
I'm guessing this is due to Apple's sandbox security model so that each app can only see files within its own bundle. This is different on Android where the cordova.file.externalRootDirectory location is NOT private.
My question is: How do you export this file out of an iOS device?
The file that I'm writing contain a long list of GPS locations captured by the Cordova app I'm running. I can see the file in XCode, under devices, and export the whole container in order to view the file. But there has to be a better way to transfer the file out. Is it possible to transfer a Cordova generated file out of an iOS device to the computer -- maybe through iTunes or iCloud?
I've also tried using cordova.file.syncedDataDirectory and I can write files to that location just fine. But the file doesn't appear in my iCloud account.
You have to use itunes file sharing
File-Sharing Support
File-sharing support lets apps make user data files available in
iTunes 9.1 and later. An app that declares its support for file
sharing makes the contents of its /Documents directory available to
the user. The user can then move files in and out of this directory as
needed from iTunes. This feature does not allow your app to share
files with other apps on the same device; that behavior requires the
pasteboard or a document interaction controller object.
To enable file sharing for your app, do the following:
Add the UIFileSharingEnabled key to your app’s Info.plist file, and set the value of the key to YES.
Put whatever files you want to share in your app’s Documents directory.
When the device is plugged into the user’s computer, iTunes displays a File Sharing section in the Apps tab of the selected
device.
The user can add files to this directory or move files to the desktop.
Apps that support file sharing should be able to recognize when files
have been added to the Documents directory and respond appropriately.
For example, your app might make the contents of any new files
available from its interface. You should never present the user with
the list of files in this directory and ask them to decide what to do
with those files.
So, add the UIFileSharingEnabled to your info.plist and set it to YES
https://developer.apple.com/library/ios/documentation/Miscellaneous/Conceptual/iPhoneOSTechOverview/CoreServicesLayer/CoreServicesLayer.html#//apple_ref/doc/uid/TP40007898-CH10-SW30
#jcesarmobile's answer helped me track down that I needed to enable file sharing in iOS. After confirming that I can enable file sharing by modifying the info.plist file in XCode, I found out that you could directly set UIFileSharingEnabled in the config.xml file but it's a bit more tricky because it's not a standard preference.
<gap:config-file platform="ios" parent="UIFileSharingEnabled" mode="replace">
<true/>
</gap:config-file>
After putting this in my config.xml file, it worked.
This is noted in the PhoneGap documentation, but I'll admit that it was really buried and a bit difficult to find.
http://docs.build.phonegap.com/en_US/configuring_config_file_element.md.html#Config%20File%20Elements

download the files saved in the ios app

I am designing an ios app which collects the user data and saves the data into a .txt file. I am currently using the sandbox in organizer in xcode to download these files. However, I want the users who do not have xcode to access these files as well.
So are there any ways that I can download these files either via USB, or via FTP to a server, or via iCloud, or via Bluetooth, or via WIFI?
iTunes File Sharing would probably be the easiest method of getting files out of your app. You basically just add the UIFileSharingEnabled key to your app's Info.plist, then save the file to the sandbox's ~/Documents/ directory.
Here's a tutorial if you want a more in-depth discussion of how to use file sharing.
Probably most easiest way is to dump file content to UIPasteboard.

how to share a certain directory tree list from <Application_Home>/Documents using UIFileSharingEnabled

i want to integrate itunes file sharing into my app. I know that i just need to set true UIFileSharingEnabled in info.plist. But it make all files and directories in /Documents from my app is show in itunes file sharing. I just want to share a directory tree listing in itunes file sharing.
This is a screenshoot of my /Documents (i got it from iphone simulator directory but it is same for the device)
from that pictures, i just want to share the all files in Project directory without showing Project directory itself.
Can i do that? Please help me to solve this.
Thank you, Risma
I don't think you can alter what is shared when you enable file sharing by using the UIFileSharingEnabled key in Info.plist.
However I suggest that you revamp your content so that application specific content go into the Library folder such as the database file and other non-user stuff. You might want to go through this for identifying which folders are backed up by iTunes.
How about a symbolic link? That would solve that issue in a snap, provided you can implement them and control permissions. Not sure how to do that with iOS, but it's definitely worth looking into. When it comes to file sharing, links are your best friend.
I don't have any experience with iPhone app dev, but I've done plenty of file share management in Linux. Hopefully it's not too different... But I have no idea what system calls are available to you with iPhones. If you find out, I'd enjoy knowing. Good luck!

Resources