Open paholg opened 1 year ago
Hey, thanks for opening this issue.
https://github.com/chinedufn/swift-bridge/pull/202 should fix the dangling pointer warning.
As for the the signatures that you mention, thus far swift-bridge
has been biased towards Swift-calling-Rust use cases, mainly because that's my current use case.
That being said, we aim to have excellent bi-directional support, so we want to get these fixed.
If a type is supported in extern "Rust"
fns, it should almost always be easy to support the other direction. I'll take a look at your first example now and submit a PR.
Submitted a PR for Option<Primitive>
in Swift functions https://github.com/chinedufn/swift-bridge/pull/203 .
Mind reviewing it?
Thanks for the quick response! I'll take a look now, though I don't really know swift.
Hello! I am trying to call Swift from Rust, but having a heck of a time getting anything but the most trivial example to work.
In all of the examples below, I have edited
src/main.rs
andswift-library/Sources/swift-library/swift_library.swift
in therust-binary-calls-swift-package
example.If I try to return an option, like so:
I get the following error:
as well as some warnings about dangling pointers. Looking at the generated code, the generated function is returning a plain
UInt
:If I try to pass a
String
from Rust to Swift:Then I get dangling pointer warnings still, and this error:
Finally, if I try to pass in a
Vec
(replaceString
withVec<usize>
andRustString
withRustVec<UInt>
in the previous example), I get this error:I must be doing something simple wrong, but I can't for the life of me figure out what it is, and I would appreciate any help.