Skip to content

A cargo-generate template for generating ios-rust-swift apps.

License

Notifications You must be signed in to change notification settings

simlay/swift-rust-xcode-template

Repository files navigation

Swift Rust Xcode Template

Build Status

This is a template for quickly building an iOS app in rust and swift. It uses cbindgen to build bindings.h for convenient rust-swift interop.

To use this with cargo-generate do:

cargo generate --git https://github.com/simlay/swift-rust-xcode-template.git --name myproject
cd myproject
./rename.sh

The ./rename.sh step renames the xcode stuff to match your project name.

To build the rest of the app/project you'll need to run:

  • cargo install cargo-lipo
  • rustup target add aarch64-apple-ios x86_64-apple-ios

After that you can build the app via the Xcode zoom-zoom-play button or run: xcodebuild -target myproject -configuration Debug -scheme my-test-app -sdk iphonesimulator13.2

Currently, there's some very rudimentary swift code that calls the rust with a closure passed in. You can see that code here.

Template Maintenance

Adding new things to this template is unfortunately annoying to add to or maintain because of the template tags in swift-rust-xcode-template.xcodeproj/project.pbxproj, rename.sh and Cargo.toml. This project is open to other work flows but here's what seems like the least worst option:

git clone https://github.com/simlay/swift-rust-xcode-template
cargo generate --git ./swift-rust-xcode-template --name update-swift-rust-xcode-template
cd update-swift-rust-xcode-template
./rename.sh

modify your stuff and then cp the files back to the other directory.

I'f you're doing a lot of things you may want to symlink the src/lib.rs, swift-rust-xcode-template/*.swift, etc. to the swift-rust-xcode-template repo checkout.

About

A cargo-generate template for generating ios-rust-swift apps.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published