第一种方法:在原生代码中修改源代码,而后提交到appStore,这个过程真是很漫长...虽然最近我提交的都是一两天就能获得反馈,可是没人能保证苹果的服务态度一直这样好.有可能10天半个月的也没时间给你审核.我把这个称为冷更新!git
第二种方法:就是利用一些三方平台.如今比较火的就是JSPatch以前有(Wax)了. 用官网 的介绍JSPatch 是一个开源项目(Github连接),只须要在项目里引入极小的引擎文件,就可使用 JavaScript 调用任何 Objective-C 的原生接口,替换任意 Objective-C 原生方法。目前主要用于下发 JS 脚本替换原生 Objective-C 代码,实时修复线上 bug。
总之个人认识就是:不用经过从新上架app项目到appstore即可以修改一些小问题!很大程度提升了开发以及维护的效率github
本地测试app
#import "ViewController.h"static NSString *identifer = @"cellID";@interface ViewController ()<UITableViewDataSource, UITableViewDelegate>@property (nonatomic, strong) UITableView *tableView;@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any 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 that 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行", indexPath.row]; return cell; } - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"OC--第%ld行", 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; }
而后添加 main.js文件ide
defineClass("ViewController", {tableView_didSelectRowAtIndexPath: function(tableView, indexPath) { console.log("JSPath--:",indexPath.row()); }})
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"OC--第%ld行", indexPath.row); }
使用JSPatch以前.gif测试
使用JSPatch以后.gifatom
线上发布新补丁.pngspa
//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; }
线上JSPathch.pngcode