Dynamic hot patching technology in iOS jspatch Han Junqiang Blog

Source: Internet
Author: User

The so-called dynamic hot patching is a serious bug that can cause the app to crash, submit a new version to the AppStore audit is too slow to affect users, this time you can use

Jspatch allows you to write native IOS apps with JavaScript. Simply by introducing a very small engine into your project, you can use JavaScript to invoke any Objective-c native interface to gain the advantage of scripting languages: adding modules dynamically for a project, or replacing a project's native code to fix bugs dynamically.

Here is not to repeat the advantages and disadvantages of the focus on implementation!

Daily Update Attention :http://weibo.com/hanjunqiang Sina Weibo

(a) first in the terminal

Pod Search Jspatch

Next, you can get your own pod into the project you need to introduce, or download to your local project and search results as follows

-Jspatch(0.1.4)  JspatchBridgeObjective-C  and JavaScript. YouCan call anyObjective-C  class      and method in JavaScript by just   including a small engine.  Pod' Jspatch ',' ~> 0.1.4 '  -Homepage: https://github.com/bang590/Jspatch  -Source:https://github.com/bang590/Jspatch. git  -Versions: 0.1.4,0.1.3,0.1.2,0.1.1,0.1,0.0.3,0.0.2,0.0.1[Master  Repo]-0.1.4,0.1.3,0.1.2,0.1.1,0.1,0.0.3,0.0.2,0.0.1[master-1Repo  -Subspecs:  -Jspatch/Core(0.1.4)  -Jspatch/Extensions(0.1.4)Macxy:~ XY$

Generally we will execute the ". js" file on the server side each time the program startup can be executed than the local JS file and the server-side JS file whether there is a change here the details do not explain

-(BOOL) application: (uiapplication*)Application didfinishlaunchingwithoptions: (nsdictionary*)launchoptions {//Load engine  [Jpengine StartEngine];//Local JS, dynamic new technology is to get JS update by the server JS  NSString*sourcepath= [[NSBundle mainbundle] Pathforresource:@"Demo"OfType:@"js "];  NSString*script= [NSString stringwithcontentsoffile:sourcepath encoding:nsutf8stringencoding Error:nil];  [Jpengine Evaluatescript:script];  Getting updates from the server JS  [Nsurlconnection sendasynchronousrequest:[nsurlrequest Requestwithurl:[nsurl urlwithstring:@"http//cnbang. net/test.js"]] Queue:[nsoperationqueue Mainqueue] completionhandler:^ (nsurlresponse *response, NSData *data, Nserror *connectionerror) {    nsstring *script = [[NSString alloc] Initwithdata:data Encoding:nsutf8stringencoding];    //execute JS    [Jpengine evaluatescript:script];   }];}

This is the approximate process to give a small chestnut description of the specific application of JS replacement;

Daily Update Attention :http://weibo.com/hanjunqiang Sina Weibo

First, a section of JS file to explain how the OC and JS interaction How to access the OC API

//Button event defineclass (' Yfjspatchmainviewcontroller ', {///which class of method  function( button) {//Method Name: function (parameter)//Jump to TableView    var tableviewctrl = Yfjspatchtsetviewcontroller.alloc (). Init () Self.navigationcontroller (). pushviewcontroller_animated ( Tableviewctrl, YES)}})

I believe we all know how we're going to use it. For example, what I've written above is to find

Yfjspatchmainviewcontroller in this class.
-(void) Buttontouch: (UIButton) btn{} This method starts with nothing, and when the JS file is executed, the method executes JS  and then push The principle is that you have to use it yourself. I wish you a happy

Dynamic hot patching technology in iOS jspatch Han Junqiang Blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.