nix: allow XCode versions 11.5 and higher

This is kinda hacky, but is simple enough since the version check uses grep.

For details see:
https://github.com/status-im/nixpkgs/blob/status-mods/pkgs/development/mobile/xcodeenv/compose-xcodewrapper.nix

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-07-30 17:05:47 +02:00
parent 8b99e992ad
commit 933c0f8f8c
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
3 changed files with 47 additions and 3 deletions

View File

@ -32,9 +32,12 @@ in {
gradlePropParser = callPackage ./tools/gradlePropParser.nix { }; gradlePropParser = callPackage ./tools/gradlePropParser.nix { };
# Package version adjustments # Package version adjustments
xcodeWrapper = super.xcodeenv.composeXcodeWrapper { version = "11.5"; };
openjdk = super.pkgs.openjdk8_headless;
nodejs = super.pkgs.nodejs-12_x; nodejs = super.pkgs.nodejs-12_x;
openjdk = super.pkgs.openjdk8_headless;
xcodeWrapper = callPackage ./pkgs/xcodeenv/compose-xcodewrapper.nix { } {
version = "11.5";
allowHigher = true;
};
# Android environement # Android environement
androidEnvCustom = callPackage ./pkgs/android-sdk { }; androidEnvCustom = callPackage ./pkgs/android-sdk { };

View File

@ -0,0 +1,41 @@
{ stdenv }:
{ version ? "11.1"
, allowHigher ? false
, xcodeBaseDir ? "/Applications/Xcode.app" }:
assert stdenv.isDarwin;
stdenv.mkDerivation {
name = "xcode-wrapper-${version}${if allowHigher then "-plus" else ""}";
buildCommand = ''
mkdir -p $out/bin
cd $out/bin
ln -s /usr/bin/xcode-select
ln -s /usr/bin/security
ln -s /usr/bin/codesign
ln -s /usr/bin/xcrun
ln -s /usr/bin/plutil
ln -s /usr/bin/clang
ln -s /usr/bin/lipo
ln -s /usr/bin/file
ln -s /usr/bin/rev
ln -s "${xcodeBaseDir}/Contents/Developer/usr/bin/xcodebuild"
ln -s "${xcodeBaseDir}/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator"
cd ..
ln -s "${xcodeBaseDir}/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs"
# Check if we have the xcodebuild version that we want
currVer=$($out/bin/xcodebuild -version)
${if allowHigher then ''
if [ -z "$(printf '%s\n' "${version}" "$currVer" | sort -V | head -n1)""" != "${version}" ]
'' else ''
if [ -z "$(echo $currVer | grep -x 'Xcode ${version}')" ]
''}
then
echo "We require xcodebuild version${if allowHigher then " or higher" else ""}: ${version}"
exit 1
fi
'';
}

View File

@ -13,7 +13,7 @@ let
xcode=0 xcode=0
iPhoneSDK=0 iPhoneSDK=0
export PATH=${xcodeWrapper}/bin:$PATH export PATH=${xcodeWrapper}/bin:$PATH
[[ "$(xcrun xcodebuild -version)" == "Xcode ${_xcodeVersion}"* ]] && xcode=1 xcrun xcodebuild -version && xcode=1
[ $xcode -eq 1 ] && xcrun --sdk iphoneos --show-sdk-version > /dev/null && iPhoneSDK=1 [ $xcode -eq 1 ] && xcrun --sdk iphoneos --show-sdk-version > /dev/null && iPhoneSDK=1
''; '';
_xcodeToolReportScript = tool-name: ''[ $SELECTED -eq 0 ] && echo -e "${NC}- ${RED}[ ] ${tool-name}" || echo -e "${NC}- ${GREEN}[] ${tool-name}${RED}"''; _xcodeToolReportScript = tool-name: ''[ $SELECTED -eq 0 ] && echo -e "${NC}- ${RED}[ ] ${tool-name}" || echo -e "${NC}- ${GREEN}[] ${tool-name}${RED}"'';