Jspatch, you can use JavaScript to invoke any Objective-c native interface to get scripting language capabilities by simply introducing a minimal engine into your project: dynamically update the app and replace the project native code to fix the bug.
Have you ever had this experience: the new version on the line found that there is a serious bug, may lead to crash rate surge, may make the network request can not be issued, at this time can do is to quickly fix the bug and then submit to wait for a lengthy appstore audit, and then look forward to users to upgrade quickly, pay huge human and time costs To complete the fix for this bug.
Using Jspatch can solve such problems, just introduce jspatch in the project, you can find the bug when the JS script patch, replace the native method, no need to update the app to fix the bug immediately.
@implementation Jptableviewcontroller ... -(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) indexpath{ *content = Self.datasource[[indexpath row]]; // may exceed array range resulting in crash Jpviewcontroller *ctrl = [[Jpviewcontroller alloc] initwithcontent:content]; [Self.navigationcontroller Pushviewcontroller:ctrl];} ... @end
Taking an array element in the code above may cause crash to be outside the array range. If Jspatch is referenced in the project, a JS script can be issued to fix the bug:
// js defineclass ( " jptableviewcontroller " { // instance method definitions Tableview_didselectrowatindexpath:function (TableView, Indexpath) {var row = Indexpath.row () if ( Self.datasource (). length > Row) {// Add the logical var content = Self.dataarr () [row]; var ctrl = Jpviewcontroller.alloc (). initwithcontent (content); Self.navigationcontroller (). Pushviewcontroller (ctrl); } }}, {})
This jptableviewcontroller in the-tableview:didselectrowatindexpath: replaced by this JS script implementation, the user is not aware of the situation fixed the bug.
Principle
Jspatch uses iOS built-in javascriptcore.framework as the JS engine, but does not use its Jsexport features for Js-oc function intermodulation, but through the objective-c Runtime, Transfer the class name function name from JS to Objective-c, and then use Nsinvocation to invoke the corresponding OC method dynamically.
Jspatch is more in line with Apple's rules. IOS Developer Program License Agreement 3.3.2 mentions that executable code cannot be issued dynamically, except for code executed by Apple Javascriptcore.framework or WebKit, JS is executed by Javascriptcore.framework.
Dynamic Update scenario comparison: Jspatch vs React Native
iOS Development hot Update Jspatch