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