@@ -2582,16 +2582,44 @@ impl Build {
25822582 "Detecting {:?} SDK path for {}" ,
25832583 os, sdk_details. sdk
25842584 ) ) ;
2585- let sdk_path = if let Some ( sdkroot) = env:: var_os ( "SDKROOT" ) {
2586- sdkroot
2587- } else {
2588- self . apple_sdk_root ( & sdk_details. sdk ) ?
2589- } ;
2585+ let sdk_path = self . apple_sdk_root ( & sdk_details. sdk ) ?;
25902586
25912587 cmd. args . push ( "-isysroot" . into ( ) ) ;
25922588 cmd. args . push ( sdk_path) ;
25932589 }
25942590
2591+ if let AppleArchSpec :: Catalyst ( _) = arch {
2592+ // Mac Catalyst uses the macOS SDK, but to compile against and
2593+ // link to iOS-specific frameworks, we should have the support
2594+ // library stubs in the include and library search path.
2595+ let sdk_path = self . apple_sdk_root ( & sdk_details. sdk ) ?;
2596+ let ios_support = PathBuf :: from ( sdk_path) . join ( "/System/iOSSupport" ) ;
2597+
2598+ cmd. args . extend ( [
2599+ // Header search path
2600+ OsString :: from ( "-isystem" ) ,
2601+ ios_support. join ( "/usr/include" ) . into ( ) ,
2602+ // Framework header search path
2603+ OsString :: from ( "-iframework" ) ,
2604+ ios_support. join ( "/System/Library/Frameworks" ) . into ( ) ,
2605+ // Library search path
2606+ {
2607+ let mut s = OsString :: from ( "-L" ) ;
2608+ s. push ( & ios_support. join ( "/usr/lib" ) ) ;
2609+ s
2610+ } ,
2611+ // Framework linker search path
2612+ {
2613+ // Technically, we _could_ avoid emitting `-F`, as
2614+ // `-iframework` implies it, but let's keep it in for
2615+ // clarity.
2616+ let mut s = OsString :: from ( "-F" ) ;
2617+ s. push ( & ios_support. join ( "/System/Library/Frameworks" ) ) ;
2618+ s
2619+ } ,
2620+ ] ) ;
2621+ }
2622+
25952623 Ok ( ( ) )
25962624 }
25972625
@@ -3489,6 +3517,10 @@ impl Build {
34893517 }
34903518
34913519 fn apple_sdk_root ( & self , sdk : & str ) -> Result < OsString , Error > {
3520+ if let Some ( sdkroot) = env:: var_os ( "SDKROOT" ) {
3521+ return Ok ( sdkroot) ;
3522+ }
3523+
34923524 let mut cache = self
34933525 . apple_sdk_root_cache
34943526 . lock ( )
0 commit comments