summary refs log tree commit diff
path: root/pkgs/development/mobile/xcodeenv
diff options
context:
space:
mode:
authorSander van der Burg <svanderburg@mgail.com>2014-10-15 17:10:35 +0200
committerSander van der Burg <svanderburg@mgail.com>2014-10-15 17:10:35 +0200
commitf58b563cb65dc0611815f3a5570dd704e61810c3 (patch)
tree5508fe414ea3be8e8a53b0acd0d904b6962dd111 /pkgs/development/mobile/xcodeenv
parent2ffe274486679965f3a608a65453396fd2e0b393 (diff)
downloadnixpkgs-f58b563cb65dc0611815f3a5570dd704e61810c3.tar
nixpkgs-f58b563cb65dc0611815f3a5570dd704e61810c3.tar.gz
nixpkgs-f58b563cb65dc0611815f3a5570dd704e61810c3.tar.bz2
nixpkgs-f58b563cb65dc0611815f3a5570dd704e61810c3.tar.lz
nixpkgs-f58b563cb65dc0611815f3a5570dd704e61810c3.tar.xz
nixpkgs-f58b563cb65dc0611815f3a5570dd704e61810c3.tar.zst
nixpkgs-f58b563cb65dc0611815f3a5570dd704e61810c3.zip
xcodeenv: Reimplement simulator script to work with Xcode 6
Diffstat (limited to 'pkgs/development/mobile/xcodeenv')
-rw-r--r--pkgs/development/mobile/xcodeenv/simulate-app.nix45
-rw-r--r--pkgs/development/mobile/xcodeenv/xcodewrapper.nix2
2 files changed, 36 insertions, 11 deletions
diff --git a/pkgs/development/mobile/xcodeenv/simulate-app.nix b/pkgs/development/mobile/xcodeenv/simulate-app.nix
index c999497d8c0..645bcd69da0 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 4545ea8dae1..4be204d5dc5 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"