Comments (4)
Hey very sorry for the delay, July 21-Aug 1 is super hectic for me and then I'll be back to normal once I settle back in.
The book seems to focus heavily on calling Rust FROM Swift but not the other way around.
Yup totally. The reason for this is that my current use case mainly involves calling Rust from Swift, so I've mainly focused on supporting and writing documentation for that use case.
That being said we also want swift-bridge
to make it easy to call Swift from Rust so I'd love to help with anything that you need here.
So you're trying to compile a Swift native library and then link to it from Rust?
If so, there's a very tiny example of this in the book right now (we still need to write a deeper walkthrough) https://github.com/chinedufn/swift-bridge/blob/a78e617ffbb9471224c4ee79a6e42f0498ed4c43/book/src/building/swiftc-and-cargo/README.md#rust-links-to-a-swift-native-library
You don't need to annotate Swift code to call it from Rust. swift-bridge
generates the FFI bridge for you.
For example, here we test the generated code for a Swift function that takes a Swift class instance as an argument:
I'm assuming there's some sort of build/compile step I'm missing with Swift to generate the needed header files that I may have just missed in the docs?
Yup it's that little blurb from the first link where you use the swift-bridge
API or CLI to generate the header files. The CLI command doesn't exist yet, but I can add it for you if you need it (or give you step by step instructions on how to do it if you'd like to make a first contribution!)
Let me know if that helps.
I'd love to help make sure that all of your problems get solved here.
Our approach has been to add documentation as we go.. so once we get you sorted out I'll add some docs on this before closing out this issue.
Cheers!
from swift-bridge.
I'm working on a full example of a Rust binary that calls a Swift library
from swift-bridge.
Update: I have a working example. Now I need to clean it up.
from swift-bridge.
Whipped up an example of a Rust binary that calls a Swift package in #104
You can view the example here -> https://github.com/chinedufn/swift-bridge/tree/23d60feaa0f8e92f2c854d8665868aa5573ef505/examples/rust-binary-calls-swift-package
Please feel free to re-open this if this example isn't enough for your use case.
Cheers!
from swift-bridge.
Related Issues (20)
- extern Swift declaration not public HOT 12
- Support Box<FnOnce> in extern "Rust" HOT 3
- Xcode reports "Multiple commands produce '...DerivedData...Build/Products/Debug/include/module.modulemap'" HOT 4
- Clippy finds clippy::unnecessary-cast
- Getting these errors in my project HOT 1
- Add an additional XCode + Rust project option HOT 1
- Building for Release HOT 5
- #[swift_bridge::bridge] macro forces module to be private HOT 3
- warning: `extern` block uses type `RustString`, which is not FFI-safe HOT 4
- Book update: Xcode 15 (at least) requires a bridge in order to import into swift
- Can't seem to return refs of custom types HOT 11
- Cannot use two `#[swift_bridge(..)]` attributes on the same function
- Already_declared causes swift generation to never declare Class HOT 1
- Result returns translating incorrectly? HOT 3
- Is &Vec<T> supported? HOT 2
- Cannot for the life of me get Xcode + Cargo to work HOT 2
- Unable to bridge function that receives &str and returns result HOT 1
- Support bridging `Option<SwiftClass>` in `extern "Rust"` function
- Support `#[swift_bridge(Sendable)]` to implement `Rust Send+Sync` for `Swift Sendable` types HOT 1
- ffi struct produces warnings on Rust 1.79.0 or +nightly HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-bridge.