Tag Archives: iOS simulator

Where is the Documents Directory for the iOS 8 Simulator

xcode-6-iconYou may have noticed that the iPhone Simulator has changed with Xcode 6, and with it – of course – the path to your simulated apps’ Documents Directory. At times we may need to take a look at it.

Finding that path is not as easy as it was once, namely Library/Application Support/iPhone Simulator/7.1/Applications/ followed by a cryptic number representing your app.

As of Xcode 6 and iOS 8 you’ll find it here:
Library/Developer/CoreSimulator/Devices/cryptic number/data/Containers/Data/Application/cryptic number

It was fairly easy to spot that one cryptic number before – but now you have to play the guessing game twice. This can become tedious, especially if you’re testing several user accounts and therefore accumulate a vast array of cryptic numbers.

Here’s a great way of writing out the Documents directory as a log message:

Add this to a viewDidLoad or applicationDidFinishLaunching method and you’re golden. If you’re running the app on a Simulator, this will write out the correct location for the current app.

Thanks to Ian for this tip!

Worse yet: every time you run the app, the folder location changes!

Thanks to Keith for bringing this up:

The location of this folder changes every time you run the app on the Simulator. Only Apple know why.

The good news is that once you open a Finder window and navigate to your project, Finder will update the location automatically as long as you don’t close that window.

At least this way you don’t have to play detective every time you launch the app from Xcode.

Complex and Cumbersome Method

Originally I did the following to detect where they Documents directory was:

  • add an identifiable file to your bundle (for example, a picture)
  • copy that file into your app’s Documents directory, using a name you can remember
  • run the app on the simulator
  • search for the file on the command line

Here’s how I did this:

This will copy a hypothetical file “swift-icon.png” from the Main Bundle to the simulator’s Documents directory as “WhereAreYouHiding-4s”. I’m adding 4s here because I’d like to find that particular simulator’s directory – which is likely different for the other models.

Searching for this file in Finder won’t yield any results – because a standard user does not have the permissions to read the simulator’s directory. Hence we’ll open Terminal and look for our file with root privileges:

This will prompt you to type in your Administrator password for your Mac and will go to work. The find command will look through every file on your hard disk and should only come up with very few results. Once you’ve found something resembling that cryptic path I’ve mentioned above, you can stop the search with CTRL+C.

How to build apps for iOS 5 with Xcode 5.1

Ios-5.1-640x480Recently I get the feeling that iOS 5 is an indiscretion Apple would rather forget. Never mind that the iPad 1 is still around and really not a bad device. Besides, iOS 5 paved the way for iCloud.

I like to support iOS 5 if I can – but with the latest Xcode 5.1 release it’s getting tougher. It is still possible, even though we no longer have access to the iOS 5 simulator. But with a real device attached you can still support and debug apps on iOS 5.

I’ve picked up a few tips and tricks – and here’s what you can do with Xcode 5.1 to make apps run on again under iOS 5:

Change the Deployment Target

Notice that Xcode no longer brings up iOS 5 from the deployment target menu. No problem, just type in what you want. Choose 5.1.1 (manually) to support both 64 and 32 bit binaries – no need to change the default build architecture this way.

Screen Shot 2014-04-04 at 11.58.18


The next big issue you’ll face are storyboards. Introduced in iOS 5, they seemingly no longer work when deployed from Xcode 5.1. There are two problems here.

One of them is Auto Layout. iOS 5 doesn’t understand it, I personally hate it – and I’m happy to say it’s easy to switch off. Select your storyboard, check out the file inspector and just untick the Auto Layout Box:

Screen Shot 2014-04-04 at 12.03.11

But even without Auto Layout, iOS 5 still won’t run an app with such a storyboard and will instead crash when deployed. The error message is something like “Could not find a storyboard named ‘Main’ in Bundle”.

Let’s fix that next.

At first this looks like a problem with an unlinked file, as if the storyboard is not added to the bundle at compile time. And sure enough, if you head over to Build Phases – Compile Sources, you don’t see your storyboard added here, as you once did:

Screen Shot 2014-04-04 at 12.13.52

The reason for this is the way Xcode now handles translations. Back in the day you had a single storyboard file, and if you wanted to translate it there was a lot of confusion in regards to base translations. You had to add those manually, then add an “English” version – it was messy.

Back then you needed a different storyboard file for every language, but since iOS 6 this was replaced with an easier system to manage: a single storyboard file, and additional strings files which would only contain the words that needed to be replaced (rather than all the XML data and positions for your elements). The previous system made it a tad cumbersome because moving a single button five pixels to the left isn’t easy when you have to do it across every language you supported.

But if you don’t care about translations, or you’re happy to do the extra work per storyboard, then here’s how to make the setup iOS 5 compatible again:

If you look at your storyboard in the file inspector (the previous screenshot), you’ll notice that you have “Base” and “English” as a localizable strings file under Translations. In fact, Xcode even compiles with a warning that “Internationlization is not available when compiling for targets before iOS 6.0”.

Simply untick “Base” and Xcode will present you with a dialogue box explaining that you’re now merging the English strings file into a storyboard file. Agree to it and your app will run fine on iOS 5 devices.

Screen Shot 2014-04-04 at 12.21.11

Core Data Model Files

The last big hurdle we may face is the way Xcode now creates Core Data Model files. Xcode may give an error such as “there was no MOMD file, or the file is nil” (in its own colourful words).

Here’s why: Back in iOS 5 days a .xcdatamodel file was a single file, turned into a .momd file at compile time. If you wanted to add a new version, this file would be put into a Bundle or Package, containing additional versions, as well as an XML file.

With Xcode 5 you get this package even if you only have a single model version – noticeable by the ending of your file .xcdatamodeld (the d at the end gives it away).

The solution here is to show the file in Finder, right-click on it and select “show package contents”. You’ll see your old favourite .xcdatamodel file (without the d at the end). Copy it to your Desktop, then drag it into Xcode (or choose “Add Files To Project”). Build again and the error message is gone!

Note that this problem may or may not happen in your Core Data project – I’ve had a 50% failure rate here.


The iOS 5 Simulator

You may have heard the shocking news: the iOS 5 simulator is no longer welcome on Mac OSX 10.9.x Mavericks. I believe it has to do with the kernel which is incompatible with some routines that used to power it.

But… if you still have access to Mountain Lion 10.8.x you’re in luck: Xcode 5.0 still has the iOS 5 simulator as a download, even though you can no longer deploy apps from Xcode to this version. With a small hack though we CAN still run an app on it, just to see if it works.

This approach is no good for debugging though because you don’t receive error messages in Xcode. But for completion I thought I’d mention how to at least test your app on the simulator this way.

Try this: deploy your iOS 5 compatible app on the iOS 6 simulator. Stop it in Xcode. Then back in the simulator, head over to Hardware – Device – pick a model – pick an iOS Version. Behold: you can still select iOS 5.1.

Do that and the simulator will switch. Check it out on the device in Settings – General – About:

Screen Shot 2014-04-04 at 13.00.19

Tears of joy! Now copy your deployed app manually to the iOS 5 simulator: Open a Finder Window and head over to Library/Application Support/iPhone Simulator/iOS6.1/Applications and find your app in there. It’s a cryptic folder name. Copy the entire folder over to the Applications folder in your iOS 5.1 directory.

Restart the simulator and find your app deployed and ready to rock.

Long live iOS 5 (before iOS 8 will make it impossible for us).

How to access the iPhone Simulator Directory Structure

You can see the full directory under

~Library/Application Support/iPhone Simulator

You’ll be presented with a list of iOS Versions, each of which has several folders to explore. To access data that your apps have written, head over to Applications and see a list of cryptic folders, each one corresponding to one of your apps. In each you’ll find your BundleID.app, indicating which folder belongs to which app.

The Documents folder for example would contain all files that your app has saved to its local Document folder.

Library only comes up in finder by holding down the Option key, then clicking Go from the top menu.