godot-rust / gdext

Rust bindings for Godot 4
https://mastodon.gamedev.place/@GodotRust
Mozilla Public License 2.0
2.98k stars 187 forks source link

iOS support #498

Open moberer opened 9 months ago

moberer commented 9 months ago

This issue is for tracking the state of iOS support.

More specifically:

MeganSpencer commented 9 months ago

Tangentially related, but still related. Spent a few hours trying to see if I can use Godot + Rust to make a simple iOS app. I got stuck at the very start of the process. After creating a basic rust library with a simple test node and test function inside that node. It turns out doing something as simple as editing that function, and doing cargo build && cp ... into the Godot folder causes Godot 4.2 and 4.2.1 to crash. The solution is to quit Godot before you do the cargo build && cp ... and I just can't imagine quitting and restarting Godot every time I change a line of code.

If I can get past this pain point, I will test the next steps towards getting it working on my phone.

johnsonbaugh commented 8 months ago

I was able to export and run the book's Hello World project on an iPhone in 4.2.1. I had to disable the OpenXR APIs before it would work. I had no issues with the editor crashing.

Bromeon commented 8 months ago

@johnsonbaugh Great to hear! Apart from excluding OpenXR* classes, was there anything special you needed to configure?

What toolchain did you use?

johnsonbaugh commented 8 months ago

Using stable-aarch64-apple-darwin. Ultimately I think everything else I did was straightforward.

Added aarch64-apple-ios target:

rustup target add aarch64-apple-ios

Added .gdextension entries:

ios.debug.arm64 =        "res://../rust/target/aarch64-apple-ios/debug/librust_project.dylib"
ios.release.arm64 =      "res://../rust/target/aarch64-apple-ios/release/librust_project.dylib"

Built for iOS:

cargo build --target=aarch64-apple-ios
Bromeon commented 8 months ago

Great to hear! In gdnative we had a CI job to build iOS, based on cargo-dinghy. Probably we can reuse that here.

leanmendoza commented 6 months ago

For those who compiling without lazy-functions-table is throwring:

USER ERROR: Panic msg:
  Failed to load class method OpenXRAPIExtension::get_instance (hash 2455072627).
  Make sure gdext and Godot are compatible: https://godot-rust.github.io/book/gdext/advanced/compatibility.html
   at: <function unset> (/Users/user/.cargo/git/checkouts/gdext-76630c89719e160c/5e18af8/godot-core/src/lib.rs:107)

The issue is this because OpenXR module is not being included for iOS: https://github.com/godotengine/godot/blob/master/modules/openxr/config.py#L2

To make it work https://github.com/godot-rust/gdext/blob/master/godot-codegen/src/special_cases/special_cases.rs#L75 this line is going to be modified :D

EDIT: After https://github.com/godot-rust/gdext/pull/639 this should be fixed