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

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


Some weeks ago I released a compiled version of the JavaScriptCore library for iOS as part of my game engine. 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 WebKit project 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, itstates"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 Apple's Open Source page 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 SVN repository – 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 Biolab Disaster 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 github. 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:

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..." like so
  • 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 maintains their own version of JavaScriptCorethat 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 my game engine. It also makes a great gift ;-)

最新文章

  1. LinqToDB 源码分析——生成表达式树
  2. CRM 2013 限制Lookup
  3. java中解决组件重叠的问题(例如鼠标移动组件时)
  4. elastic search查询命令集合
  5. c#.net 调用BouncyCastle生成PEM格式的私钥和公钥
  6. 查找当前SQL Server下的Active Session正连接着哪个数据库
  7. Sass学习
  8. URL加载系统----iOS工程师必须熟练掌握
  9. 你的App为什么上不了TOP10?
  10. IP包头
  11. CTR预估中的贝叶斯平滑方法及其代码实现
  12. linux_发邮件
  13. CPU温度的实现
  14. python读取excel(xlrd)
  15. 转:StarUML3.0的破解方法
  16. Unity下Iso和Persp两种模式的区别
  17. #define a int[10]与 typedef int a[10]用法
  18. P2054 [AHOI2005]洗牌
  19. java-关于getClass().getClassLoader()
  20. OC基础之访问修饰符

热门文章

  1. EF 增删改查 泛型方法、类
  2. ASP.NET MVC+EF框架+EasyUI实现权限管理系列(15)-用户登录详细错误和权限数据库模型设计
  3. Effective C++ 18-23
  4. java_eclipse_maven_svn_主题彩色插件_全屏插件
  5. ACM经典算法之字符串处理:字符串替换
  6. ASP.NET学习笔记2--自己写代码绑定Gridview
  7. 关于Android开发中导出jar包后的资源使用问题解决
  8. 请确保在编译时已将“AjaxControlToolkit.Properties.Resources.NET4.resources”正确嵌入或链接到程序集“AjaxControlToolkit”
  9. Windows,查看进程的连接的IP地址,批量模式,最后做成Excel
  10. Linux的错误码