godot-rust / gdnative

Rust bindings for Godot 3
https://godot-rust.github.io
MIT License
3.62k stars 210 forks source link

How do I create an iOS app #972

Closed juliettebee closed 1 year ago

juliettebee commented 2 years ago

Hello, I have a project and I built the rust portion with cargo build --release --target aarch64-apple-ios and I put it in the GDNativeLibrary path thingy with that dylib. Then I followed the instructions in the documentation for Godot but I'm getting ERROR: does not have a library for the current platform when I run it. How can I fix this?

jacobsky commented 1 year ago

Unfortunately, we don't have much expertise in the project exporting to iOS as you might notice from the long time TODO in the iOS section.

Rust does support iOS out of the box, but there is no guide that we have available for this kind of scenario at the moment: https://godot-rust.github.io/book/faq/support.html?highlight=ios#which-platforms-are-supported

As GDNative is a kind of library this guide may be a good starting point: https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-06-rust-on-ios.html

Schr3da commented 1 year ago

@juliettebee I would like to share with you my tutorial (iOS Godot Tutorial). In the tutorial the most important step starts at 4:24 where you need to defined the gdnlib. Please note that this tutorial used an older version of the godot-rust lib however the same basics should apply.

Please note that in case you want to build a lib for all the different architectures on iOS the following code might also be useful for you. So this will generate all the libs. Next you could use lipo to combine the aarch64-apple-ios-sim and x86_64-apple-ios lib builds into one file

sample code: ` cargo build --target x86_64-apple-ios --release cargo build --target aarch64-apple-ios-sim --release cargo build --target aarch64-apple-ios --release

Simulator lib

lipo -create ./target/aarch64-apple-ios-sim/release/YOUR_LIB_NAME.a ./target/x86_64-apple-ios/release/YOUR_LIB_NAME.a -output ./ios_build/YOUR_LIB_NAME_SIM.a

Real Device lib

lipo -create ./target/aarch64-apple-ios/release/YOUR_LIB_NAME_SIM.a -output ./ios_build/YOUR_LIB_NAME_SIM.a `

Hope that helps

chitoyuu commented 1 year ago

Closing as answered :tada: