James's Twisted Ape

Thoughts, code and anything else.

Xcode 6 Simulator Folders

In the latest version of Xcode finding your files on an iOS simulator has become a lot harder. The file structure has changed presumably to help with sharing data between applications. As a result I have written a short bash script to help you find your applications folders on the iOS simulator. You can download it here.

I’ve added this program to my PATH so I can run it from anywhere in Terminal.

If you run it with no commands it will print some help, and a list of simulator folders found on your machine:

Jamess-MacBook-Air:~ james$ simulatorAppFolders
simulatorAppFolders [-?sap]
-? show help, and prints simulators currently installed
-s <device name> prints the folder of this simulator without -i will choose the first matching folder
-i <iOS version> finds the folder matching the iOS version as well as the simulator name
-p Used with -s to print the installed apps on a simulator
-a <application name> Used with -s to print the application and data folder of the application

simulator names:
iOS-8-0 iPad 2
iOS-8-0 iPhone 6
iOS-8-0 iPhone 6 Plus
iOS-7-1 iPad 2
iOS-7-1 iPhone 5s
iOS-8-0 iPad Air
iOS-8-0 iPad Retina
iOS-7-1 iPhone 4s
iOS-8-0 iPhone 5s
iOS-8-0 iPhone 4s
iOS-7-1 iPad Air
iOS-7-1 iPhone 5
iOS-8-0 Resizable iPhone
iOS-7-1 iPad Retina
iOS-8-0 Resizable iPad
iOS-8-0 iPhone 5

With the -s command you can give it a device name and it will print you the folder for the given device (don’t forget to quote the device name):

Jamess-MacBook-Air:~ james$ simulatorAppFolders -s "iPad Air"
/Users/james/Library/Developer/CoreSimulator/Devices/6A9DEE93-FAEF-4BF4-9989-BC14CD38AEA0

If there are multiple devices with this name (say one with iOS 7 and one with iOS 8) then you can add the -i command to specify the iOS version:

Jamess-MacBook-Air:_posts james$ simulatorAppFolders -s "iPad Air" -i iOS-8-0
/Users/james/Library/Developer/CoreSimulator/Devices/6A9DEE93-FAEF-4BF4-9989-BC14CD38AEA0

If you add the -p command it will print the applications that you currently have installed:

Jamess-MacBook-Air:_posts james$ simulatorAppFolders -s "iPad Air" -i iOS-8-0 -p
PagingScrollView
CollectionViewSource

Finally if you use replace the -p command with the -a command the script will print the folders associated with your app:

Jamess-MacBook-Air:_posts james$ simulatorAppFolders -s "iPad Air" -i iOS-8-0 -a PagingScrollView
App folder = /Users/james/Library/Developer/CoreSimulator/Devices/6A9DEE93-FAEF-4BF4-9989-BC14CD38AEA0/data/Containers/Bundle/Application/8F64CD7F-A227-43D6-98AC-41D3919827CB
dataFolder = /Users/james/Library/Developer/CoreSimulator/Devices/6A9DEE93-FAEF-4BF4-9989-BC14CD38AEA0/data/Containers/Data/Application/96C40A21-5A5C-4399-839C-B155B8A72932

Update

Thanks to Derek Clarkson at odecee who pointed out that it’s also useful to be able to search on the device type as well as the device name and amended the script to be able to do this using a -d option. If you re-download the script you can do this.

I’ve also written another script which makes makes a folder in your home area called iOS_SIMULATORS (if you already have a folder called this it will delete it), in this folder there is a directory structure where you can easily find your applications (they’re sensibly named!):

You can us a -f option on this script and it will collapse/remove useless folders, so running this on the same system as the original command you get this:

You can download this script here.

Update

There is a git repo with both of the scripts here.