OGeek|极客世界-中国程序员成长平台

标题: ios - Javascript/Native 代码不同步(参数数量不同)错误 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 16:59
标题: ios - Javascript/Native 代码不同步(参数数量不同)错误

我最近从 1.24 更新到 ReactNativeControllers 2.03。我还将 RN 更新为 0.25。我正在使用仅添加 Podspec 文件的 fork。在整理出 RN 中的所有导入更改后,我现在被这个错误难住了:

(另见 https://github.com/wix/react-native-controllers/issues/59 )

RCCManager.setRootController was called with 3 arguments, but expects 2. If you haven't changed this method yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.

有问题的代码:

RCCManagerModule.m:

setRootControllerNSDictionary*)layout animationTypeNSString*)animationType globalPropsNSDictionary*)globalProps)

index.js中:

ControllerRegistry: {
    registerController: function (appKey, getControllerFunc) {
      _controllerRegistry[appKey] = getControllerFunc();
    },
    setRootController: function (appKey, animationType = 'none', passProps = {}) {
      var controller = _controllerRegistry[appKey];
      if (controller === undefined) return;
      var layout = controller.render();
      _validateDrawerProps(layout);
      RCCManager.setRootController(layout, animationType, passProps);
    }
  },

很明显,两者都有 3 个参数。

我已经杀死并重新启动了打包程序。我已经清理了包含派生数据的 Xcode 项目,并使用 watchman watch-del-all 删除了 watchman 缓存。我已经删除了我的 node_modules 文件夹,完成了 npm installpod install

我已经重建了 Xcode 项目。仍然没有运气。我不知道如何进一步调试。

编辑:我还尝试清理 pod 缓存,更新到 Cocoapods 1.01...

我觉得这里的某个地方可能有一条红鲱鱼。作为引用,我的完整跟踪如下所示:

2016-06-10 14:15:18.179 [warn][tid:com.facebook.React.JavaScript] Warning: ReactNative.Component is deprecated. Use React.Component from the "react" package instead.
2016-06-10 14:15:18.239 JustTuner[7523:185768] Launching Couchbase Lite...
2016-06-10 14:15:19.048 JustTuner[7523:185768] Couchbase Lite url = http://adamwilsonsMBP.lan:5984/
2016-06-10 14:15:19.050 JustTuner[7523:185768] Launching Couchbase Lite...
2016-06-10 14:15:19.058 JustTuner[7523:185768] Couchbase Lite url = http://adamwilsonsMBP.lan:5984/
2016-06-10 14:15:19.538 [error][tid:main][RCTModuleMethod.m:456] RCCManager.setRootController was called with 3 arguments, but expects 2.                   If you haven't changed this method yourself, this usually means that                   your versions of the native code and JavaScript code are out of sync.                   Updating both should make this error go away.



Best Answer-推荐答案


在花了很多时间试图解决这个问题后,我发现 build/Products/Debug-iphonesimulator 中有一个过时的静态库 libReactNativeControllers.a

删除 libReactNativeControllers.a 并重建项目解决了这个问题。

Pod 静态库现在似乎保存在它们各自的文件夹中,例如build/Products/Debug-iphonesimulator/ReactNativeControllers/libReactNativeControllers.a

我的猜测是最近的构建将静态库保存在子文件夹中,但链接器正在选择过时的库。任何人都知道为什么这可能最近发生了变化?

关于ios - Javascript/Native 代码不同步(参数数量不同)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37749590/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) Powered by Discuz! X3.4