接入jsPatch
- 第一步:
我们需要使用cocopods把jsPatch代码库导入到工程中,在 podfile中添加命令,然后执行pod install就可以将文件导入到工程中。当然,如果你太闲了,也可以手动将jsPatch代码库导入到工程中。下载 SDK 后解压,将 JSPatchPlatform.framework 拖入项目中,然后切记要勾选 "Copy items if needed",并确保 "Add to target" 勾选了相应的 target。
pod 'JSPatchPlatform'
然后我们就完成了导入frameWork的第一步。
- 第二步我们需要把相关的依赖库导入到工程中,和其他的大的sdk不同,jsPatch只需导入 libz.dylib和 JavaScriptCore.framework两个依赖库,具体操作为TARGETS -> Build Phases -> Link Binary With Libraries -> + 点击加号后输入我们要添加的依赖库的名字,就能将依赖库添加到工程中。
- 第三步是我们需要把在appdelegate文件中运行文件,在appdelegate中加入下面的代码,我们就完成了jsPatch的接入。
#import <JSPatchPlatform/JSPatch.h> @implementation AppDelegate -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [JSPatch startWithAppKey:@"你的AppKey"]; [JSPatch sync]; ... } @end
- 常见问题:
若使用 XCode8 接入,需要在项目 Capabilities 打开 Keychain Sharing 开关,否则在模拟器下载脚本后会出现 decompress error, md5 didn't match错误(如果是真机,则无论是否打开都没问题):

原文地址:http://www.jianshu.com/p/a0b582a3f6c3