2013-01-07 15:52:42 +00:00
|
|
|
{stdenv, xcodewrapper}:
|
2014-10-15 16:10:35 +01:00
|
|
|
{name, bundleId, app}:
|
2013-01-07 15:52:42 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2013-02-12 10:35:21 +00:00
|
|
|
name = stdenv.lib.replaceChars [" "] [""] name;
|
2013-01-07 15:52:42 +00:00
|
|
|
buildCommand = ''
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p $out/bin
|
2013-01-07 15:52:42 +00:00
|
|
|
cat > $out/bin/run-test-simulator << "EOF"
|
|
|
|
#! ${stdenv.shell} -e
|
2014-10-15 16:10:35 +01:00
|
|
|
|
|
|
|
if [ "$1" = "" ]
|
|
|
|
then
|
|
|
|
# Show the user the possibile UDIDs and let him pick one, if none is provided as a command-line parameter
|
|
|
|
xcrun simctl list
|
|
|
|
|
|
|
|
echo "Please provide a UDID of a simulator:"
|
|
|
|
read udid
|
|
|
|
else
|
|
|
|
# If a parameter has been provided, consider that a device UDID an use that
|
|
|
|
udid="$1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Open the simulator instance
|
|
|
|
open -a "$(readlink "${xcodewrapper}/bin/iOS Simulator")" --args -CurrentDeviceUDID $udid
|
|
|
|
|
|
|
|
# Copy the app and restore the write permissions
|
|
|
|
appTmpDir=$(mktemp -d -t appTmpDir)
|
|
|
|
cp -r "$(echo ${app}/*.app)" $appTmpDir
|
|
|
|
chmod -R 755 "$(echo $appTmpDir/*.app)"
|
|
|
|
|
|
|
|
# Wait for the simulator to start
|
|
|
|
echo "Press enter when the simulator is started..."
|
|
|
|
read
|
|
|
|
|
|
|
|
# Install the app
|
|
|
|
xcrun simctl install $udid "$(echo $appTmpDir/*.app)"
|
|
|
|
|
|
|
|
# Remove the app tempdir
|
|
|
|
rm -Rf $appTmpDir
|
|
|
|
|
|
|
|
# Launch the app in the simulator
|
|
|
|
xcrun simctl launch $udid "${bundleId}"
|
2013-01-07 15:52:42 +00:00
|
|
|
EOF
|
2014-10-15 16:10:35 +01:00
|
|
|
|
2013-01-07 15:52:42 +00:00
|
|
|
chmod +x $out/bin/run-test-simulator
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
|