Hello guys,
I used LibGDX 1.9.10 and MOE 1.7.4 to create my IOS app.
I use Xcode to and test it on my IOS device. Actually everything were fine - it work properly on
device .
But when i tried to install some Admob / Firebase SDK inside âapplicationDidFinishLaunchingWithOptionsâ -> problem up:
It said : âapplicationDidFinishLaunchingWithOptions(UIApplication, NSDictionary<?, ?>)â in âcom.game.IOSMoeLauncherâ clashes with âapplicationDidFinishLaunchingWithOptions(UIApplication, NSDictionary<String, ?>)â in âapple.uikit.protocol.UIApplicationDelegateâ; both methods have same erasure, yet neither overrides the other
Here my IOSMoeLauncer.java:
public class IOSMoeLauncher extends IOSApplication.Delegate {
protected IOSMoeLauncher(Pointer peer) {
super(peer);
}
IOSApplication application;
MyGame game;
@Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
config.useAccelerometer = false;
game = new MyGame();
application = new IOSApplication(game, config);
return application;
}
public static void main(String[] argv) {
UIKit.UIApplicationMain(0, null, null, IOSMoeLauncher.class.getName());
}
@Override
public void applicationDidBecomeActive(UIApplication application) {
// Gdx.app.log("TEST", "applicationDidBecomeActive");
super.applicationDidBecomeActive(application);
}
@Override
public boolean applicationDidFinishLaunchingWithOptions(UIApplication application, NSDictionary<?, ?> launchOptions) {
// I want to install some sdk here
return super.applicationDidFinishLaunchingWithOptions(application, launchOptions);
}
@Override
public void applicationDidFinishLaunching(UIApplication application) {
//Gdx.app.log("TEST", "applicationDidFinishLaunching");
super.applicationDidFinishLaunching(application);
}
}
Any solutions for this one?? I look forward and appreciate your help!!
Regards!!
The problem here is that the MOE version the libgdx backend was build for doesnât match the MOE version you are using. The parameters of " applicationDidFinishLaunchingWithOptions
" changed from NSDictionary<?, ?> to NSDictionary<String, ?> in this commit: https://github.com/multi-os-engine/moe-core/commit/9d3ddbf02cf21cf1e96f19501b2b3899d58a94be
So there are three options I think:
- Use an older MOE version.
- Donât use IOSApplication.Delegate. A option how you could do it can be found here: https://github.com/multi-os-engine/moe-samples-java/blob/moe-svm/LibGDXMissileCommand/ios/src/main/java/org/moe/libgdxmissilecommand/ios/Main.java
- Build LibGDX from source with an updated MOE backend. (I have a repo for this but it is currently just for MOE 2.0. But it can be easily adjusted to MOE 1.x. Just some file deletion I think). With this you could also have LibGDX use Metal instead of the deprecated OpenGLES. If this would be the way you want to go I could give you further informations.
1 Like
Ohh hey @Berstanio!! Thank for your help
Actually I already fixed my code. I have checked and followed the instructions from this post:
https://discuss.multi-os-engine.org/t/launch-a-libgdx-game-using-moe-from-ios-storyboard/1005/12
- So I did change my IOSMoeLauncher.java
- Created a new AppViewCotroller
- Created a new Main.Storyboard and link the View
It took me a little time to reseach and adjust to the above changes Now i can run my app on IOS Devices and I also added some SDK from GoogleAdmob and Firebase.
But due to my lack of experience with handling these above, so my app has new probs
- Config the View to make it Fullscreen on all IOS devices.
- Try to freeze my orientation. My app is landscape but after show an Interstitial or VideoReward -> It became Potrait?? Please check my demo images:
Right Orientation.
Orientation changed after see ads :))
I will try to fix these above and also try your methods. Hope that i wont have more probs !!
Thank you!!
Hi @Berstanio!! Hope you have a nice day
I fixed my app by following your suggestion
https://github.com/multi-os-engine/moe-samples-java/blob/moe-svm/LibGDXMissileCommand/ios/src/main/java/org/moe/libgdxmissilecommand/ios/Main.java
So here what i changed:
- Changed everything inside the IOSMoeLancher . Instead of IOSApplication.Delegate -> I used UIApplicationDelegate.
- Create a new class MyIOSApplication extends IOSApplication.
- Remove the Main.storyboard & AppViewController . Now i created my app inside the applicationDidFinishLaunchingWithOptions .
- Use Metal instead of OpenGLES.
- My app have proguard , so i added this: -keep class apple.uikit.protocol.UIApplicationDelegate { *; } inside my proguard.
With the above changes, now i can run and test my app on my IOS devices.
Remove the storyboard and view -> so bye bye 2 probs in my last repiled
Now i need to add some Firebase Crashlystic and RemoteConfig to test and track my app before release it to the app store
Once again, thank for your help!! It has saved me more time instead of having to research by myself.
Regards.
Ah thats great to hear!
About the 2. point. Here I forgot to mention something about the sample I gave you ( https://github.com/multi-os-engine/moe-samples-java/blob/moe-svm/LibGDXMissileCommand/ios/src/main/java/org/moe/libgdxmissilecommand/ios/Main.java ). The sample was updated to support MOE 2.0. In order to do that I needed to replace the old LibGDX MOE Logger with a updated one because the old Logger relied on some art libraries. So creating the MyIOSApplication class should be only needed for MOE 2.0, not for MOE 1.x which you are using. Therefor I think you could delete this class and use the standard âIOSApplicationâ.
Just curios about the 4. point. How did you switched to Metal? Have you found my repository?
Okay thanks for your info!
- I had fix my app. So i deleted MyIOSApplication class.
- Yeah when i used Xcode to build a demo on my IOS device. It said OpenGLES was deprecated , and use Metal instead. So I just followed that.
About the second point: The switching from OpenGLES to Metal needs to be done in LibGDX. Have a look here: https://github.com/libgdx/libgdx/blob/af899350378fc0908eb26867b8cc44fd3cfdce7c/gdx/jni/iosgl/iosgl20.cpp#L6-L7 This is the file that creates the OpenGL calls for LibGDX and as you see it imports the OpenGLES header. And switching from OpenGLES to Metal is sadly not easy for LibGDX.
But there is a project called âMetalANGLEâ which creates from OpenGL calls Metal calls. I implemented this in a fork of LibGDX and if you want to test/use this, this would be the steps:
- change the libGDX Version to 1.10.1-SNAPSHOT
- add this maven repository with âmaven { url âhttps://s01.oss.sonatype.org/content/repositories/snapshots/â }â
- Change the artifacts:
âcom.badlogicgames.gdx:gdx-backend-moe:$gdxVersionâ
âcom.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-iosâ
to
âio.github.berstanio:gdx-backend-moe-art-metalangle:$gdxVersionâ
âio.github.berstanio:gdx-platform:$gdxVersion:natives-ios-metalangleâ
- Replace this line
if (jar.name.endsWith("natives-ios.jar")) outputDir = file("xcode/native/ios")
with this line
if (jar.name.matches(".*natives-ios.*")) outputDir = file("xcode/native/ios")
- Add Metal AND OpenGLES(donât know really why but is still needed for some EAGL stuff.) in XCode to the Frameworks
Then everything should work the same as before, just faster! But keep in mind that this isnât as well tested as the standard libGDX OpenGL implementation.
P.S: If you are working with the MOE Version 1.9.0-SNAPSHOT this wont work out of the box. You would need to add â-lc++â as a custom linker flag. But since you are using MOE 1.7.4 this shouldnât be a problem for you. Later this will be probably again the default behavior(https://github.com/multi-os-engine/multi-os-engine/issues/143).