Reading iPhone files from PC / Mac programmatically - iphone

Applications like iPhone Explorer can show the contents for each installed iPhone application on Mac OS X (even on non-jailbroken devices) when iPhone is connected using USB-cable. I'm trying to do something similar, programmatically copy some files from my iPhone app's folder.
I have done some experiments with open-source frameworks/products built to use iTunes-framework, like iPhoneBrowser and MobileDevice Library. I can connect to iPhone, now the problem is how to enumerate Apps folder items? iPhoneBrowser or MobileDevice Library don't support or provide any easy way for that. Even when hardcoding my application path to iPhoneBrowser it still refuses to display the folder. iPhone Explorer can read the folder without any trouble on the very same device, so it is definitely possible.
Second problem is getting path to apps, on each device they have different path with some hash number folder names. How to 'decrypt' the paths so that I can access my app folder on every device?

the app enumerate use another protocol, you may find some in this https://github.com/phildrip/fruitstrap

I wrote a open source program that works on Windows, here is the github project url:
https://github.com/Moligaloo/iPhoneFS
It can access files on jailbroken iPhone/iPod/iPad (non-jailbroken devices files are limited accessible).
It can also enumerate apps on iDevice.

Related

Look inside Apps folder

is there a way to navigate inside the folder structure in iPad or iPhone, check what is inside of any app folder? I tried already xcode but can not identify the folders. Thanks...
You can't do it on a real device, but you can have a look on the simulator. Up until iOS 7 each iOS version maintains it's own set of apps under
Library/Application Support/iPhone Simulator/7.1/Applications/
followed by a cryptic number representing your app. Replace 7.1 with another iOS version. To display the Library folder in Finder, click Go from the Finder menu while holding down Option.
Since iOS 8 those locations have moved and are harder to find. See here: http://pinkstone.co.uk/where-is-the-documents-directory-for-the-ios-8-simulator/
Yes, you can use programs like "iExplorer" which let you navigate your device even without jailbroken devices. I often use it to check that my app is correctly creating files according to my coded file structure.
You can see only contents of Documents Directory on Simulator or device. If you want to see documents directory in device then you have to set UIFileSharingEnabled key to YES in your application's Info.plist file. Then you can see it via iTunes app in Mac os x.
There is not way to see bundle contents in application. Just you can see bundle contents in xcode.
Regards.

Browsing an apps folder structure on an iDevice

When I plug my iPhone into the computer can I access an apps folder structure that's on the phone? Either programatically or manually with a tool that doesn't involve jailbreaking.
Have you tried iExplorer? See if that satisfies your requirements.(It doesn't need the device to be jailbroken).
It cant be done without jailbreaking, you basically must create your app folder structure with xcode.

Any way to get your SQLite DB off iPhone?

I'd like to analyze the data that I have in my iPhone app after doing some tests, and the data is in a SQLite database. Is there any way for me to be able to copy it off of the iPhone back to my laptop? I'm not aware of any mechanisms that allows me filesystem style access.
You don't need to turn on file sharing in the app to get this, you can get the data for any app you've built via Xcode's devices window.
In recent versions of Xcode (8 and up, I think), open this with Window menu --> Devices. Find the device in the device list and look at the installed apps list for the device. Each app that you've built and installed on the device will be listed (and maybe some others). Select your app and click the gear menu below the list. Clicking the "Download" item on the pop-up menu will enable you to copy the app's documents, library, and other directories to your Mac.
NB: This will download an .xcappdata file. Right-clicking on that and selecting "Show Package Contents" will allow you to drill down to the actual sqlite file.
In Xcode 6 this is available at:
Window -> Devices -> -> Installed Apps.
Select your application.
Click the gear icon -> "Download Container"
You can also use iExplorer (for Windows or Mac, free version available) to browse and copy data on the iphone, without needing to jailbreak it.
If this is your own application you can enable Application supports iTunes file sharing (UIFileSharingEnabled) in your applications plist and your database is stored in your documents directory of your application you will be able to easily access your database through iTunes.
UIFileSharingEnabled (Boolean - iOS)
specifies whether the application
shares files through iTunes. If this
key is YES, the application shares
files. If it is not present or is NO,
the application does not share files.
Applications must put any files they
want to share with the user in their
/Documents
directory, where is
the path to the application’s home
directory.
In iTunes, the user can access an
application’s shared files from the
File Sharing section of the Apps tab
for the selected device. From this
tab, users can add and remove files
from the directory.
This key is supported in iOS 3.2 and
later.
Other Options:
Jailbreaking your phone, adding afc2add through Cydia and then using some type of iPhone Explorer application.
Jailbreak your phone and install ssh and use a tool such as CyberDuck.
There are windows alternatives to both of those applications.
If your iPhone is jailbroken, you can access it through SSH. A program like WinSCP (on Windows) can allow you to connect to the phone and give you filesystem access. Then you can navigate to where your application stores the DB.
There are also multiple Filesystem applications out there that might allow you to do this, but I don't think they will give you the full extent if your phone is not jailbroken.
You can also use iMazing (for Windows or Mac, free version available) to browse and copy data on the iphone, ipad or ipod

Transfer Zip file from iPhone app

I have an iPhone app that creates a zip file.
I need to provide an easy way to allow the user to transfer that zip file to their PC (not via any network connectivity, as this file could be rather large).
Any suggestions?
Currently there is no way to accomplish this. You cannot hook into the synchronization until the next release of iPhone OS.
However, it works fine in Android.
For development builds you can access the file through Xcode's Organizer, and save locally to the Mac. I am not sure what is required to permit the access, perhaps the signing certificate?
iPhone Explorer (now iExplorer) works to grab files stored in an app bundle. I use it all the time.

Moving archives from Mac OS X to iPhone OS

My iPhone application has a fair amount of data that it needs to run, which I would like to store in the bundle as archives, and unpickle the data when the application starts up. Can I create these archives (which include instances of custom classes) on a Mac OS X system, and read them from the iPhone app?
If your question is: can you create archive files on the Mac, then ship them in your app's bundle, and have code on the iPhone access those bundled files, the answer is: sure, why not?
If your question is: can you have these archives live on the Mac, and have your iPhone app go find and download them when it first runs, the answer is: maybe, but it's much harder. And doesn't work too well for users whose devices aren't online when they try to run the app.