2013-01-07 16:52:42 +01:00
|
|
|
{stdenv, xcodewrapper}:
|
2014-10-15 17:10:35 +02:00
|
|
|
{name, bundleId, app}:
|
2013-01-07 16:52:42 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2013-02-12 11:35:21 +01:00
|
|
|
name = stdenv.lib.replaceChars [" "] [""] name;
|
2013-01-07 16:52:42 +01:00
|
|
|
buildCommand = ''
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p $out/bin
|
2013-01-07 16:52:42 +01:00
|
|
|
cat > $out/bin/run-test-simulator << "EOF"
|
|
|
|
#! ${stdenv.shell} -e
|
2014-10-15 17:10:35 +02: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 16:52:42 +01:00
|
|
|
EOF
|
2014-10-15 17:10:35 +02:00
|
|
|
|
2013-01-07 16:52:42 +01:00
|
|
|
chmod +x $out/bin/run-test-simulator
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
|