iPhone application, Documents directory on Mac - iphone

I'm reading through some of the documentation about File Management on iOS. When you create an application for the simulator, does the application get created somewhere on my hard drive? If so, where is it?
Also, does this have access to the Documents directory? Like if I create some test .txt file, and want to see it in the App->Documents folder, is that possible? Thanks.

Yes. Look here:
~/Library/Application Support/iPhone Simulator/4.3.2/Applications
Change the 4.3.2 to be the version of the Simulator you are using.
Within that folder you will find your apps, except the they are named cryptically. Open one of those folders and you will find your app, named as you recognize it, and the Documents, Library and tmp folders. Documents is where you find the docs that your app creates and uses. You can, in fact, makes changes to the files in the Documents folder or just access their content to see what your app sees or writes.

Under XCode 6, the document directory for your app is quite hidden:
~/Library/Developer/CoreSimulator/Devices//data/Containers/Data/Application//
You can find the directory for your app with this command:
$ sudo find ~/Library/Developer/CoreSimulator/Devices -name <APP_NAME>.app | grep -o '.*/'

Related

How to extract sms.db from non-jailbroken iphone on linux

Objective: Extract the sms.db sms text message database from an Iphone 4S.
I have installed ifuse on ubuntu 12.04 and am able to browse certain folders. None seem to contain the 'sms.db' file.
It is possible to extract the sms.db using freely available tools on linux?
I don't know yet how to access the SMS.DB file directly from the phone. But if you backup an iPhone using for example iTunes, you can then read the SMS.DB file from within the backup. It will be SHA-1 hashed (the file name will be gibberish), but it should still be a .DB file. You'll need iPhone Analyzer to unhash the file names, or something similar. Then you can load it into SQLite.
Please post here if you find a solution.
I've figured out a way on how to access it with Jailbroken devices... It miiiiiight be the same if you aren't jailbroken based on what the Github says (https://github.com/libimobiledevice/ifuse)
Anyways, open a terminal
Sudo su
now make a folder in your home and direct ifuse to that folder
ifuse --root /home/<INSERT NAME>/<INSERT NAME OF FOLDER>
Now you gotta open that folder as root
nautilus
Browse through your /home/ and find the folder.
It should be in
/var/mobile/Library/SMS/sms.db
Then you just copy it to your desktop and your good to go!

Is there a method for sharing and syncing the iOS simulator Applications folder

Our sales team often needs to give demos of apps currently in development. We've used a variety of methods to get them installed on their laptops but everything has been very manual.
The initial method we were using had us downloading the source code and compiling each and every project for each and every salesman. Very time consuming and annoying.
Then we got a little smarter and realized that we could copy out the Applications folder for the iOS simulator and just past that over the iOS simulator's Applications folder on each salesman's laptop. Much better, but still the manual part of copying them all over to each laptop.
So I started poking around about some folder syncing options for macs and came across this technique http://www.youtube.com/watch?v=iWoXPWlu_Dk
Very awesome and seemed to meet my need exactly. I had one central shared folder I could throw new iOS applications into and then the salesmen's laptops would automagically sync with that applications folder and new apps would just appear with no need to ever have their laptops here.
Unfortunately, the iOS simulator does not seem to be recognizing the Applications folder when it's a symbolic link or alias. Is there some Mac magic that could make this work? (I'm a Windows guy normally, just recently been working in the iOS world, so there could be something basic I'm missing here).
I'd love to have the Applications folder /Application Support/iPhone Simulator/5.1/Applications be a shared folder that syncs automatically for them, grabbing any new applications we have ready for demos (and getting them updates to old ones). Just seems like a nice smooth way to get them early builds.
We've used services like TestFlight for the actual devices and that's a great option for that, but when they don't have a device handy or are just blasting through demos on their laptops we'd love to have a nice easy process for keeping them up to date with new builds for their simulator install.
First a bit of background, you don't really need this, but I like teaching :).
On Unix, and now MacOS, there are two basic kinds of links. 'normal' links, and symbolic links. Alias, on windows, unix and mac are a kind of symbolic link: the link contains a reference to the original file. Normal, or hard links create a second directory entry that points to the data, if you delete the original file, the OS knows that there is still another entry pointing to it, so it only actually deletes the file (or directory) when all hard links have been removed. The disadvantage of hard links is that they have to be on the same file system, so that the file system can keep count of how many hard links there are.
OK, I've just installed Dropbox, and it seems that it creates a real folder in the user's home directory, so unless you're a complicated disk partitioning scheme, or file vault 1, where the user's home directory is actually an encrypted disk image, you can use a hard link. It also means that you don't need to copy or sync, as Dropbox is already doing that.
One thing not corrected, but didn't actually point out is that in your post, you seem to be copying to /Application Support, not ~/Library/Application Support or /Library/Application Support. Since you've got the basic scheme working without dropbox, I'll assume that is a typo.
Before I give you the commands, you might want to delete the old iPhone Simulator Applications directory with the Finder, instead of using the rm command, as the rm command is potentially very destructive.
OK, finally, the commands to do the linking; the quotes are important whenever filenames contain spaces. This example is for ~/Library
rm -rf "~/Library/Application Support/iPhone Simulator/5.1/Applications"
ln "~/Dropbox/Simulator Applications" "~/Library/Application Support/iPhone Simulator/5.1/Applications"
This should work, you can stop reading now, the rest is just more education :)
Tilde (~) is a short cut for the users home directory. Use the commands without this to work on /Library instead.
If you want to be sure you've got the exact path, you can drag files and folders from a finder window into the terminal, the path gets pasted instead of the file.
If you're messing with stuff in the root filesystem, you might need superuser rights. If you are logged in with an admin account, you can run single commands with superuser access as follows.
sudo ln "/Library/Application Support/iPhone Simulator" fred
The shell asks for your password, and then runs the command for you as superuser.
sudo remembers the authorization for a few minutes, then you have to authenticate again.
Haven't tested this since I only have one Mac, but give this a try:
Install Dropbox
Create a shared folder there and copy your apps from /Users/USERNAME/Library/Application Support/iPhone Simulator/5.1/Applications
Create a shell script to copy them back to the simulator's location, and add it to the shared folder. It should look something like this:
#!/bin/sh
cp -R ~/Dropbox/Appfolder/appname ~/Library/Application Support/iPhone Simulator/5.1/Applications/
Have your users sync their dropboxes to get the files, then run the shell script to copy the files.

