@@ -2582,16 +2582,44 @@ impl Build {
2582
2582
"Detecting {:?} SDK path for {}" ,
2583
2583
os, sdk_details. sdk
2584
2584
) ) ;
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 ) ?;
2590
2586
2591
2587
cmd. args . push ( "-isysroot" . into ( ) ) ;
2592
2588
cmd. args . push ( sdk_path) ;
2593
2589
}
2594
2590
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
+
2595
2623
Ok ( ( ) )
2596
2624
}
2597
2625
@@ -3489,6 +3517,10 @@ impl Build {
3489
3517
}
3490
3518
3491
3519
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
+
3492
3524
let mut cache = self
3493
3525
. apple_sdk_root_cache
3494
3526
. lock ( )
0 commit comments