Our Flying Friends

Halle's latest posts

Open the Simulator sandbox folder of the app you just built and ran

13 May

Updated for Xcode 6: I now use the following bash one-liner:

open -R `find ~/Library/Developer/CoreSimulator/Devices -type d -depth 5 -name "*.app" -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -1 | cut -f2- -d" "`

Read on for some historical AppleScript which applies to Xcode versions previous to 6.

If you’re interested in this, you might also enjoy checking out OpenEars, Politepix’s free iOS SDK for doing offline speech recognition without using the network, now featuring the ability to generate rules-based recognition grammars dynamically at runtime!

Here’s another Applescript* tool for dealing with the Simulator, since I seem to be on an Applescript/Simulator kick**. Maybe I’m the only one with this problem: a common use of the Simulator for me is testing code that writes out to the Documents folder of the app. And yet, it’s always an unpleasant process to locate the app’s Simulator install folder inside of the Application Support/Simulator folder. It’s not always 100% obvious which SDK folder I ought to be looking in, the containing folder name changes, it’s not self-evidently named, etc. So, I have an Applescript that just finds and opens the Simulator install folder for whatever Simulator app I built and ran last.


Or at least, I had an Applescript, but it was dog-slow. But I recently asked for help on MacScripter here and it’s now optimized into a speed demon thanks to Hank and Stefan. The script, to be entered and saved in your Applescript Editor:

# By StefanK at MacScripter: https://macscripter.net/viewtopic.php?pid=140141

property findtype : quoted form of "kMDItemContentType = \"com.apple.application-bundle\""

set simulatorFolder to POSIX path of (path to application support folder from user domain) & "iPhone Simulator/"
set appFiles to paragraphs of (do shell script "mdfind -onlyin " & quoted form of simulatorFolder & " " & findtype)
if appFiles is not {} then
	set mostRecentApp to item 1 of appFiles
	tell application "Finder" to reveal ((POSIX file mostRecentApp) as alias)
	tell application "Finder" to activate
end if

Of you can just download it as an already-saved app if you prefer (it can still be opened and edited in Applescript Editor).

Put it in the dock and click it when you want to see the install folder. I hope it spares you as much annoyance as it spares me. Tip of the hat to MacScripter and regulus6633 and StefanK.

*”What’s the deal with all the Applescript?” you ask. Look, I just want to be well-practiced when Apple rolls out the Applescript Store at WWDC this year.

**My last AppleScript/Simulator post was linked on Alex Curlyo’s blog and it led to a discussion that raised two even better suggestions for accomplishing the same task which are now part of my standard workflow.

Tags: , , , ,

2 Responses to “Open the Simulator sandbox folder of the app you just built and ran”

  1. sogwiz August 3, 2011 at 9:33 pm #

    Thanks for the useful information. Do you know of a way to use AppleScript to install an app to a device? That is, let’s say you just compiled and built your app using a build script (not necessarily XCode). Now you want a script that takes your built app file and deploys it to a device.
    I’m guessing you’d write some kind of AppleScript to interface with iTunes or the iPhone Configuration Utility. Any suggestions here? Thanks!

  2. Halle August 4, 2011 at 8:36 am #

    Sorry, I don’t know of a way to install an app on a device via AppleScript — good luck!