gdnative: [ios] Unable to load GDNative library on iOS simulator

I manage to compile successfully build for iOS using this code:

#[macro_use]
extern crate gdnative;

#[derive(gdnative::NativeClass)]
#[inherit(gdnative::Sprite)]
struct Simpler;

#[gdnative::methods]
impl Simpler {
  fn _init(_owner: gdnative::Sprite) -> Self {
    Simpler 
  }

  #[export]
  unsafe fn _ready(&self, mut _owner: gdnative::Sprite) {
      godot_dbg!("Start");
  }

  #[export]
  unsafe fn _process(&mut self, mut owner: gdnative::Sprite, _delta: f64) {
    godot_dbg!("process called");
  }
}

fn init(handle: gdnative::init::InitHandle) {
  handle.add_class::<Simpler>();
}


godot_gdnative_init!();
godot_nativescript_init!(init);
godot_gdnative_terminate!();

But not able to run it on the device.

I added rustup target add aarch64-apple-ios and rustup target add x86_64-apple-ios then using cargo lipo to compile.

During compilation was no issue. Final steps I added compiled libsimpler.a into my simpler.gdns: simpler.gdns

After I exported to Xcode project and compile and run the sample on my Iphone I facing this bunch of errors (game doesn’t crash):

2020-05-15 11:28:25.835997+0800 Fc[365:10488] **ERROR**: Failed to obtain godot_gdnative_init symbol
2020-05-15 11:28:25.836034+0800 Fc[365:10488]    At: modules/gdnative/gdnative.cpp:342:initialize() - Failed to obtain godot_gdnative_init symbol
**ERROR**: Failed to obtain godot_gdnative_init symbol
   At: modules/gdnative/gdnative.cpp:342:initialize() - Failed to obtain godot_gdnative_init symbol
2020-05-15 11:28:25.836110+0800 Fc[365:10488] **ERROR**: No valid library handle, can't get symbol from GDNative object
2020-05-15 11:28:25.836165+0800 Fc[365:10488]    At: modules/gdnative/gdnative.cpp:483:get_symbol() - No valid library handle, can't get symbol from GDNative object
**ERROR**: No valid library handle, can't get symbol from GDNative object
   At: modules/gdnative/gdnative.cpp:483:get_symbol() - No valid library handle, can't get symbol from GDNative object
2020-05-15 11:28:25.836210+0800 Fc[365:10488] **ERROR**: No nativescript_init in "res://scripts/native/ios64/libsimpler.a" found
2020-05-15 11:28:25.836278+0800 Fc[365:10488]    At: modules/gdnative/nativescript/nativescript.cpp:1506:init_library() - No nativescript_init in "res://scripts/native/ios64/libsimpler.a" found
**ERROR**: No nativescript_init in "res://scripts/native/ios64/libsimpler.a" found
   At: modules/gdnative/nativescript/nativescript.cpp:1506:init_library() - No nativescript_init in "res://scripts/native/ios64/libsimpler.a" found

What exactly I did wrong? Why is not working?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 38 (2 by maintainers)

Most upvoted comments

Hey @toasteater,

finally had the chance again to look into the ios build way - unfortunately Im still unable to make it work. Do you have a instruction on how to do it - i tried to follow your description before but Im unable to make it work - If possible I would be also available for a call.

kind regards Georg