For a client I've developed an iOS + Android
app using Cordova (PhoneGap)
for the user interface. Now, as an update to this app, I'm am attempting to add a game that was written in Haxe. Originally the game was written for the Flash target
, but I've updated it to work with the C++
targets for Android and iOS
.
On Android it was easy to integrate this with the Cordova
app using activities (the Haxe part runs as a separate activity), but I am having some trouble achieving a similar result on iOS.
So far I have tried to include all hxcpp
generated code in my project (in the same way that NME sets up the XCode project when you do "nme build ios"), and I'm calling hxRunLibrary()
from my code when I want the game to run.
The problem is that hxRunLibrary()
seems to want to create its own UIApplication
instance, which fails with the following error, since my main app is already running an instance:
*** Assertion failure in void UIApplicationInstantiateSingleton(Class)(), /SourceCache/UIKit_Sim/UIKit-2380.17/UIApplication.m:2037
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There can only be one UIApplication instance.'
I think it might have something to do with SDL, which Haxe uses for graphics. From what I understand SDL needs to run from the main function of the app, which created a conflict with Cocoa that also needs to run from the main function.
Is there any easy way around this? I've looked in the hxcpp sources, but been unable to find the UIApplication
related code, or any entry code for SDL.
Perhaps someone could point me in the right direction. Thanks!