Skip to content
 
 

Repository files navigation

xcode-rust-example

Xcode

Demonstrates the ability to generate the necessary bindings for a rust lib compiled for an apple target to be embedded and called by a Swift project in Xcode.

pre-reqs

  1. cargo
  2. xcode from Apple app store

Setup

rustylib rust library with two exposed functions
swiftyapp hello world ios app that imports and uses the two rust lib functions swiftyrustlib Swift package of rust lib

  1. Run make rust (or ./build.sh).
  2. Open the Xcode project located at swiftyapp/swiftyapp.xcodeproj.
  3. Ensure that RustyLib was successfully imported into project.
  4. Build and run the project in Xcode.
  5. For Intel Macs, enable and choose the Mac Catalyst destination in Xcode.
  6. On Apple Silicon Macs, you can also choose My Mac (Designed for iPad) in Xcode.
  7. Verify that the Rust library functions are successfully called from the Swift project.

Make targets

  • make rust builds the Rust static libraries, Swift bindings, and RustyCore.xcframework.
  • make resolve refreshes the local Swift package reference in Xcode.
  • make app builds the app for a generic iOS Simulator destination.
  • make catalyst builds the app for Mac Catalyst.
  • make clean removes Rust and Xcode derived build artifacts.

Referenced Articles:

Releases

Packages

Contributors

Languages