cargo-mobile2 icon indicating copy to clipboard operation
cargo-mobile2 copied to clipboard

Fix and update Bevy templates

Open NiklasEi opened this issue 7 months ago • 7 comments

This PR updates the Bevy templates to Bevy 0.16.

To test

  1. cargo install --path . in this branch
  2. cargo mobile init choose template 0 or 1
  3. cargo android run or cargo apple run

Draft because:

  • [x] test on iOS (I do not have access to a mac / iOS device at the moment)

NiklasEi avatar May 22 '25 22:05 NiklasEi

I can try to test it on macos/ios tomorrow or so. Feel free to ping me early/mid next week if I didn't get back to you by then :)

FabianLars avatar May 24 '25 17:05 FabianLars

I can try to test it on macos/ios tomorrow or so. Feel free to ping me early/mid next week if I didn't get back to you by then :)

@FabianLars have you had time to look at this?

NiklasEi avatar May 27 '25 16:05 NiklasEi

Just tested it. I never tested the old version so both things are probably unrelated to your PR but maybe still good to adress them.

  1. To adress https://github.com/tauri-apps/cargo-mobile2/issues/352 it seems like it helps to change cargo.toml from
[package.metadata.cargo-apple.ios]
frameworks = ["AudioToolbox"]

to

[package.metadata.cargo-apple.ios]
frameworks = ["AudioToolbox", "SystemConfiguration"]
  1. I added this https://github.com/tauri-apps/cargo-mobile2/blob/dev/templates/apps/egui/src/lib.rs#L142C1-L163 as well. Technically only the block with extern C is needed (if we change it to call main() ) but the catch_unwind stuff doesn't hurt i guess. Without this the linker fails to find the entry point.

FabianLars avatar May 28 '25 11:05 FabianLars

Thank you!

I added this https://github.com/tauri-apps/cargo-mobile2/blob/dev/templates/apps/egui/src/lib.rs#L142C1-L163 as well. Technically only the block with extern C is needed (if we change it to call main() ) but the catch_unwind stuff doesn't hurt i guess. Without this the linker fails to find the entry point.

Usually the bevy_main macro takes care of providing an entry point, but this tool expects it to be called differently. Would it maybe make sense to make https://github.com/tauri-apps/cargo-mobile2/blob/8bc00deb687fcd7001f000d851906c8f693ef191/templates/platforms/xcode/Sources/%7B%7Bapp.name%7D%7D/bindings/bindings.h#L5 configurable?

NiklasEi avatar May 28 '25 17:05 NiklasEi

Maybe but i'm in no position to judge that, i'm just doing the bare minimum here, like testing PRs 😅 Also, looking at bevy_main i'm not sure that'd actually help (didn't try it though)

FabianLars avatar May 28 '25 20:05 FabianLars

Oh right, it was changed in 0.16. It would have only helped if we can rename the expected entry point in the bindings.

Thanks again for checking on iOS. This PR is ready for review then 🙂

NiklasEi avatar May 28 '25 21:05 NiklasEi

Ah i forgot something. I need all commits to be signed before i can merge a PR.

If you could add a changefile like https://github.com/tauri-apps/cargo-mobile2/pull/453/files#diff-47e070136f64bf323a3f0cd2c156663dc4cc877bbf3ae4fd4a1d5ef410bd79eb (patch) that would be much appreciated as well :)

FabianLars avatar May 29 '25 12:05 FabianLars

ahh the commits were still not signed. since i added new commits already i'll just bypass the rules this time.

thanks for the contribution

FabianLars avatar Jun 03 '25 14:06 FabianLars

ahh the commits were still not signed. since i added new commits already i'll just bypass the rules this time.

Sorry, I misunderstood and only signed-off the commit with my git E-Mail. I should have followed your link :see_no_evil:

NiklasEi avatar Jun 03 '25 15:06 NiklasEi