Blog

iOS: A Quick Script to Retain Your Sanity With CoreSimulator Folders.

Written by Metal Toad Staff | Apr 27, 2015 12:00:00 AM

Note: This is outdated. See our update for Xcode 7

When Xcode 6 was released this past fall, Apple switched from a relatively sane folder structure to a completely opaque GUID based structure. For debugging purposes, it’s often nice to be able to browse your app’s file structure in the simulator without resorting to NSLogging a device ID.

We wrote a quick script to eliminate that headache. It grabs the GUIDs for all CoreSimulator devices from the `instruments` command line utility, and makes nicely named symlinks in your Documents directory. When Apple inevitably adds or removes simulators, you can simply run the script again to regenerate the links.

Here’s the script

#!/bin/sh
 
if [ -d $HOME/Documents/iOS\ Simulator\ Symlinks ]; then
  rm -rf ~/Documents/iOS\ Simulator\ Symlinks
fi
 
mkdir ~/Documents/iOS\ Simulator\ Symlinks
 
xcrun instruments -s | grep 'Simulator' | while read -r line ; do
    left=`echo $line | sed -n 's/ \[.*\]//p'`
    left=`echo $left | sed -n 's/ /\\ /pg'`
    right=`echo $line | sed -n 's/.*\[\(.*\)\]/\1/p'`
    ln -s ~/Library/Developer/CoreSimulator/Devices/"$right" ~/Documents/iOS\ Simulator\ Symlinks/"$left"
done