diff --git a/pkgs/development/mobile/xcodeenv/simulate-app.nix b/pkgs/development/mobile/xcodeenv/simulate-app.nix index c999497d8c09..645bcd69da0c 100644 --- a/pkgs/development/mobile/xcodeenv/simulate-app.nix +++ b/pkgs/development/mobile/xcodeenv/simulate-app.nix @@ -1,22 +1,47 @@ {stdenv, xcodewrapper}: -{ name, appName ? null, app -, device ? "iPhone", baseDir ? "" -, sdkVersion ? "7.0" -}: +{name, bundleId, app}: -let - _appName = if appName == null then name else appName; -in stdenv.mkDerivation { name = stdenv.lib.replaceChars [" "] [""] name; buildCommand = '' mkdir -p $out/bin cat > $out/bin/run-test-simulator << "EOF" #! ${stdenv.shell} -e - - cd "${app}/${baseDir}/${_appName}.app" - "$(readlink "${xcodewrapper}/bin/iPhone Simulator")" -SimulateApplication './${_appName}' -SimulateDevice '${device}' -currentSDKRoot "$(readlink "${xcodewrapper}/SDKs")/iPhoneSimulator${sdkVersion}.sdk" + + 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}" EOF + chmod +x $out/bin/run-test-simulator ''; } diff --git a/pkgs/development/mobile/xcodeenv/xcodewrapper.nix b/pkgs/development/mobile/xcodeenv/xcodewrapper.nix index 4545ea8dae15..4be204d5dc52 100644 --- a/pkgs/development/mobile/xcodeenv/xcodewrapper.nix +++ b/pkgs/development/mobile/xcodeenv/xcodewrapper.nix @@ -10,7 +10,7 @@ stdenv.mkDerivation { ln -s /usr/bin/codesign ln -s "${xcodeBaseDir}/Contents/Developer/usr/bin/xcodebuild" ln -s "${xcodeBaseDir}/Contents/Developer/usr/bin/xcrun" - ln -s "${xcodeBaseDir}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator" + ln -s "${xcodeBaseDir}/Contents/Developer/Applications/iOS Simulator.app/Contents/MacOS/iOS Simulator" cd .. ln -s "${xcodeBaseDir}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs"