When iOS Simulator Apps Go AWOL
I’ve just finished work on version 2.0 of runsim
, a small shell script
that installs and runs apps in the iOS Simulator. For this version I
added the ability to start apps in the simulator automatically from the
command line. I also separated out the different functions, so you can
install, uninstall, list, and run apps as separate operations.
You can read the full details on Run iOS Simulator from the Command Line.
You can also download runsim
from the following link:
Before using it, however, I suggest you read the full description linked above. There are some complexities in using the automatic start-up facility that you want to understand beforehand.
The new automatic start-up uses instruments
, the command-line version
of the Xcode Instruments tool. While getting it working I had one
persistent problem: Instruments kept reporting that the monitored app
had gone AWOL. For the benefit of other folks working from the command
line, I’ll show how to elicit this legendary error and what I did to
correct it.
To keep the example simple, I’ll use Psi
, an iOS app I wrote to be be
as small as possible and to require no supporting files. (Get the
source from Tiny iOS App in One Source File.)
Every app in the Apple universe has an Info.plist
file that describes
its basic attributes. The core of the AWOL app problem is that Xcode has
begun to add internal attributes to this file behind the scenes. You can
see why Apple would do things this way, but it makes it a little more
difficult for “enthusiasts” to do new things with the tools.
Here is an Info.plist
file for Psi
as it is presented to users of
Xcode:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>Psi</string>
<key>CFBundleExecutable</key>
<string>Psi</string>
<key>CFBundleIconFile</key>
<string>Icon.png</string>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Icon.png</string>
</array>
</dict>
</dict>
<key>CFBundleIdentifier</key>
<string>com.psellos.Psi</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Psi</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0.1</string>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>
<key>LSRequiresIPhoneOS</key>
<true/>
</dict>
</plist>
If you try to start up Psi
with this exact Info.plist
, however,
instruments
reports that the app has gone AWOL:
$ PSID="$HOME/Library/Application Support/iPhone Simulator/6.0/Applications/72002825-3566-4EF2-B87B-872836AD29C6/Psi.app"
$ TRC=/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate
$ instruments instruments -t "$TRC" "$PSID"
2012-11-15 12:32:51.586 instruments[56628:1207] Automation Instrument ran into an exception while trying to run the script. UIATargetHasGoneAWOLException
2012-11-15 20:32:51 +0000 Fail: An error occurred while trying to run the script.
If you let Xcode install the app, it modifies Info.plist
internally to
include the following extra attributes:
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneSimulator</string>
</array>
<key>DTPlatformName</key>
<string>iphonesimulator</string>
<key>DTSDKName</key>
<string>iphonesimulator6.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
</array>
In essence, these are device attributes for the iOS Simulator’s iPhone
simulation. If you add these attributes to the Info.plist
file,
instruments
runs as expected. It starts up the iPhone Simulator and
then starts up Psi
in the simulator.
Inside runsim
2.0 there’s a little Python script that adds these
attributes to an Info.plist
file. If you’re encountering the AWOL
problem, maybe this little script will help. (You can download runsum
from the link above.)
If you have any comments, corrections, or suggestions, leave them below or email me at jeffsco@psellos.com.
Posted by: Jeffrey