github.com/status-im/status-go@v1.1.0/nix/pkgs/xcodeenv/compose-xcodewrapper.nix (about) 1 { stdenv, lib, writeShellScriptBin }: 2 { versions ? [ "14.3" "15.1" "15.2" "15.3" ] 3 , xcodeBaseDir ? "/Applications/Xcode.app" }: 4 5 assert stdenv.isDarwin; 6 7 let 8 xcodebuildPath = "${xcodeBaseDir}/Contents/Developer/usr/bin/xcodebuild"; 9 10 xcodebuildWrapper = writeShellScriptBin "xcodebuild" '' 11 currentVer="$(${xcodebuildPath} -version | awk 'NR==1{print $2}')" 12 wrapperVers=(${lib.concatStringsSep " " versions}) 13 14 for ver in "''${wrapperVers[@]}"; do 15 if [[ "$currentVer" == "$ver" ]]; then 16 # here exec replaces the shell without creating a new process 17 # https://www.gnu.org/software/bash/manual/bash.html#index-exec 18 exec "${xcodebuildPath}" "$@" 19 fi 20 done 21 22 echo "The installed Xcode version ($currentVer) does not match any of the allowed versions: ${lib.concatStringsSep ", " versions}" 23 echo "Please update your local Xcode installation to match one of the allowed versions" 24 exit 1 25 ''; 26 in 27 stdenv.mkDerivation { 28 pname = "xcode-wrapper-plus"; 29 version = lib.concatStringsSep "," versions; 30 # Fails in sandbox. Use `--option sandbox relaxed` or `--option sandbox false`. 31 __noChroot = true; 32 buildCommand = '' 33 mkdir -p $out/bin 34 cd $out/bin 35 ln -s "${xcodebuildWrapper}/bin/xcode-select" 36 ln -s /usr/bin/security 37 ln -s /usr/bin/codesign 38 ln -s /usr/bin/xcrun 39 ln -s /usr/bin/plutil 40 ln -s /usr/bin/clang 41 ln -s /usr/bin/lipo 42 ln -s /usr/bin/file 43 ln -s /usr/bin/rev 44 ln -s "${xcodebuildWrapper}/bin/xcodebuild" 45 ln -s "${xcodeBaseDir}/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator" 46 47 cd .. 48 ln -s "${xcodeBaseDir}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs" 49 ''; 50 }