JSPath修復(fù)的具體步驟就是: 在main.js文件里面蟆融, 完成你要對哪個文件 + 哪個方法里面的操作進(jìn)行修改饿敲, 然后先進(jìn)行本地補(bǔ)丁修復(fù), 然后將main.js文件傳到JSPath上對應(yīng)得APP應(yīng)用上, 完成網(wǎng)上的修復(fù)现横。
下面開始吧。。戒祠。骇两。。
首先姜盈, 登錄JSPath官網(wǎng)注冊賬號
http://jspatch.com
第一步: 新增APP獲取Appkey
新增
輸入APP的名字
app名字
獲得AppKey
appKey
第二步: 到程序中設(shè)置
one: 到gitHUb上下載SDK
https://github.com/bang590/JSPatchPlatform.git
下載 SDK 后解壓低千,將 JSPatchPlatform.framework 拖入項目中,勾選 "Copy items if needed"馏颂,并確保 "Add to target" 勾選了相應(yīng)的 target示血。
*添加 libz.dylib 和 JavaScriptCore.framework。
導(dǎo)入框架
two:
在 AppDelegate.m 里載入文件救拉,并調(diào)用 +startWithAppKey: 方法难审,參數(shù)為第一步獲得的 AppKey。接著調(diào)用 +sync 方法檢查更新亿絮。例子:
#import "AppDelegate.h"
//第一步: 引入頭文件
#import <JSPatchPlatform/JSPatch.h>
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//APPKey: e948b3f13342d77d
//本地補(bǔ)丁測試時關(guān)掉下面兩個方法
[JSPatch startWithAppKey:@"e948b3f13342d77d"];
[JSPatch sync];
//至此 JSPatch 接入完畢告喊,下一步可以開始在后臺為這個 App 添加 JS 補(bǔ)丁文件了。
//發(fā)布前進(jìn)行本地補(bǔ)丁測試用的(本地補(bǔ)丁上傳到網(wǎng)上時不能帶有中文注釋派昧,否則不成功黔姜。 而且最好執(zhí)行兩遍才會有效果)
//[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 文件, 在里面完成補(bǔ)丁工作
在上傳修復(fù)文件的時候蒂萎, 最好不要有中文注釋秆吵, 否則修復(fù)不成功
719E0692-4BC2-4C92-9F36-79CDB13347E6.png
defineClass("ViewController", {
viewDidLoad:function(){
}
})```
- 首先打開Appdelegate中的
[JSPatch testScriptInBundle];
方法, 測試本地補(bǔ)丁修復(fù)結(jié)果岖是, 若修復(fù)成功繼續(xù)下一步帮毁。。豺撑。 - 將main.js文件從工程中移除去烈疚, 放到桌面上
- 在JSPath中,打開剛剛新建的APP
上傳補(bǔ)丁
719E0692-4BC2-4C92-9F36-79CDB13347E6.png
FD43C3D0-DE09-4FB5-91C6-6AFBF5A2CDF3.png
上傳剛才的main.js補(bǔ)丁文件
3071BF3F-725D-43A1-8900-8E7A7CFA3C3F.png
完成修復(fù)嘍 ~