我想知道是否有人成功将一个javascript引擎/解释器移植到iOS.我正在编写一款iPhone游戏,我想使用Javascript作为高级脚本语言(AI,游戏等),但要做到这一点,我需要将JS引擎编译成静态库并将其链接我的iPhone OS的objectiveC程序.我正在看一些候选JS引擎,但我找不到任何成功案例.
这是我希望用于iOS的js引擎
另一种方法是使用UIWebView'sJavascript回调接口,但这需要将整个加载UIWebView到内存中,我听到的经验是性能通常很慢.
感谢是否有人有类似的经历或知道任何参考!
[更新]正如Kostis所说,Apple 在WWDC 2013中引入了JavascriptCore
我在使用xcodebuild在命令行中构建iOS动态框架时遇到此ld断言错误.
0 0x10163b342 __assert_rtn + 144
1 0x101678a3a archive::File<arm64>::makeObjectFileForMember(archive::File<arm64>::Entry const*) const + 1138
2 0x1016783e8 archive::File<arm64>::justInTimeforEachAtom(char const*, ld::File::AtomHandler&) const + 122
3 0x10168ea75 ld::tool::InputFiles::searchLibraries(char const*, bool, bool, bool, ld::File::AtomHandler&) const + 265
4 0x101697db8 ld::tool::Resolver::resolveUndefines() + 160
5 0x10169a117 ld::tool::Resolver::resolve() + 79
6 0x10163c060 main + 812
7 0x7fff9dd4c5ad start + 1
A linker snapshot was created at:
/tmp/MyKit-2016-02-31-154836.ld-snapshot
ld: Assertion failed: (memberIndex != 0), function makeObjectFileForMember, file /Library/Caches/com.apple.xbs/Sources/ld64/ld64-253.9/src/ld/parsers/archive_file.cpp, line 355.
clang: error: linker command failed with exit code 1 …Run Code Online (Sandbox Code Playgroud)