Skip to content

Commit 5df9997

Browse files
authored
Ensure that the Xcode CLI tools are installed (#415)
1 parent bedd77b commit 5df9997

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

curl-sys/build.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -497,14 +497,17 @@ fn try_pkg_config() -> bool {
497497
}
498498

499499
fn xcode_major_version() -> Option<u8> {
500-
let output = Command::new("xcodebuild").arg("-version").output().ok()?;
501-
if output.status.success() {
502-
let stdout = String::from_utf8_lossy(&output.stdout);
503-
println!("xcode version: {}", stdout);
504-
let mut words = stdout.split_whitespace();
505-
if words.next()? == "Xcode" {
506-
let version = words.next()?;
507-
return version[..version.find('.')?].parse().ok();
500+
let status = Command::new("xcode-select").arg("-p").status().ok()?;
501+
if status.success() {
502+
let output = Command::new("xcodebuild").arg("-version").output().ok()?;
503+
if output.status.success() {
504+
let stdout = String::from_utf8_lossy(&output.stdout);
505+
println!("xcode version: {}", stdout);
506+
let mut words = stdout.split_whitespace();
507+
if words.next()? == "Xcode" {
508+
let version = words.next()?;
509+
return version[..version.find('.')?].parse().ok();
510+
}
508511
}
509512
}
510513
println!("unable to determine Xcode version, assuming >= 9");
@@ -551,7 +554,7 @@ fn macos_link_search_path() -> Option<String> {
551554
let stdout = String::from_utf8_lossy(&output.stdout);
552555
for line in stdout.lines() {
553556
if line.contains("libraries: =") {
554-
let path = line.split('=').skip(1).next()?;
557+
let path = line.split('=').nth(1)?;
555558
return Some(format!("{}/lib/darwin", path));
556559
}
557560
}

0 commit comments

Comments
 (0)