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
|
2016-01-07 15:43:17 +01:00
|
|
|
open -a "$(readlink "${xcodewrapper}/bin/Simulator")" --args -CurrentDeviceUDID $udid
|
2014-10-15 17:10:35 +02:00
|
|
|
|
|
|
|
# Copy the app and restore the write permissions
|
|
|
|
appTmpDir=$(mktemp -d -t appTmpDir)
|
2017-01-25 16:56:55 +01:00
|
|
|
cp -r "$(echo ${app}/*.app)" "$appTmpDir"
|
2014-10-15 17:10:35 +02:00
|
|
|
chmod -R 755 "$(echo $appTmpDir/*.app)"
|
|
|
|
|
|
|
|
# Wait for the simulator to start
|
|
|
|
echo "Press enter when the simulator is started..."
|
|
|
|
read
|
|
|
|
|
|
|
|
# Install the app
|
2017-01-25 16:56:55 +01:00
|
|
|
xcrun simctl install "$udid" "$(echo $appTmpDir/*.app)"
|
2014-10-15 17:10:35 +02:00
|
|
|
|
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
}
|