chinedufn / swift-bridge

swift-bridge facilitates Rust and Swift interop.
https://chinedufn.github.io/swift-bridge
Apache License 2.0
755 stars 54 forks source link

Compile swift-library for iOS #275

Open HS3003991 opened 3 weeks ago

HS3003991 commented 3 weeks ago

Hello dear community, I am currently trying to organize a project in which I want to access Apple's Secure Enclave operations via Rust. I have so far managed to execute operations on the Secure Enclave via MacOS using a binary. Now my next step would be to implement the same for iOS and then call it wrapped in a Rust library from Flutter. My problem right now is that I can only get the Swift library compiled for MacOS (as you can see in the screenshot "arm64-apple-macosx"). Is there a way to compile it for iOS as well? I am mainly following the example of Chinedufn (“rust-binary-calls-swift-package”).

I would be very happy to receive help. :)

Bildschirmfoto 2024-06-09 um 23 44 37
chinedufn commented 3 weeks ago

Hey. You can try targeting aarch64-apple-ios.

https://github.com/chinedufn/swift-bridge/blob/ef01d21001914b79e0384627535098e15f87f096/book/src/building/xcode-and-cargo/README.md?plain=1#L86-L91

Feel free to re-open if yo need more help.

HS3003991 commented 3 weeks ago

Hello chinedufn, thank you very much for your quick support and your developed bridge. I already tried it to build for "aarch64-apple-ios". And I got a big error with the note _"= note: ld: building for 'iOS', but linking in object file (/Users/danielreimer/dev/github/binary_knights/implemented_CAL_environment/target/aarch64-apple-ios/debug/deps/libapple_secure_enclavebindings-655cb33c1ed02cd8.rlib6) built for 'macOS' clang: error: linker command failed with exit code 1 (use -v to see invocation)"

chinedufn commented 3 weeks ago

Can you follow the iOS example and then see if it works for you https://github.com/chinedufn/swift-bridge/blob/ef01d21001914b79e0384627535098e15f87f096/book/src/building/xcode-and-cargo/README.md?