From f58b563cb65dc0611815f3a5570dd704e61810c3 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Wed, 15 Oct 2014 17:10:35 +0200 Subject: xcodeenv: Reimplement simulator script to work with Xcode 6 --- pkgs/development/mobile/xcodeenv/simulate-app.nix | 45 ++++++++++++++++++----- pkgs/development/mobile/xcodeenv/xcodewrapper.nix | 2 +- 2 files changed, 36 insertions(+), 11 deletions(-) (limited to 'pkgs/development/mobile/xcodeenv') 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" -- cgit v1.2.3