JSPath修复的具体步骤就是: 在main.js文件里面, 完成你要对哪个文件 + 哪个方法里面的操作进行修改, 然后先进行本地补丁修复, 然后将main.js文件传到JSPath上对应得APP应用上, 完成网上的修复。
下面开始吧。。。。。
首先, 登录JSPath官网注册账号
http://jspatch.com
第一步: 新增APP获取Appkey

输入APP的名字

获得AppKey

第二步: 到程序中设置
one: 到gitHUb上下载SDK
https://github.com/bang590/JSPatchPlatform.git
下载 SDK 后解压,将 JSPatchPlatform.framework 拖入项目中,勾选 "Copy items if needed",并确保 "Add to target" 勾选了相应的 target。
*添加 libz.dylib 和 JavaScriptCore.framework。

two:
在 AppDelegate.m 里载入文件,并调用 +startWithAppKey: 方法,参数为第一步获得的 AppKey。接着调用 +sync 方法检查更新。例子:
#import "AppDelegate.h"
//第一步: 引入头文件
#import <JSPatchPlatform/JSPatch.h>
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//APPKey: e948b3f13342d77d
//本地补丁测试时关掉下面两个方法
[JSPatch startWithAppKey:@"e948b3f13342d77d"];
[JSPatch sync];
//至此 JSPatch 接入完毕,下一步可以开始在后台为这个 App 添加 JS 补丁文件了。
//发布前进行本地补丁测试用的(本地补丁上传到网上时不能带有中文注释,否则不成功。 而且最好执行两遍才会有效果)
//[JSPatch testScriptInBundle];
return YES;
}
three:在ViewController中添加一个label
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
label.backgroundColor = [UIColor redColor];
label.text =@"aaa";
[self.view addSubview:label];
}```
#####four: 新建一个main.js 文件, 在里面完成补丁工作
在上传修复文件的时候, 最好不要有中文注释, 否则修复不成功

defineClass("ViewController", {
viewDidLoad:function(){
}
})```
- 首先打开Appdelegate中的
[JSPatch testScriptInBundle];
方法, 测试本地补丁修复结果, 若修复成功继续下一步。。。 - 将main.js文件从工程中移除去, 放到桌面上
- 在JSPath中,打开刚刚新建的APP



上传刚才的main.js补丁文件

完成修复喽 ~
网友评论