at v192 1.3 kB view raw
1{stdenv, xcodewrapper}: 2{name, bundleId, app}: 3 4stdenv.mkDerivation { 5 name = stdenv.lib.replaceChars [" "] [""] name; 6 buildCommand = '' 7 mkdir -p $out/bin 8 cat > $out/bin/run-test-simulator << "EOF" 9 #! ${stdenv.shell} -e 10 11 if [ "$1" = "" ] 12 then 13 # Show the user the possibile UDIDs and let him pick one, if none is provided as a command-line parameter 14 xcrun simctl list 15 16 echo "Please provide a UDID of a simulator:" 17 read udid 18 else 19 # If a parameter has been provided, consider that a device UDID an use that 20 udid="$1" 21 fi 22 23 # Open the simulator instance 24 open -a "$(readlink "${xcodewrapper}/bin/iOS Simulator")" --args -CurrentDeviceUDID $udid 25 26 # Copy the app and restore the write permissions 27 appTmpDir=$(mktemp -d -t appTmpDir) 28 cp -r "$(echo ${app}/*.app)" $appTmpDir 29 chmod -R 755 "$(echo $appTmpDir/*.app)" 30 31 # Wait for the simulator to start 32 echo "Press enter when the simulator is started..." 33 read 34 35 # Install the app 36 xcrun simctl install $udid "$(echo $appTmpDir/*.app)" 37 38 # Remove the app tempdir 39 rm -Rf $appTmpDir 40 41 # Launch the app in the simulator 42 xcrun simctl launch $udid "${bundleId}" 43 EOF 44 45 chmod +x $out/bin/run-test-simulator 46 ''; 47} 48