[英]Running Haxe from iOS app – hxRunLibrary() error
For a client I've developed an iOS + Android
app using Cordova (PhoneGap)
for the user interface. 对于客户,我使用
Cordova (PhoneGap)
为用户界面开发了一个iOS + Android
应用程序。 Now, as an update to this app, I'm am attempting to add a game that was written in Haxe. 现在,作为这个应用程序的更新,我正在尝试添加一个用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
. 最初这个游戏是为
Flash target
编写的,但我已经更新它以使用Android and iOS
的C++
目标。
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. 在Android上,使用活动很容易将它与
Cordova
应用程序集成(Haxe部分作为单独的活动运行),但我在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. 到目前为止,我已经尝试在我的项目中包含所有
hxcpp
生成的代码(就像你在做“nme build ios”时NME设置XCode项目一样),并且当我想要的时候我从我的代码调用hxRunLibrary()
游戏运行。
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: 问题是
hxRunLibrary()
似乎想要创建自己的UIApplication
实例,由于我的主应用程序已经在运行实例,因此失败并出现以下错误:
*** 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. 我认为这可能与SDL有关,Haxe将其用于图形。 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.
根据我的理解,SDL需要从应用程序的主要功能运行,这与Cocoa产生冲突,也需要从main函数运行。
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. 我查看了hxcpp源代码,但无法找到
UIApplication
相关代码或SDL的任何入口代码。
Perhaps someone could point me in the right direction. 也许有人可以指出我正确的方向。 Thanks!
谢谢!
Well ,I have googled some information about Haxe . 好吧,我已经搜索了一些关于Haxe的信息。 what i understood is that The Haxe will prouduce a completed application for you .that mean it include the main Function .
我所理解的是,Haxe将为您完成一份完整的申请。这意味着它包括主要功能。 That's why the error is happend .
这就是错误发生的原因。
And you can simulate the problem by invoke UIApplicationMain Function twice . 您可以通过两次调用UIApplicationMain函数来模拟问题。
In my opinion , you have to remove the code about UIApplicationMain from the souce code file produced by Haxe. 在我看来,你必须从Haxe生成的源代码文件中删除有关UIApplicationMain的代码。
cordova has the ability to be integrated as part of a bigger application cordova能够作为更大应用程序的一部分进行集成
ran into the same issue. 遇到了同样的问题。
http://devgirl.org/2012/11/15/embed-cordovaphonegap-in-your-native-ios-app/ this article will help http://devgirl.org/2012/11/15/embed-cordovaphonegap-in-your-native-ios-app/这篇文章将有所帮助
you dont actually create a new project instead you embed it in a webview via the ios webview and cordova acts a subview. 你实际上并没有创建一个新项目,而是通过ios webview将它嵌入到webview中,而cordova则是一个子视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.