Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /System/iOSSupport to header/library search paths on Mac Catalyst #961

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 37 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2582,16 +2582,44 @@ impl Build {
"Detecting {:?} SDK path for {}",
os, sdk_details.sdk
));
let sdk_path = if let Some(sdkroot) = env::var_os("SDKROOT") {
sdkroot
} else {
self.apple_sdk_root(&sdk_details.sdk)?
};
let sdk_path = self.apple_sdk_root(&sdk_details.sdk)?;

cmd.args.push("-isysroot".into());
cmd.args.push(sdk_path);
}

if let AppleArchSpec::Catalyst(_) = arch {
// Mac Catalyst uses the macOS SDK, but to compile against and
// link to iOS-specific frameworks, we should have the support
// library stubs in the include and library search path.
let sdk_path = self.apple_sdk_root(&sdk_details.sdk)?;
let ios_support = PathBuf::from(sdk_path).join("/System/iOSSupport");

cmd.args.extend([
// Header search path
OsString::from("-isystem"),
ios_support.join("/usr/include").into(),
// Framework header search path
OsString::from("-iframework"),
ios_support.join("/System/Library/Frameworks").into(),
// Library search path
{
let mut s = OsString::from("-L");
s.push(&ios_support.join("/usr/lib"));
s
},
// Framework linker search path
madsmtm marked this conversation as resolved.
Show resolved Hide resolved
{
// Technically, we _could_ avoid emitting `-F`, as
// `-iframework` implies it, but let's keep it in for
// clarity.
let mut s = OsString::from("-F");
s.push(&ios_support.join("/System/Library/Frameworks"));
s
},
]);
}

Ok(())
}

Expand Down Expand Up @@ -3488,6 +3516,10 @@ impl Build {
}

fn apple_sdk_root(&self, sdk: &str) -> Result<OsString, Error> {
if let Some(sdkroot) = env::var_os("SDKROOT") {
return Ok(sdkroot);
}

let mut cache = self
.apple_sdk_root_cache
.lock()
Expand Down