mozilla / uniffi-rs

a multi-language bindings generator for rust
https://mozilla.github.io/uniffi-rs/
Mozilla Public License 2.0
2.83k stars 231 forks source link

Add `cargo-xcode` crate for easier iOS project dependency configuration #1623

Open gezihuzi opened 1 year ago

gezihuzi commented 1 year ago

Hello, I tried to add the Uniffi and Rust lib dependencies to my iOS project by following the Xcode project configuration tutorial and sample project provided by Uniffi, but the process was complex, and the generated dependency library architecture did not support both simulator and real machine architectures at the same time.

To solve this problem, I suggest using cargo-xcode to simplify the Xcode project configuration process and simultaneously generate dependency library architectures applicable to multiple platforms. Here are the steps to use cargo-xcode:

  1. Use cargo-xcode to generate the libname.xcodeproj project engineering file for Rust lib.
  2. Use Xcode to create a Framework project, add the required dependencies and library files, then drag the libname.xcodeproj project generated in step 1 into the newly created dependency and add project dependencies and library dependencies.
  3. To generate header files, import udl files and customize the compilation process.
  4. Open the required header files in the Framework project created in step 2 and import the header files generated in step 3.
  5. Import the Framework to any Xcode project to use it.

Using the cargo-xcode tool, I can more easily realize the dependency introduction of Uniffi and Rust lib, while also saving some tedious configuration work. Thank you for providing this useful tool!

I hope my suggestions can be adopted and helpful to other users!

mhammond commented 1 year ago

Thanks for the suggestion - if this suggestion is for other people consuming UniFFI, it would be fantastic if you could provide a PR which updates the docs to others will actually find and be able to use this suggestion.

gezihuzi commented 1 year ago

I have been recently trying to add a example Xcode Framework and update the related documentation. After completion, I will submit the PR.