美文网首页
JSPath热修复

JSPath热修复

作者: by小杰 | 来源:发表于2016-09-29 12:11 被阅读222次

JSPath修复的具体步骤就是: 在main.js文件里面, 完成你要对哪个文件 + 哪个方法里面的操作进行修改, 然后先进行本地补丁修复, 然后将main.js文件传到JSPath上对应得APP应用上, 完成网上的修复。
下面开始吧。。。。。

首先, 登录JSPath官网注册账号
http://jspatch.com

第一步: 新增APP获取Appkey


新增

输入APP的名字

app名字

获得AppKey


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 文件, 在里面完成补丁工作

在上传修复文件的时候, 最好不要有中文注释, 否则修复不成功

719E0692-4BC2-4C92-9F36-79CDB13347E6.png

defineClass("ViewController", {

        viewDidLoad:function(){
        
        }
    })```
  1. 首先打开Appdelegate中的[JSPatch testScriptInBundle];方法, 测试本地补丁修复结果, 若修复成功继续下一步。。。
  2. 将main.js文件从工程中移除去, 放到桌面上
  3. 在JSPath中,打开刚刚新建的APP
上传补丁 719E0692-4BC2-4C92-9F36-79CDB13347E6.png FD43C3D0-DE09-4FB5-91C6-6AFBF5A2CDF3.png

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

3071BF3F-725D-43A1-8900-8E7A7CFA3C3F.png

完成修复喽 ~

相关文章

网友评论

      本文标题:JSPath热修复

      本文链接:https://www.haomeiwen.com/subject/okwkyttx.html