appcelerator/titanium_mobile — pull request #6450 by matt-langston (2014-12-07 19:45:40+00:00)
Title: [TIMOB-11093] iOS: Update Titanium to use Apple's JavaScriptCore that ships with iOS.

**DO NOT MERGE BEFORE PEER REVIEW**

This PR updates the iOS Titanium SDK to use the JavaScriptCore that Apple ships with iOS. As such, I have removed libTiCore.a and all references to tijscore from the Titanium SDK (i.e. project files, SCons, cli build hooks, etc.) since Apple's JavaScriptCore.framework provides this functionality.

This PR resolve issues pertaining to [TIMOB-11093](https://jira.appcelerator.org/browse/TIMOB-11093), particularly the recent crashers [TIMOB-18137](https://jira.appcelerator.org/browse/TIMOB-18137), [TIMOB-18135](https://jira.appcelerator.org/browse/TIMOB-18135) and [TIMOB-18118](https://jira.appcelerator.org/browse/TIMOB-18118). It can also resolve [TIMOB-18131](https://jira.appcelerator.org/browse/TIMOB-18131) quite easily (i.e. the "missing stack trace info" problem - see screenshots below) but I did not want to pursue further development on this effort without peer review and critical feedback on this "Apple JavaScriptCore" approach.

A few notes:
1. The goal of this PR is to demonstrate that the iOS Titanium SDK can use the JavaScriptCore.framework that ships with iOS. I have tested on both iOS Simulator and Device (iPhone 5s) for iOS 7.0, 7.1, 8.0 and 8.1.
2. This PR resolves the three P1 crashers [TIMOB-18137](https://jira.appcelerator.org/browse/TIMOB-18137), [TIMOB-18135](https://jira.appcelerator.org/browse/TIMOB-18135) and [TIMOB-18118](https://jira.appcelerator.org/browse/TIMOB-18118).
3. This PR demonstrates that Apple gives us rich stack trace information, and therefore can resolve [TIMOB-18131](https://jira.appcelerator.org/browse/TIMOB-18131) with minor effort.
4. I was able to easily provide efficient implementations of [TiValueIsArray](https://github.com/matt-langston/titanium_mobile/blob/TIMOB-11093_3_5_X-apple/iphone/Classes/TiBindingTiValue.m#L60-L67) and [TiValueIsDate](https://github.com/matt-langston/titanium_mobile/blob/TIMOB-11093_3_5_X-apple/iphone/Classes/TiBindingTiValue.m#L69-L76) in the Titanium SDK itself using only Apple's public JavaScriptCore API (previously these were provided by modifications to tijscore in [TiValueRef.h](https://github.com/appcelerator/tijscore/blob/master/TiCore/API/TiValueRef.h#L120-L136) and [TiValueRef.cpp](https://github.com/appcelerator/tijscore/blob/master/TiCore/API/TiValueRef.cpp#L123-L139) that used private API).
5. I am able to successfully use Apple's JavaScript debugger to debug Titanium applications (i.e. I can set breakpoints, inspect the call stack, variables, scripts, etc. - everything our Studio debugger provides to the best of my knowledge (however, I am no Studio debugger expert). Apple's debugger also lets me manipulate the running JavaScript of an iOS Titanium Application in a "Live View" type fashion.
6. This PR should provide access to Apple's new profiler as well (a very rich, sophisticated profiler I might add), but I have yet to explore this effort because I need peer review and critical feedback on this "Apple JavaScriptCore" approach.

A few screenshot that demonstrate the power (and simplicity) of using Apple's WebInspector to debug an iOS Titanium application:

![screenshot 2014-12-07 10 41 41](https://cloud.githubusercontent.com/assets/83967/5332284/e51cf08a-7e05-11e4-8655-407b6fd8e324.png)

![screenshot 2014-12-07 10 40 39](https://cloud.githubusercontent.com/assets/83967/5332287/f7e607c4-7e05-11e4-8e33-c0d4fd223118.png)

![screenshot 2014-12-07 10 29 19](https://cloud.githubusercontent.com/assets/83967/5332289/020ff228-7e06-11e4-83c0-b098bb6580fd.png)

![screenshot 2014-12-07 10 27 38](https://cloud.githubusercontent.com/assets/83967/5332290/0b52985e-7e06-11e4-8fcd-e5ba8b8f7dcc.png)