-
Notifications
You must be signed in to change notification settings - Fork 53
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
Various errors calling Swift from Rust #201
Comments
Hey, thanks for opening this issue. #202 should fix the dangling pointer warning. As for the the signatures that you mention, thus far That being said, we aim to have excellent bi-directional support, so we want to get these fixed. If a type is supported in |
Submitted a PR for Mind reviewing it? |
Thanks for the quick response! I'll take a look now, though I don't really know swift. |
Related to #201. This commit adds support `RustString` in extern Swift functions. Here's an example of using this. ```Swift //Swift func reflect_swift_string(arg: RustString) -> RustString { arg } ``` ```Rust //Rust #[swift_bridge::bridge] mod ffi { extern "Swift" { fn reflect_swift_string(arg: String) -> String; } } let foo = "foo"; let string = ffi::reflect_swift_string(foo.to_string()); assert_eq!(string.len(), 3); assert_eq!(&string, foo); ```
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.
The text was updated successfully, but these errors were encountered: