wix-incubator / react-native-controllers

Native IOS Navigation for React Native (navbar, tabs, drawer)
MIT License
611 stars 82 forks source link

RCCManager.setRootController was called with 3 arguments, but expects 2. #59

Closed adamski closed 8 years ago

adamski commented 8 years ago

I'm getting this error now, after updating to 2.03 but can't seem to track down why ... I'm using a fork but only adding a Podspec and the rest should be identical. Any ideas? I've deleted my node_modules folder, npm install and done a pod install but still getting this error...

artald commented 8 years ago

I don't know which version you had before, but maybe the native code is not in sync with the JS code.

In version 1.2.6 the setRootController method was changed to receive an additional parameter, but this is not a breaking change since the JavaScript wrapper takes care of the the default value.

The only option I see for this error to happen is if the native code in your project is not up to date and your JS code is (native code is older and receives 2 parameters and the JS code is newer and sends 3 parameters).

If this is not the case - have you tried to:

adamski commented 8 years ago

I've killed and restarted the packager. I've cleaned the Xcode project inc derived data, and watchman watch-del-all. No joy yet...

artald commented 8 years ago

Did you try to check if the issue is because of the "out of sync" reason I mentioned?

In the native code in RCCManagerModule.m look at the setRootController method; It should get 3 arguments: layout, animationType, globalProps. This should match index.js having a call with 3 arguments for setRootController: RCCManager.setRootController(layout, animationType, passProps).

adamski commented 8 years ago

Yes I had a look, the definition i see is:

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

adamski commented 8 years ago

Unless there is some other layer of caching I have not yet found....!?

artald commented 8 years ago

The code seems to be in sync.. Very weird.

adamski commented 8 years ago

The previous working version I was using was 1.2.4 so that accounts for the error thats coming up, but have no idea why. About to rebuild the Xcode project to see if that helps..

adamski commented 8 years ago

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. Simply deleting it and rebuilding 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.