ios:在原有项目中手动集成react-native,报模块名 null 错误



  • ios:在原有项目中手动集成react-native(非cocoapods,官网上rnpm{安装依赖的命令没用})

    参考地址:http://reactnative.cn/docs/0.31/linking-libraries-ios.html#content

    运行奔溃,日志输出如下:
    2016-09-02 16:37:57.780 [error][tid:com.facebook.react.JavaScript] Native module cannot be null. 2016-09-02 16:37:57.793 [error][tid:com.facebook.react.JavaScript] Requiring module "187", which threw an exception. 2016-09-02 16:37:57.794 TestRNDemo[3248:89149] -[RCTRootView reactTag]: unrecognized selector sent to instance 0x7fa960c39740 2016-09-02 16:37:57.800 TestRNDemo[3248:89149] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RCTRootView reactTag]: unrecognized selector sent to instance 0x7fa960c39740


    至于原有工程中 关于react-native代码如下:
    项目工程名TestRNDemo, viewController中:
    let jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURLForBundleRoot("Demo2", fallbackResource: nil) let rootView = RCTRootView.init(bundleURL: jsCodeLocation, moduleName: "TestRNDemo", initialProperties: nil, launchOptions: nil) self.view = rootView


    至于js的代码如下:

    class TestRDemo extends Component{
      render(){
          return(
            <View style={{padding:0,backgroundColor:'skyblue'}}>
            <Text>How Wonderful the ???</Text>
            </View>
             );
       }  
    }
    AppRegistry.registerComponent('TestRNDemo',()=>TestRDemo)
    

    是我少加了什么吗?

    0_1472807020403_屏幕快照 2016-09-02 下午5.01.12.png

    0_1472807388340_屏幕快照 2016-09-02 下午5.08.06.png

    0_1472807397941_屏幕快照 2016-09-02 下午5.01.35.png

    0_1472807403612_屏幕快照 2016-09-02 下午5.00.44.png



  • 请问楼主怎么解决的


登录后回复