bang590 / JSPatch

JSPatch bridge Objective-C and Javascript using the Objective-C runtime. You can call any Objective-C class and method in JavaScript by just including a small engine. JSPatch is generally used to hotfix iOS App.
MIT License
11.37k stars 2.24k forks source link

JSPatch.sync()後 js無作用, version 1.6.6 #814

Closed chengte99 closed 6 years ago

chengte99 commented 6 years ago

依照https://jspatch.com/Docs/error 文檔 使用 JSPatch.testScriptInBundle() 本地測試main.js 正常 改為補丁下發也可加載更新成功, 但main.js 卻無作用

log: 2018-03-16 11:27:47.285356+0800 TestJSPatch[17761:14146964] JSPatch: 尝试加载补丁 2018-03-16 11:27:47.285558+0800 TestJSPatch[17761:14146964] JSPatch: 当前没有补丁 2018-03-16 11:27:47.300961+0800 TestJSPatch[17761:14146964] JSPatch: sync请求:https://dn-jspatch.qbox.me/dev/e3679f87aec9279a/1.0.0?d=E8CD90AF-162E-44A3-8F42-1DA3FF3A2695&sv=1.6.6&v=1521170867.300845 2018-03-16 11:27:49.585523+0800 TestJSPatch[17761:14146980] JSPatch: sync请求成功:{ v = 3; } 2018-03-16 11:27:49.585745+0800 TestJSPatch[17761:14146980] JSPatch: 补丁版本没有更新

AppDelegate.swift: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch.

    JSPatch.setupCallback { (type, data, error) in
        if type == JPCallbackType.exception{
            if let data = data{
                assert(false, data["msg"] as! String)
            }
        }
    }

    JSPatch.start(withAppKey: "e3679f87aec9279a")
    #if DEBUG
        JSPatch.setupDevelopment()
    #endif
    JSPatch.setupRSAPublicKey("-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCvnBSplOVmbydik9cb1yfbYGVO\nP8e+P1sCZTvFlg84J3ts29APm9nj0ArSl0E5uBI/490BKsKyywUzeDjq0ML6jrKW\nnb1+4qJJ6duFdutiPGQz4zf0XEEVz0oo38raVXxdH9y0Xs61IiX1lufy0+QR+5rg\nakYu70LT/eV8NtYMJQIDAQAB\n-----END PUBLIC KEY-----")
    JSPatch.sync()
    // JSPatch.testScriptInBundle()

    return true
}

請問還有哪處有錯誤嗎?

bang590 commented 6 years ago

看起来没有错误,请确定main.js是否确实没有执行(通过在首行加console.log()),另外确定是否debug状态下请求到了开发模式的补丁。

Lishaoshuai commented 6 years ago

@chengte99 你解决了吗?我也遇到了同样的问题

chengte99 commented 6 years ago

@bang590 已在main.js首行加上console.log(), 在本地測試均正常印出,但補丁下載後依然沒有執行main.js 而log顯示補丁確實有更新.....

@Lishaoshuai 沒解決,請問你解決了嗎

Lishaoshuai commented 6 years ago

没有解决,发邮件与 JSPatch 管理员沟通也未能解决问题,管理员给我发了一个 1.7.4版本的 SDK,但我安装上之后报 no such module 的错误,尚未解决

bang590 commented 6 years ago

@@chengte99 SDK版本是否1.7.4?

chengte99 commented 6 years ago

@bang590 SDK版本為1.6.6 我通过 cocoapods 接入的 pod 'JSPatchPlatform' pod 'JSPatch/Extensions' pod 'JSPatch/JPCFunction'

Lishaoshuai commented 6 years ago

@chengte99 已解决,pod 的 1.6.6 版本的 SDK 有问题,切换成 1.7.4 之后就可以了,no such module 的问题是 给我的 1.7.4 的 framework 没有 module.modulemap 文件

chengte99 commented 6 years ago

@Lishaoshuai 感謝, 所以我應該要索取試用或付費取得1.7.4版對嗎?

Lishaoshuai commented 6 years ago

@chengte99 索取试用就可以,在 JSPatch 官网下方联系管理员索取

chengte99 commented 6 years ago

@Lishaoshuai 感謝!