Generate Native Binding Document

Dear MOE Team!

Im new to MOE and trying to build my LibGDX game with MOE but i had some problem with binding native Objc framework. I did research but couldnt find any official doc about generate binding or i didnt look in the right place? Can you help me out please. What i did so far:

  • 1.3 beta 2 MOE and build LibGDX with newest setup jar.

  • Binded framework follow the official sample using .nbc file, got generation successful but when i use method from new binding it crashed with -[NSObject unrecognized selectorā€¦, tried proguard setting and not still got error message : Binding to class ā€¦ but not found.

  • Tried binding with cocoapod, change configure and included custom.xcconfig to pod configs but the building proccess showed the error message <MOE/MOE.h> not found in main.cpp class.

I would glad to hear any hint from other source and example. Thank you!

1 Like

Try to add an ObjC file and make calls to the framework there. And check if it works and linked properly. You can easily bind a C function from you own ObjC file.

1 Like

Dear Kirill!

Can you give me more hints please? Im working on LibGDX generated project so itā€™s diffrent i assume. I got the binding successful but the app crash when i called the function from it as i said earlier. Do you have any sample project beside official project from github that i can have a try please? Struggled for days :). Thanks for your reply!

Do you have a xcode project that you can open from xcode and run ?

1 Like

Dear Kirill!

Thank you so much with the hint ā€œlinked properlyā€, almost surrender and wait for official docs to come out and follow but today i give it another try and add framework manually and it work as you said. Last time i tried to integrate via Pod and didnā€™t linked objc properly so it was failed all the time. Thanks again for your reply, now im trying what more capable with native binding.

Dear Kirill!

I have another question, single class Objc can be binded too? I wrote a custom class and i tried to bind with header option in nbc file but it show error like : ā€œerror: expected a typeā€ which in .h file. Thank you.

Hi, I can not help here, sorry. I write bindings by hand.
What do you want to bind from C ?

1 Like

Hi,

Roland wrote a small tutorial in another post on how to create an NBC:

We are working on a proper tutorial, please stay tuned.

Best Regards,
Gergely

HI there!

At last i chose to bind direct from Objc then, not with custom class except for 3rd party lib. Today i deploy app on device and it crashed cause cant find binding class from framework but it ran fine on simulator. Do you have issue like that?

Hi,

can you share your project so we can take a look? Please also share the console output with the error message.

Best Regards,
Gergely

1 Like

Hi there!

Thanks for your reply! I attached a link to my project on MediaFire here so can you take a look at it. It ran ok on simulator but crash when i deloy it on device, showing message :

ā€œBinding class refers to class FBSDKLoginManager, but it can not be found. Fallback to indirect super class.
org.moe.natj.objc.ObjCException: -[NSObject logInWithReadPermissions:fromViewController:handler:]: unrecognized selector sent to instanceā€ when Facebook button pressed.

Link to my project : http://www.mediafire.com/file/zflhxcdyd4ji16h/Ahoho.zip

And i always have a warning when loading sound file : -[OALSimpleAudio internalPreloadEffect:reduceToMono:]: , maybe it loading from core using Robovm binding so MOE does not understand it i assume.

Thanks for your support!

Dear tthufo!

The FB framework you use seems to be a x86_64 only library. Where did you get that framework? We had a look at the one you can download from https://developers.facebook.com/docs/ios and it is for i386, armv7, x86_64 and arm64. I would suggest that either use that framework or have a look at https://github.com/multi-os-engine/moe-bindings to see how we use the FB frameworks.

Best Regards,
Roland

Hi there!
Thanks for your reply! I replace the framework with official ones and the problem still the same, cant find class. Iā€™ll come back when MOE more stable then, now i just stick to RoboVM OSS then. Thank you!

Hi,

Feel free to use RoboVM if it works better for you. However, I donā€™t see anything in your messages, that would point to a bug in MOE, so I donā€™t understand what you mean by ā€œmore stableā€.

Best Regards,
Gergely Kis

Open your XCode project, click the highest level item in the Project Navigator on the left (probably says ā€˜ios-moeā€™) and that will bring up all the settings. Click the Build Settings tab and under the Linking section find Other Linker Options. Double click the value for Debug (mine starts with ā€œ-sectcreateā€¦ā€) and click the plus button at the bottom. Type ā€œ-ObjCā€ without the quotes and hit enter. Do the same for release.

Now when you build, it will find your bindings classes assuming everything else is in order. Be prepared for more errors related to missing frameworks etc but those are much easier to solve than this problem. Official documentation cannot come soon enough :smiley: