@@ -497,14 +497,17 @@ fn try_pkg_config() -> bool {
497497}
498498
499499fn 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