-
Notifications
You must be signed in to change notification settings - Fork 65
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
extern Swift declaration not public #241
Comments
Could you share the minimal example? |
See this zip file for a minimal example. The generated code looks like this:
Thus the linker will report That's because of swifts access control defaulting to The swift compiler does not expose the symbol because the |
If you point me in the right direction, I can create a pull request fixing this :) |
@tmolitor-stud-tu
I'll dive into this issue next weekend because I'm a bit busy right now. |
public func test() {
__swift_bridge__$test()
}
@_cdecl("__swift_bridge__$swift_handler")
func __swift_bridge__swift_handler (_ text: UnsafeMutableRawPointer) {
swift_handler(text: RustString(ptr: text))
} In your example, it seems like I think we need to share an example which can reproduce this error. |
As far as I remember, this method is used on the Rust side. So, other swift modules shouldn't call this. |
Exactly, but the binary rust XCFramework has an unresolved symbol ( Please note: even though I did not include swift code containing the Sidenote: a full (non-minimal) example can be found over here: https://github.com/monal-im/Monal/tree/develop/rust |
What linker do you use?
By the way, I added the your package to my minimal project like this: Even though I don't put EnvironmentXcode: Version 14.3.1 |
As you can see the immediately above comment, it seems like the program run, which means the linker could link all of the rust object files and swift object files. |
Well, I'm using Xcode Version 14.3.1, too. The build command is this: And later on: What commands did you use to build the rust binary? Just to double check: our build script uses That said I'm almost certain that the swift compiler won't export any symbols of functions that are not public (because swift functions without explicit access control default to "internal"). In your test the binary rust xcframework seems to be seen as internal by the swift compiler, while in my case the compiler seems to see the rust framework as external. Regardless of the root cause of this: I really think that using |
#262 should fix this |
Thanks @jmp-0x7C0 !!! |
We are building a library that has swift code that should be called by rust in an extra swift file (besides the auto generated ones).
But we keep getting linker errors that
__swift_bridge__$rust_handler
could not be found.Until we make the auto-generated function public:
Could you fix the code autogenerator to make these public by default (or at least introduce some compile-time switch to do that)?
The text was updated successfully, but these errors were encountered: