@@ -497,14 +497,17 @@ fn try_pkg_config() -> bool {
497
497
}
498
498
499
499
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
+ }
508
511
}
509
512
}
510
513
println ! ( "unable to determine Xcode version, assuming >= 9" ) ;
@@ -551,7 +554,7 @@ fn macos_link_search_path() -> Option<String> {
551
554
let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
552
555
for line in stdout. lines ( ) {
553
556
if line. contains ( "libraries: =" ) {
554
- let path = line. split ( '=' ) . skip ( 1 ) . next ( ) ?;
557
+ let path = line. split ( '=' ) . nth ( 1 ) ?;
555
558
return Some ( format ! ( "{}/lib/darwin" , path) ) ;
556
559
}
557
560
}
0 commit comments