Search code examples
iosreact-nativecocoapodsreact-native-navigation

Javascript / Native code out of sync (differing number of arguments) error


I have recently updated to ReactNativeControllers 2.03 from 1.24. I have also updated RN to 0.25. I am using a fork which only adds a Podspec file. After sorting out all the import changes in RN I am now stumped on this error:

(See also 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.

The code in question:

In RCCManagerModule.m:

setRootController:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps)

and in 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);
    }
  },

As is evident, both have 3 parameters.

I've killed and restarted the packager. I've cleaned the Xcode project including derived data, and deleted watchman cache with watchman watch-del-all. I've deleted my node_modules folder, done npm install and pod install.

I've rebuilt the Xcode project. Still no luck. I don't know how to debug this further.

EDIT: I also tried to clean the pod cache, updated to Cocoapods 1.01...

I have a feeling there may be a red herring here somewhere. For reference my full trace looks like this:

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.

Solution

  • After spending many hours trying to work this out, I found that there was an out of date static library libReactNativeControllers.a in build/Products/Debug-iphonesimulator.

    Deleting libReactNativeControllers.a and rebuilding the project solved the issue.

    It seems that the Pod static libraries are now being saved in their respective folders e.g. build/Products/Debug-iphonesimulator/ReactNativeControllers/libReactNativeControllers.a

    My guess is that the recent builds were saving the static lib in the subfolder, but the linker was picking up the out-of-date one. Anyone know why this might have changed recently?