How to download app data in Xcode 4.2

In the latest version of Xcode I could simply go to Organizer->MyDevice->Applications and then select the app I wanted to look at and download the appdata in form of a folder with all the app content. Now I only get a .xcappdata file.
How can I access this file for take a look in a .sqlite file?
Under the Data files in Sandbox pane in the Organizer, you'll find all the individual files that the selected app stores on the device and uses, displayed in a hierarchical view.
For my app, it looks like this:
To view the files in Finder, download the .xcappdata file, go to where you save it in Finder, Control-click on it and choose Show Package Contents. The directory structure is identical to what you see in the Organizer, and you can open and/or copy out the files as usual.
I'm constantly checking my app's database, so to speed things up I always download the .xcappdata to the same folder. I then run the following script that's sitting in that folder to look at the latest version of the database in 'sqliteman' (a sqlite program available through MacPorts):
#!/bin/bash
shopt - nullglob
for PACKAGE in *.xcappdata; do
CURRENT=$PACKAGE
done
sqliteman "$CURRENT/AppData/Documents/yourapphere.sqlite"

xcode: how to save files in "documents" folder in compile/build phase (not via "code on run")?

I have a lot of jpeg+png+html files to add to my app, and of course when i "build" it all my resources files are added/included in myApp mainBundle folder.
I'd like to be able to modify via code, in run time, some of my resources, but:
1) we cannot "write" files via code in run-time in mainBundle
2) we can do it just in "documents" folder (or temp, or...)
3) we can copy files in "Documents" folder just via code in run-time
4) we cannot delete the mainBundle files after coping them in "Documents"
but that means that we will have doubled-sized our app, and in big apps (it's my case) this should be a non-sense, we'll have a lot of big files never used again in the mainBundle...
so i wondered if there was a work-around for this problem (is it just me thinking it's a non-sense?) to add files directly in the "Documents" folder in the "build" phase via xCode, or other similar solutions...
ps
one could be to download all files the first time a user use my app via server/internet directly in "Documents" folder, so my app won't be heavy to download via iTunesStore, but of course this will get a lot of time the first time for end-users, and it could be not well accepted, of course...
Well you can't, since the document directory is created on installing the app. There is no way to do what you want on compile time. Neither you can do it at the install.
Since you needed the file you have to include them in your bundle, i've even included 10MB sqlite database that I copy to to the document direct on first launch. That is just the way it is.
Doesn't work for apps
Copying files to the documents directory during compile time requires you to know that directory in advance. You generally can't know this as the documents directory might not have been created before your app is installed.
Can work for unit tests on the simulator
However, the location of the documents directory depends on the target platform and the kind of bundle you are building. For unit tests based on SenTestingKit executed on the iOS simulator, you can determine the documents directory at compile time by just doing this inside a "Run Script" build phase:
~/Library/Application Support/iPhone\ Simulator/$IPHONEOS_DEPLOYMENT_TARGET/Documents
Note that this really only works for unit test bundles as those are not executed in a dedicated app directory and thus access a "shared" documents directory on the simulator platform.

Write to iPhone file system - Jailbreak/Toolchain

so I am working on a jb app that requires writing to the file system (/var/mobile/Library/Downloads specifically), and I tried hard coding it in like someone recommended but I cant seem to make it work, i know how to do so to the Documents directory in my app but not the file system, any ideas? thank you!
edit 1 - as reference: the way that the Safari DL Plugin does it
try this path
/private/var/mobile/Library/Downloads
You need to check if the directory already exists or not before writing to it. You can use NSFileManager class for file/directory operations. You also need to check for the permissions on that folder, your app if not running as root cannot write to folders which only root has access to.