博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[转]编译 JavaScriptCore For iOS
阅读量:5153 次
发布时间:2019-06-13

本文共 4222 字,大约阅读时间需要 14 分钟。

from: http://phoboslab.org/log/2011/06/javascriptcore-project-files-for-ios

github: https://github.com/phoboslab/JavaScriptCore-iOS


 

Some weeks ago  a compiled version of the JavaScriptCore library for iOS as part of my . Since then I had many people asking for the project files necessary to build the library - and I promised to release them as well. But before I do so, let me just rant about Apple's politics real quick:

They suck.

You see, JavaScriptCore is an Open Source library. In fact the whole  is. It's licensed under BSD and LGPL licenses. The latter of which requires that if you modify the software you have to release your modified version – including the complete source – under the LGPL as well. Furthermore, it: "For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files,plus the scripts used to control compilation and installation of the library."

Yet the JavaScriptCore sources that you get from  come without a project file. So while you get the source code for the library, it's useless because you can't compile it.

Luckily you can also get the current JavaScriptCore sources directly from the  – and behold, they even come with an Xcode project file, ready to be build for MacOSX with the touch of a button. But – and here's the kicker – this project file curiously misses the iOS platform target. You can't build it for the iPhone or iPad.

Adding this iOS target to the project file is by no means a trivial endeavor, mind you. Especially not in Xcode. I ended up duplicating the MacOSX target, setting the Base SDK to Latest iOS, changing the Supported Platforms to iphoneos iphonesimulator and poking around in the project file with a text editor to change the productType to library.static, because you're not allowed to build a framework for iOS.

After some more changes that I can't remember (I'll be sure to document this next time I do it), I was finally able to compile the library for iOS. I submitted my game  to the App Store only to see that it was rejected the next day.

JavaScriptCore utilizes the libicucore library to sort strings in a unicode fashion. Apparently libicucore is a "private" API on iOS – which is curious because I can add this library to my iOS project without any dirty hacks, I'm just not allowed to use any functions of it. So I compiled JavaScriptCore again, this time setting theUCONFIG_NO_COLLATION preprocessor macro to disable unicode sorting.

Did I mention Apple's politics suck?

Update December 2nd 2012: an up-to-date version can be found on . The old version and instructions follow.

Anyway, here's the statically compiled libiOSJavaScriptCore.athat you can use in your iOS projects and the source and project file if you want to build it yourself for whatever reason:

  •  – compiled library
  •  – source code and project file

This all is based on the slightly outdated 534.27 version of JavaScriptCore, but at least this version seems to be AppStore compatible.

Using libiOSJavaScriptCore.a in your Project:

  • Copy the JavaScriptCore directory with the header files from the ZIP to your project folder and add them to your Xcode project
  • Copy the libiOSJavaScriptCore.a into your project folder
  • Add the libstdc++.dyliblibicucore.dylib from the list and the libiOSJavaScriptCore.a from "Add other..." 
  • import <JavaScriptCore/JavaScriptCore.h>

Building JavaScriptCore from the Source:

  • Select iOSJavaScriptCore iPhone as the active Scheme and build
  • Select iOSJavaScriptCore iPhone Simulator as the active Scheme and build
  • Navigate your terminal to the build directory: depending on your Xcode settings either build/Products/ directly in your project directory or~/Library/Developer/Xcode/DerivedData/JavaScriptCore-xxx/Build/Products/
  • Combine the ARM6/7 and x86 (Simulator) libs into one: lipo -create Production-iphoneos/libiOSJavaScriptCore.a Production-iphonesimulator/libiOSJavaScriptCore.a -output libiOSJavaScriptCore.a

Btw.: AppCelerator that they use in Titanium, but I have no idea how to build it. Any hints are greatly appreciated!

If you want to support me, please consider buying a license of . It also makes a great gift ;-)

转载于:https://www.cnblogs.com/Proteas/p/3573605.html

你可能感兴趣的文章
Hdu - 1002 - A + B Problem II
查看>>
Android设置Gmail邮箱
查看>>
js编写时间选择框
查看>>
JIRA
查看>>
小技巧——直接在目录中输入cmd然后就打开cmd命令窗口
查看>>
深浅拷贝(十四)
查看>>
HDU 6370(并查集)
查看>>
BZOJ 1207(dp)
查看>>
HDU 2076 夹角有多大(题目已修改,注意读题)
查看>>
洛谷P3676 小清新数据结构题(动态点分治)
查看>>
九校联考-DL24凉心模拟Day2T1 锻造(forging)
查看>>
Attributes.Add用途与用法
查看>>
L2-001 紧急救援 (dijkstra+dfs回溯路径)
查看>>
javascript 无限分类
查看>>
spring IOC装配Bean(注解方式)
查看>>
[面试算法题]有序列表删除节点-leetcode学习之旅(4)
查看>>
SpringBoot系列五:SpringBoot错误处理(数据验证、处理错误页、全局异常)
查看>>
kubernetes_book
查看>>
侧边栏广告和回到顶部
查看>>
https://blog.csdn.net/u012106306/article/details/80760744
查看>>