builder: fix building for iOS and simulator from macOS

pull/13883/head
Cameron Katri 2022-03-30 21:28:03 -04:00
parent fbdf519d32
commit d2c477d309
No known key found for this signature in database
GPG Key ID: BAFFD97826540F1C
2 changed files with 10 additions and 3 deletions

View File

@ -347,7 +347,11 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
if v.pref.os == .macos {
ccoptions.post_args << '-mmacosx-version-min=10.7'
} else if v.pref.os == .ios {
ccoptions.post_args << '-miphoneos-version-min=10.0'
if v.pref.is_ios_simulator {
ccoptions.post_args << '-miphonesimulator-version-min=10.0'
} else {
ccoptions.post_args << '-miphoneos-version-min=10.0'
}
} else if v.pref.os == .windows {
ccoptions.post_args << '-municode'
}

View File

@ -219,11 +219,14 @@ pub fn (mut p Preferences) default_c_compiler() {
ios_sdk_path_res := os.execute_or_exit('xcrun --sdk $ios_sdk --show-sdk-path')
mut isysroot := ios_sdk_path_res.output.replace('\n', '')
arch := if p.is_ios_simulator {
'-arch x86_64'
'-arch x86_64 -arch arm64'
} else {
'-arch armv7 -arch armv7s -arch arm64'
}
p.ccompiler = 'xcrun --sdk iphoneos clang -isysroot $isysroot $arch'
// On macOS, /usr/bin/cc is a hardlink/wrapper for xcrun. clang on darwin hosts
// will automatically change the build target based off of the selected sdk, making xcrun -sdk iphoneos pointless
p.ccompiler = '/usr/bin/cc'
p.cflags = '-isysroot $isysroot $arch' + p.cflags
return
}
}