Support iOS targets in the logos-delivery transport build (#203)

The platform gate rejected every target OS except macOS and Linux, so any
Apple mobile target failed at build-script time before compiling anything.

iOS differs from the existing platforms in how the native library is
consumed: an app bundle cannot ship a loose dylib the way an APK ships a
.so, so the delivery node has to be linked as a static archive. That also
means rln must be named explicitly -- with no shared library in the
picture there is no rpath to resolve it transitively. iOS takes the
relocatable path unconditionally, since the absolute-install-name stamping
the default path performs has no meaning for a statically linked archive.

Verified on aarch64-apple-ios-sim: liblogoschat.a builds (arm64,
platform IOSSIMULATOR, 26 exported logoschat_* symbols), links against
liblogosdelivery.a + librln.a with no unresolved symbols, and runs on an
iPhone 17 Pro simulator -- logoschat_gen_address() returns a valid account
address.

Device targets (aarch64-apple-ios) are untested here: they additionally
need liblogosdelivery.a and librln.a built for the device slice, which is
outside this repo.

Co-authored-by: Jazz Turner-Baggs <473256+jazzz@users.noreply.github.com>
This commit is contained in:
Guru 2026-08-11 21:27:50 +05:30 committed by GitHub
parent 5142fe9bf0
commit 2fc6172471
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,13 +20,13 @@ fn main() {
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
match target_os.as_str() { match target_os.as_str() {
"macos" | "linux" => {} "macos" | "linux" | "ios" => {}
other => panic!("unsupported OS for logos-delivery transport: {other}"), other => panic!("unsupported OS for logos-delivery transport: {other}"),
} }
// Two linking modes, because dev builds and *distributable* builds want // Two linking modes, because dev builds and *distributable* builds want
// opposite things out of the library's install name / soname. // opposite things out of the library's install name / soname.
if relocatable() { if relocatable() || target_os == "ios" {
// Distribution: link the shipped library in place and leave its // Distribution: link the shipped library in place and leave its
// relocatable name (@rpath on macOS, $ORIGIN soname on Linux) intact, // relocatable name (@rpath on macOS, $ORIGIN soname on Linux) intact,
// so the consumer can copy it into its own bundle and resolve it from // so the consumer can copy it into its own bundle and resolve it from
@ -51,7 +51,16 @@ fn main() {
println!("cargo:rustc-link-search=native={out_dir}"); println!("cargo:rustc-link-search=native={out_dir}");
} }
println!("cargo:rustc-link-lib=dylib=logosdelivery"); if target_os == "ios" {
// iOS apps cannot ship loose dylibs the way an APK can, so the delivery
// node is linked as a static archive. rln has to be named explicitly:
// with no shared library there is no rpath to resolve it transitively.
println!("cargo:rustc-link-lib=static=logosdelivery");
println!("cargo:rustc-link-lib=static=rln");
println!("cargo:rustc-link-lib=c++");
} else {
println!("cargo:rustc-link-lib=dylib=logosdelivery");
}
println!("cargo:lib_dir={}", lib_dir.display()); println!("cargo:lib_dir={}", lib_dir.display());
} }