oscartbeaumont / tauri-specta

Completely typesafe Tauri commands
MIT License
289 stars 26 forks source link

Using tauri-specta on tauri v2 mobile #104

Closed Dreaming-Codes closed 3 weeks ago

Dreaming-Codes commented 3 weeks ago

I'm trying to use your awesome crate on Tauri Mobile, but I'm encountering an error when running my project on a mobile device. The issue arises because the crate attempts to save TypeScript bindings directly to my phone instead of within the project directory.

Is there a way to generate the bindings during the build process rather than at runtime to resolve this issue? Disabling bindings generation on mobile isn't a viable option for me, as my app only works on mobile.

Thank you!

oscartbeaumont commented 3 weeks ago

I suspect you could use #[cfg(all(debug_assertions, not(target_os = "android"), not(target_os = "ios")))] on the .path method here.

All you need to do it make sure this method is not called on your mobile devices.

oscartbeaumont commented 3 weeks ago

@Brendonovich pointed out you might not also be building a desktop app which I completely missed in that original solution.

If that's the case you can setup a unit test for exporting your bindings file instead of doing within your apps runtime code.

We have an example of this in ./examples/custom-plugin/plugin.

Dreaming-Codes commented 3 weeks ago

@Brendonovich pointed out you might not also be building a desktop app which I completely missed in that original solution.

If that's the case you can setup a unit test for exporting your bindings file instead of doing within your apps runtime code.

We have an example of this in ./examples/custom-plugin/plugin.

Exactly what I needed, thanks