What is a hot update? For example, your app is on the shelves, but suddenly want to add a small feature, then you have two ways
The first method: To modify the source code in the native code, and then submit to AppStore, this process is really long ... Although I have recently submitted a couple of days to get feedback, but no one can guarantee that Apple's service attitude has been so good. There may be 10 days and half a month and no time for you to review. I call this cold update!
The second approach is to take advantage of a few tripartite platforms. Now the comparison of the fire is Jspatch before (Wax). With the introduction of the official website in JSPatch 是一个开源项目(Github链接),只需要在项目里引入极小的引擎文件,就可以使用 JavaScript 调用任何 Objective-C 的原生接口,替换任意 Objective-C 原生方法。目前主要用于下发 JS 脚本替换原生 Objective-C 代码,实时修复线上 bug。
Short, I know that: do not have to re-shelves app project to AppStore can modify some small problems! Increased efficiency in development and maintenance to a large extent
Jspatch SDK Access Jspatch basic usage Finally, print a HelloWorld with the Jspatch platform.
#import"ViewController.h"StaticNSString *identifer =@ "Cellid";@interfaceViewcontroller () <Uitableviewdatasource,Uitableviewdelegate>@property (Nonatomic,Strong)UITableView *tableview;@end@implementationviewcontroller-(void) Viewdidload {[Super Viewdidload];Additional setup after loading the view, typically from a nib.NSLog (< #NSString * _nonnull format, ...#>) [Self. View Addsubview:Self. TableView];} - (void) Didreceivememorywarning {[Super didreceivememorywarning];Dispose of any resources the can be recreated.} - (UITableView *) TableView {if (!_tableview) {_tableview = [[UITableView Alloc] initWithFrame:Self. View. Bounds Style:Uitableviewstyleplain]; _tableview. DataSource =Self _tableview. Delegate =Self [_tableview registerclass:[ UITableViewCell class] forcellreuseidentifier:identifer]; } return _tableview;} -( Nsinteger) TableView: ( uitableview *) TableView numberofrowsinsection: ( Nsinteger) Section { return 4;} -( UITableViewCell *) TableView: ( uitableview *) TableView Cellforrowatindexpath: ( Nsindexpath *) Indexpath { UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:identifer]; cell . Textlabel . Text = [ nsstring stringWithFormat: @ "%ld line", Indexpath . row]; return cell;} -( void) TableView: ( uitableview *) TableView Diddeselectrowatindexpath: ( Nsindexpath *) Indexpath { NSLog ( @ "oc--%ld line", Indexpath . row);} @end
//APPDelete.m- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch.// [JSPatch startWithAppKey:@"891dfb388fe263a1"];// [JSPatch sync]; [JSPatch testScriptInBundle]; return YES;}
Then add the Main.js file
defineClass("ViewController", {tableView_didSelectRowAtIndexPath: function(tableView, indexPath) { console.log("JSPath--:",indexPath.row()); }})
The Main.js file above will be automatically called when the app is launched: The function is to cover this method in the Viewcontroller.
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"OC--第%ld行", indexPath.row);}
This is the result of the program running before calling the Main.js file.
Before using Jspatch. gif
This is the result of the program running after calling the Main.js file.
After using Jspatch. gif
Here you should have seen this jspatch powerful! This is only a local test, when you want to modify the program content, you have to modify the Main.js file online test (in fact, the Main.js file to jspathch backstage)
New patches are posted on the line. png
Then modify the code in the APPDELETE.M
//APPDelete.m- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. //891dfb388fe263a1 这个是你在JSPatch后台创建应用的时候自动生成的appKey [JSPatch startWithAppKey:@"891dfb388fe263a1"]; [JSPatch sync];// [JSPatch testScriptInBundle]; /** 同时删除本地的main.js文件 */ return YES;}
On-line Jspathch.png
Finally attached to GitHub source code: https://github.com/yuzhouheike/jspathch-
Ios+jspatch Online Modify app function-B