-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add support for proc-macro #26
Comments
The underlying library (UniFFI by Mozilla, which does the heavy lifting here) has proc-macros as described in the UniFFI docs: https://mozilla.github.io/uniffi-rs/proc_macro/index.html It should work if you have a lib.udl file with an empty namespace. Alternatively, as per the UniFFI docs, putting I am currently on vacation, but I'll check soon what should be modified in cargo swift to make this work more elegantly. (Probably just adding a template for macro-only mode). Keeping this issue open until I checked the rough edges when using UniFFI proc-macros with |
@martinmose I added support for using UniFFI proc macros in If you want to test it, you can do the following: Install the current alpha:
Init a new project with Calling Let me know if you encounter any bugs |
@antoniusnaumann Awesome! Thanks a lot. I will give it a go tonight 💪. Regarding the I have this in my lib.rs: And this in the
It could be cool if I could test it out with my existing project where Im using procs marcros ⭐. |
For cargo swift, you don't need the bin as cargo swift already handles this. (If you still need this for generating bindings to other languages using the UniFFI CLI, you can keep it of course) Currently, cargo swift assumes that there is a lib.udl file in the src/ directory and will fail if it is not present. I will lift this requirement in future versions. Otherwise, cargo swift should work fine in your existing project. |
I require the bin for Android 😅. However, fantastic work! You're doing great, and it works flawlessly! |
The To test this out, you can install the latest cargo swift version from git, this one depends on the UniFFI git repository instead of the latest published versions:
(this might contain bugs of course, as it depends on the UniFFI main branch) |
Keeping this issue open - blocked until UniFFI update is released by Mozilla |
Projects that only use UniFFI proc macros can now be packaged without a UDL file. @martinmose Could you try this out in the
(make sure that your project depends on uniffi 0.25.0) |
Hi, First and foremost, great job – it's working now! 🤩 However, I have a few observations: I noticed the header file (.h) is now named using snake_case. Wasn't it supposed to be named based on the --name option? I see the same naming pattern with the .swift file. I observed that the static lib-type is now the default. I found I can specify the desired library type using I encountered a few "errors" initially. I'm pretty sure it is unrelated and I believe this might be because I restructured my project.
When I used the
But if I just removed the However, after that I ran into another "error":
The only "project" I want to uniffi to export is my root project. The other crates are just some dependencies to my root project. If that make sense? |
Yeah, when invoked in a workspace, the default behavior is now as of #7. This builds all crates that depend on UniFFI as package. Consequently, the --name parameter is not allowed when invoking in a workspace. |
I changed the behavior of
|
@antoniusnaumann Thanks a lot! It now just works 🥳 |
Hello,
Firstly, a heartfelt thank you for the incredible work you've done!
I'd like to express my interest in proc-macro support, eliminating the need for a .udl file. I believe this enhancement could significantly simplify the initial learning curve for those venturing into a shared codebase in Rust.
I recognize that this is a substantial request, and a "spoiled" one, but I hope you bear with me.
The text was updated successfully, but these errors were encountered: