[SOLVED] LibGDX and GameSparks, unrecognized selector sent to instance


We are using LibGDX together with GameSparks and are working on the iOS port of our game. GameSparks comes in two possible forms :

  • Sources (.h/.m files)
  • CocoaPods

CocoaPods way

I have not managed to make CocoaPods work with MOE. If I go into the “xcode” folder inside my MOE module, and type pod init, then pod install (so even with an empty PodFile). I get this warning :

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the targetios-moetoPods/Target Support Files/Pods-ios-moe/Pods-ios-moe.debug.xcconfigor include thePods/Target Support Files/Pods-ios-moe/Pods-ios-moe.debug.xcconfigin your build configuration (ios-moe/custom.xcconfig).

The only way I found to solve this warning was adding #include "Pods/Target Support Files/Pods-ios-moe/Pods-ios-moe.debug.xcconfig"to my xcode/ios-moe/custom.xconfig , but it got regularly resetted for some reason, erasing my include and making the warning appear again.

When trying to run my game with pods installed, I get this error :

diff: /Podfile.lock: No such file or directory diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

Any idea what my mistake is here ?

Sources way

I tried the other way of using the GameSparks SDK, downloading the sources. I put them in my MOE project, in a libs/sources folder. I then used the MOE plugin to generate bindings, following this : Help with the "Create New Binding" option in 1.3.x plugin .

Here is my NBC file : https://puu.sh/xubUI/52ad3dd690.png

This generates our Java binding classes, they look good. But when I use them, the game crashes.
alloc() and init() work, for example, but anything not static crashes. For example this code :

GSRegistrationRequest reg = GSRegistrationRequest.alloc().init();
        reg.setCallback(new GSRegistrationRequest.Block_setCallback() {
            public void call_setCallback(GSRegistrationResponse arg0) {
                System.out.println("CALLBACK OF REGISTRATION");

It crashes at reg.setUserName(“ios-test”). Same happens to setPassword or setCallback.

Here is the error :

/Users/rolandvigh/Migeran-1.3/moe/natj/natj/src/main/native/natj/NatJ.cpp:353 DEBUG: Method 'boolean java.lang.reflect.Method.isDefault()' is not accessible.
2017-09-08 03:42:34.969 iOSPORT[24042:1154233] -[GSRegistrationRequest setUserName:]: unrecognized selector sent to instance 0x7861a840

If we tick “bindings” instead of “hybrid” in the NBC file, it’s even worse :

/Users/rolandvigh/Migeran-1.3/moe/natj/natj/src/main/native/natj/NatJ.cpp:353 DEBUG: Method 'boolean java.lang.reflect.Method.isDefault()' is not accessible.
/Users/rolandvigh/Migeran-1.3/moe/natj/natj/src/main/native/natj/ObjCRuntime.mm:1478 WARNING: Binding class refers to class GSRequest, but it can not be found. Fallback to indirect super class.
/Users/rolandvigh/Migeran-1.3/moe/natj/natj/src/main/native/natj/ObjCRuntime.mm:1478 WARNING: Binding class refers to class GSRegistrationRequest, but it can not be found. Fallback to indirect super class.
2017-09-08 03:40:33.280 iOSPORT[23927:1150110] -[NSObject setUserName:]: unrecognized selector sent to instance 0x1409fd30  

Note that we did not do anything in XCode. Do we need to make some kind of link between Xcode and our .h/.m files ? If so, how do we do that exactly ?

Thanks in advance

So what you need is include custom.xconfig in Pods-ios-moe.debug.xcconfig, not include Pods-ios-moe.debug.xcconfig in custom.xconfig since custom.xconfig will be reseted by libgdx during build by the code in your build.gradle:

def outFlags = file( "xcode/ios-moe/custom.xcconfig" );
outFlags.write LD_FLAGS

I just tried that but did not manage to make it work.

  • I opened the project in xcode

  • I removed all configurations : https://puu.sh/xure3/90217caf4f.png

  • I did a pod init + pod install

  • I modified my xconfig file :

    #include “…/…/…/ios-moe.custom.xconfig”
    HEADER_SEARCH_PATHS = $(inherited) “${PODS_ROOT}/Headers/Public”
    OTHER_CFLAGS = $(inherited) -isystem “${PODS_ROOT}/Headers/Public”
    OTHER_LDFLAGS = $(inherited) -ObjC

(for some reason it’s writing …/ instead of ../, but it’s fine in the code)

I get this error logs : https://pastebin.com/GSPCYuCp (uploaded on pastebin, it was really long).

After doing all this, in xcode, the config has been automatically changed to Pods-ios-moe.debug .

I finally managed to make it work using the instructions there : Generating Java Bindings in 1.3 beta - How to do so?

There was some work needed on the gradle files considering xcworkspace file (the first answer with the detailed instructions) + the #include stuff since this is a LibGDX project.