Open sax opened 5 months ago
One thing I'm unclear on is the best set of targets for watchos
and iphoneos
. I'm only targeting the latest version of iOS, so aarch64 may be good enough. I have compiled the Rust part of my application for watchOS and visionOS, but have not started the Swift part so don't yet know if this is missing anything.
Also I have my XCode project in a swift/
subdirectory of my repository, which is why my script is changing directory. That may not be needed for others.
I have an application where my initial platform was
macosx
but where I'm now adding multi-platform support. I'm not sure if this is yet stable enough to do a pull request into the guides, but I thought I'd put it here in case it's helpful to others. @chinedufn if you want to use any of this, please feel free to do so without any need for attribution.My first attempt was just to bundle more targets into a single build artifact. I quickly discovered that
lipo
only allows a single artifact per architecture (aarch64
vsx86_64
), and cannot combine multiple build targets on the same architecture. Therefor I decided to create a different artifact per target, and configure my XCode project to link to a specific file per target platform.Note that I am using
lipo
from thecoreutils
package installed via Homebrew, and in the following snippets I'm replacing my real crate name with<rust-bridge>
or<rust_bridge>
.My
build-rust.sh
script is as follows:In my XCode project, rather than directly linking to the build product (which now includes the
PLATFORM_NAME
in the file name), I added a newConfiguration Settings File
with the following contents:I go multiple years between having to configure linkers, so it took me a bit of fighting before I remembered that
-l"name"
links tolibname.a
, and I had to excludelib
from the ldflags.