-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not sure my use case would work #271
Comments
If I'm understanding, you're looking to create a Swift package that contains Swift and Rust code? Does the Swift packages chapter in the book meet your needs https://github.com/chinedufn/swift-bridge/tree/c3c950c90867550e09a24c94357f1e502bf6d69d/book/src/building/swift-packages If that's not what you mean then could you explain your use case a bit more? What is the final artifact that you are looking to create? How would that artifact be used? |
escentially i am building another project like this: https://github.com/rustunit/bevy_ios_notifications At the root of the repo its a swift package that people can easily integrate into their xcode project via the SPM. This package so far exposed a manually crafted c-ffi via funcs like:
this is matched by a separate (though in the same git repo) rust crate that hooks into these via the usual:
So the communication is rust calling swift and and in order to call the other direction there some swift functions take a function pointer that is used to callback. This way everything works together as soon as xcode builds the project and links everything together the c functions that rust expects to be there are coming from the swift package. Now crafting these c-ffis is obviously tedious and error prone. so ideally I can use swift-bridge to generate these for me problem: |
I think you need to set the bridging header setting to tell XCode to link against the headers, otherwise it will just ignore them: https://developer.apple.com/documentation/swift/importing-objective-c-into-swift#Import-Code-Within-an-App-Target |
Thanks Bright-Shard. extrawurst if that doesn't work please share the build errors that you are seeing. This will help with figuring out what the root of the problem is. |
I am looking into using
swift-bridge
for building native iOS bevy integrations. aka reusable crates/swift-packages.So far I did this by hand crafting the rust-side and swift-side to then have a matching c-ffi layer in between. once this was complex enough I used protobuf for the data-transport between both sides. works but adds protobuf as a dependency and obviously requires data serialization (albeit it being fast)
now I am wondering if I can use swift-bridge instead. so far I cannot get it to work, as it seem to heavily depend on bridging headers to c headers. and as far as I can see there is no way to create swift packages shipping swift code and c headers.
maybe I am missing something? (I hope so, using this would be so much more awesome)
The text was updated successfully, but these errors were encountered: