xcodeenv: enable Xcode 10.1 support

This commit is contained in:
Sander van der Burg 2019-02-04 22:43:48 +01:00
parent 8626808c72
commit 9edc2d4dbb
2 changed files with 16 additions and 7 deletions

View File

@ -1,7 +1,7 @@
{stdenv, composeXcodeWrapper}: {stdenv, composeXcodeWrapper}:
{ name { name
, src , src
, sdkVersion ? "11.3" , sdkVersion ? "12.1"
, target ? null , target ? null
, configuration ? null , configuration ? null
, scheme ? null , scheme ? null
@ -11,6 +11,7 @@
, certificateFile ? null , certificateFile ? null
, certificatePassword ? null , certificatePassword ? null
, provisioningProfile ? null , provisioningProfile ? null
, codeSignIdentity ? null
, signMethod ? null , signMethod ? null
, generateIPA ? false , generateIPA ? false
, generateXCArchive ? false , generateXCArchive ? false
@ -21,7 +22,7 @@
, ... , ...
}@args: }@args:
assert release -> certificateFile != null && certificatePassword != null && provisioningProfile != null && signMethod != null; assert release -> certificateFile != null && certificatePassword != null && provisioningProfile != null && signMethod != null && codeSignIdentity != null;
assert enableWirelessDistribution -> installURL != null && bundleId != null && appVersion != null; assert enableWirelessDistribution -> installURL != null && bundleId != null && appVersion != null;
let let
@ -53,8 +54,11 @@ let
in in
stdenv.mkDerivation ({ stdenv.mkDerivation ({
name = stdenv.lib.replaceChars [" "] [""] name; # iOS app names can contain spaces, but in the Nix store this is not allowed name = stdenv.lib.replaceChars [" "] [""] name; # iOS app names can contain spaces, but in the Nix store this is not allowed
buildInputs = [ xcodewrapper ];
buildPhase = '' buildPhase = ''
# Be sure that the Xcode wrapper has priority over everything else.
# When using buildInputs this does not seem to be the case.
export PATH=${xcodewrapper}/bin:$PATH
${stdenv.lib.optionalString release '' ${stdenv.lib.optionalString release ''
export HOME=/Users/$(whoami) export HOME=/Users/$(whoami)
keychainName="$(basename $out)" keychainName="$(basename $out)"
@ -85,9 +89,9 @@ stdenv.mkDerivation ({
''} ''}
# Do the building # Do the building
export LD=clang # To avoid problem with -isysroot parameter that is unrecognized by the stock ld. Comparison with an impure build shows that it uses clang instead. Ugly, but it works export LD=/usr/bin/clang # To avoid problem with -isysroot parameter that is unrecognized by the stock ld. Comparison with an impure build shows that it uses clang instead. Ugly, but it works
xcodebuild -target ${_target} -configuration ${_configuration} ${stdenv.lib.optionalString (scheme != null) "-scheme ${scheme}"} -sdk ${_sdk} TARGETED_DEVICE_FAMILY="1, 2" ONLY_ACTIVE_ARCH=NO CONFIGURATION_TEMP_DIR=$TMPDIR CONFIGURATION_BUILD_DIR=$out ${if generateIPA || generateXCArchive then "-archivePath \"${name}.xcarchive\" archive" else ""} ${if release then ''PROVISIONING_PROFILE=$PROVISIONING_PROFILE OTHER_CODE_SIGN_FLAGS="--keychain $HOME/Library/Keychains/$keychainName-db"'' else ""} ${xcodeFlags} xcodebuild -target ${_target} -configuration ${_configuration} ${stdenv.lib.optionalString (scheme != null) "-scheme ${scheme}"} -sdk ${_sdk} TARGETED_DEVICE_FAMILY="1, 2" ONLY_ACTIVE_ARCH=NO CONFIGURATION_TEMP_DIR=$TMPDIR CONFIGURATION_BUILD_DIR=$out ${if generateIPA || generateXCArchive then "-archivePath \"${name}.xcarchive\" archive" else ""} ${if release then '' PROVISIONING_PROFILE=$PROVISIONING_PROFILE OTHER_CODE_SIGN_FLAGS="--keychain $HOME/Library/Keychains/$keychainName-db"'' else ""} ${xcodeFlags}
${stdenv.lib.optionalString release '' ${stdenv.lib.optionalString release ''
${stdenv.lib.optionalString generateIPA '' ${stdenv.lib.optionalString generateIPA ''
@ -97,11 +101,15 @@ stdenv.mkDerivation ({
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>signingCertificate</key>
<string>${codeSignIdentity}</string>
<key>provisioningProfiles</key> <key>provisioningProfiles</key>
<dict> <dict>
<key>${bundleId}</key> <key>${stdenv.lib.toLower bundleId}</key>
<string>$PROVISIONING_PROFILE</string> <string>$PROVISIONING_PROFILE</string>
</dict> </dict>
<key>signingStyle</key>
<string>manual</string>
<key>method</key> <key>method</key>
<string>${signMethod}</string> <string>${signMethod}</string>
${stdenv.lib.optionalString (signMethod == "enterprise" || signMethod == "ad-hoc") '' ${stdenv.lib.optionalString (signMethod == "enterprise" || signMethod == "ad-hoc") ''

View File

@ -1,5 +1,5 @@
{stdenv}: {stdenv}:
{version ? "9.3", xcodeBaseDir ? "/Applications/Xcode.app"}: {version ? "10.1", xcodeBaseDir ? "/Applications/Xcode.app"}:
assert stdenv.isDarwin; assert stdenv.isDarwin;
@ -13,6 +13,7 @@ stdenv.mkDerivation {
ln -s /usr/bin/codesign ln -s /usr/bin/codesign
ln -s /usr/bin/xcrun ln -s /usr/bin/xcrun
ln -s /usr/bin/plutil ln -s /usr/bin/plutil
ln -s /usr/bin/clang
ln -s "${xcodeBaseDir}/Contents/Developer/usr/bin/xcodebuild" ln -s "${xcodeBaseDir}/Contents/Developer/usr/bin/xcodebuild"
ln -s "${xcodeBaseDir}/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator" ln -s "${xcodeBaseDir}/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator"