Archive for the ‘Uncategorized’ Category

iOS Simulator and Documents folder

Sunday, August 4th, 2013

Note: This only applies to Xcode 5 and earlier. Xcode 6 rather radically changed the location of the app and its associated data folders.

This is geared to the iOS developers or project managers who might be testing builds with the simulator out there…

Recently, my client wanted to check out wow their currently shipping app would look under Apple’s new iOS 7. Since they did not have iOS 7 installed on any of their testing iPads, they wanted to run the latest code base under the simulator. Their app requires some files in the Documents directory to be at useful, so the question of how to populate it with test data came up. Here is the skinny:

Overview

When you are developing an application for iOS, I would guess that a majority of the time (except in certain situations) you will be relying on the iOS Simulator (it is actually named “iPhone Simulator”, but it covers all the iDevices, so whatever). If for no other reason than the code-compile-debug cycle is much faster. But what if your application works with external files stored and transferred in and out of the Documents directory?

From here on out, we are going to assume a bit of familiarity with Terminal.app. If you are a developer and don’t have experience with Apple’s command line terminal application, we keep it fairly simple, but you really should become familiar with it. Please launch it now. You will find it in /Applications/Utilities/.

Find The Way

So, when Xcode runs your application in the simulator, where does it live? Here:

~/Library/Application Support/iPhone Simulator/<iOS version>/Applications/

Where <iOS version> might be “6.1” or some what ever (well pretend at this date and time we are referring to 6.1, but it would be the same with any version). If we get a directory listing (ls command), we should see something like:

Screen Shot 2013-07-26 at 1.25.54 PM

Here we see 7 different entries, each corresponding to a different application (your listing may have more or less, depending on how many different projects you have going at one time). When the application is launched in the Simulator for the first time (or after a “Reset Contents and Settings…” from within the simulator) Xcode creates and associates an Unique IDentifier (erstwhile known as UID) with which to name the directory for the application bundle and to track the application from within the debugger.

As you might expect, this makes it slightly challenging to find your app. Sometimes, using the ls -l command will give us the additional information we need (namely, date of the creation for the directory), from which we can determine our desired directory.

Screen Shot 2013-08-04 at 7.02.44 PM

Otherwise, we can do:

ls ~/Library/Application Support/iPhone Simulator/6.1/Applications/*

and examine the results to see which contains our application (looking for MyApp.app). You should see each of the above directories (with UID naming) plus their contents listed beneath each.

Screen Shot 2013-08-04 at 7.03.56 PM

Copying

OK, so now we know our path to our target iOS application. From here on out we’ll use 05EF4BB0-A995-99C1-067752EAD15B as our example UID. The path to this applications’s Documents directory will appear as such:

~/Library/Application Support/iPhone Simulator/6.1/Applications/05EF4BB0-A995-99C1-067752EAD15B/Documents/

Now we’ll employ the services of the Unix command cp (for copy) in the Terminal:
cp -v /path/to/file or files/we/want/copied/* ~/Library/Application Support/iPhone Simulator/6.1/Applications/05EF4BB0-A995-99C1-067752EAD15B/Documents/

Translated this is telling the system: copy all the files in the source directory to our simulator app documents directory. The ‘-v” tells cp to report each file copied, so you can leave this option off if you like.

If you prefer to use the OS X Finder to drag-and-drop copy files, then simply issue the system command

open ~/Library/Application Support/iPhone Simulator/6.1/Applications/05EF4BB0-A995-99C1-067752EAD15B/Documents/

And a new window will be opened with connected to the Documents directory.

I hope this helps.

I need to…

Monday, October 18th, 2010

…write more often.

Um…

“Wooly Tasks – Universal Edition” for iPad and iPhone now available

Friday, April 2nd, 2010

Just in time for the launch of the iPad to  consumers in the United States on April 3rd. It’ll be exciting to finally get my hands on the real hardware. It was quite the challenge relying only on the software emulator to do all the development. This is an “universal binary” application, meaning anyone who purchases it can install it both on their iPhone as well as their iPad. I also made significant enhancements to the iPhone side of the application in terms of UI and fixes as well that will show up in the upcoming free iPhone version update.

Find the “Wooly Tasks – Universal Edition” here: http://bit.ly/bGGJNt

First Post!

Tuesday, February 9th, 2010

Welcome! This is the new home of the Wooly Blog. This is the final step of migrating the site to a permanent  home at our new web hosting service.

I may or may not migrate past blog posts from the old site over. Most of it is irrelevant now, but might hold some historical significance. Or not.

May I finally rest now?