2023-04-29 16:46:19 +00:00
|
|
|
{ stdenv, lib }:
|
|
|
|
{ version ? "11.1"
|
|
|
|
, allowHigher ? false
|
|
|
|
, xcodeBaseDir ? "/Applications/Xcode.app" }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
assert stdenv.isDarwin;
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2023-04-29 16:46:19 +00:00
|
|
|
pname = "xcode-wrapper${lib.optionalString allowHigher "-plus"}";
|
|
|
|
inherit version;
|
2023-05-24 13:37:59 +00:00
|
|
|
# Fails in sandbox. Use `--option sandbox relaxed` or `--option sandbox false`.
|
|
|
|
__noChroot = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
2023-04-29 16:46:19 +00:00
|
|
|
currVer=$($out/bin/xcodebuild -version | head -n1)
|
|
|
|
${if allowHigher then ''
|
|
|
|
if [ -z "$(printf '%s\n' "${version}" "$currVer" | sort -V | head -n1)""" != "${version}" ]
|
|
|
|
'' else ''
|
|
|
|
if [ -z "$(echo $currVer | grep -x 'Xcode ${version}')" ]
|
|
|
|
''}
|
2020-04-24 23:36:52 +00:00
|
|
|
then
|
2023-04-29 16:46:19 +00:00
|
|
|
echo "We require xcodebuild version${if allowHigher then " or higher" else ""}: ${version}"
|
|
|
|
echo "Instead what was found: $currVer"
|
2020-04-24 23:36:52 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
}
|