How to download app data in Xcode 4.2 - iphone

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"

Related

folder structure in xcode vs folder structure in finder

I have the following folder structure in xcode for a project.
However, I have the above file structure in finder.
Is there any way to reflect the file structure from xcode to finder ?
I recently discovered a Command Line Tool that will do exactly what you need. You can find it here:
https://github.com/venmo/synx
To install the tool, you just need to open the terminal and run the following command (use sudo to run it as a superuser and get permission):
$ sudo gem install synx
Then, just like the instructions on the GitHub webpage above indicate, use the following command to re-organize your folder structure:
$ synx path/to/your/project.xcodeproj
This should do it :).
You should managed it yourself in Finder, then set new Path for folders in Utility View
The "folders" in Xcode are actually groups and not necessarily linked to a folder in Finder.
You need to manage it yourself if you want a mirror in Xcode/Finder.
What you can do is create the folder structure you desire in Finder, then drag each folder into Xcode, this will create references to the folders as groups in Xcode and any files you create in those groups will be saved in the appropriate Finder folders.
You can do this to some extent! There's just one extra step to do every time you create a new group (and this first time you'll have a lot of catching up to do!):
Xcode 3: Whenever you create a group in Xcode, immediately get info on it, and notice the "Path:" setting just below its name. Click "Choose..." and set it to a new folder with the same name.
Xcode 4: Whenever you create a group in Xcode, immediately select it and open the righthand sidebar. Notice the "Path:" setting just below its name. Click the icon next to "None" (what is that, a file in a window?) and set it to a new folder with the same name.
Now, whenever you add files to the group, they'll head to the corresponding folder on disk. Woo!
Hence, I always create folder in Finder and then add that in Xcode.
Check out this article. It might help you organise your project.
http://www.blackdogfoundry.com/blog/xcode4-folder-structure/
After version 9 Xcode (haven't checked previous versions) handles this for you! As long as you create a group and you don't select "New group without folder" Xcode automagically creates a corresponding folder in your project that will be reflected in your project's file structure.

Examine the content of created plist

In my program I store some data in a plist. The plists content changes during user activities. Is there any option to examine the content of such created file in xcode?
If you want to retrieve the plist from a device, you can use Xcode's "Organizer", choose "Devices" tab, and then you can download the data associated with a particular app there:
When you download the xcappdata file, you can control-click on the file and choose "Show Package Contents" to navigate to the various folders in the app's sandbox.
Or if running the app on the simulator, you can navigate to "~/Library/Application Support/iPhone Simulator" and see the files there. If you don't see your "Library" folder, you can execute the following from the Terminal command line:
chflags nohidden ~/Library

Copying non-existent resources during iPhone build

At one point in my iPhone app development, I had 2 rather large video files as resources for use in the app. After some tests, I decided I didn't want them anymore. So I deleted both from the resources folder in xcode - and I selected 'remove and delete selected references.' When I try to build on my iPhone or iPad, it still says "copying file opening.mov to iPhone." And it takes up space in the build.
What is happening? I deleted all references to the file everywhere on my computer, but it still copies the file on my iDevices.
I checked the xcode project folder in finder and it's not there!
You can go to Project->Build Phases->Copy Bundle Resources, chances are those files are still there somehow, delete them if they are.
Additionally as suggested do a product clean.
Go to /Users/your user/Library/Application Support/iPhone Simulator/your version/Applications and delete the folder for your app.
Hint: Library could be a hidden folder. If you not see it use tinker tools to make the folder visible.
Delete the app on your test device.
In xcode go to Build Phases and check if your file is copied to bundle resources. If yes - delete it from there.
Clean your build an run.

Is there a way to view your app's .entitlements file from your app's .ipa archive?

I think there's an issue with my app's .entitlements file when a .ipa is created and so I want to check the Bundle ID of the entitlements file. There's a fairly complicated build script I am using to change some stuff in there before building so I want to see what the final product is. I know that there used to be an Entitlements.plist that I could get off of the ipa but it doesn't seem to be there any longer. Is there any way to access the .entitlements file now?
For those getting here via Google, the Information Apple provides at https://developer.apple.com/library/ios/qa/qa1798/_index.html is a lot more recent.
Specifially, after unzipping the IPA:
Display the entitlements in the app by running:
codesign -d --entitlements :- "Payload/YourApp.app"
and display the provisioning profile by running:
security -D -i "Payload/YourApp.app/embedded.mobileprovision"
Sure, unzip the .ipa file which will create a Payload directory. Inside of the Payload directory is the application package. Right-click the app package in Finder to "Show Package Contents".
Look for the embedded.mobileprovision file which you can open with a text editor or plist editor. Look for the <key>Entitlements</key>

iPhone application, Documents directory on Mac

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 '.*/'