summary refs log tree commit diff
path: root/pkgs/development/mobile/xcodeenv/simulate-app.nix
blob: 03ed90c40d5bf14042350a0bd84a6c33cf40c8e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{stdenv, xcodewrapper}:
{ name, appName ? null, app
, device ? "iPhone", baseDir ? ""
, sdkRoot ? "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs"
, sdkVersion ? "6.1"
}:

let
  _appName = if appName == null then name else appName;
in
stdenv.mkDerivation {
  name = stdenv.lib.replaceChars [" "] [""] name;
  buildCommand = ''
    ensureDir $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 '${sdkRoot}/iPhoneSimulator${sdkVersion}.sdk'
    EOF
    chmod +x $out/bin/run-test-simulator
  '';
}