美文网首页
React-native 新手遇到的坑

React-native 新手遇到的坑

作者: 那位小姐 | 来源:发表于2018-05-03 12:44 被阅读150次

    问题1:报错“Could not connect to development server.” 如图所示

    image

    原因:没有启动ReactNative的服务
    解决方案:打开终端 进入node_modules所在的文件夹根目录-输入: react-native start 服务开启后,在模拟器上command+r 刷新

    问题2:报错“unable to resolve module 'react-navigation' from ...”
    Clear watchman watches: watchman watch-del-all.
    Delete the node_modules folder: rm -rf node_modules && npm install.
    Reset packager cache: rm -fr $TMPDIR/react-* or npm start --reset-cache.

    如图所示

    image

    解决方案:
    在package.json加入下面这句话,然后从新nom install 和pod install
    "react-navigation": "git+https://github.com/react-community/react-navigation.git#7edd9a7"

    "dependencies": {
        "react": "16.0.0-alpha.6",
        "react-native": "0.43.4",
        "react-navigation": "git+https://github.com/react-community/react-navigation.git#7edd9a7"
      },
    

    问题3:“Native module cannot be null.”

    image

    原因:Xcode项目导入的ReactNative的依赖少了
    解决方案:加入RCTLinkingIOS

    pod 'React', :path => ‘./ReactNative/node_modules/react-native', :subspecs => [
            'Core',
            'ART',
            'RCTActionSheet',
            'RCTAdSupport',
            'RCTGeolocation',
            'RCTImage',
            'RCTNetwork',
            'RCTPushNotification',
            'RCTSettings',
            'RCTText',
            'RCTVibration',
            'RCTWebSocket',
            'RCTLinkingIOS',
        ]
    
    

    问题4:xcode 运行报yoga.h 找不到 或者报错yoga.c之类的 请升级版本至0.52以上

    问题5:cocopod 与xcode打包上传问题 也是困恼我几天的问题

    image.png

    原因


    image.png

    libraries 里面的react和cocopod里面的react文件冲突了

    解决方案1:


    image.png

    注释掉这两个,打包可以,但是debug错误

    解决方案2:在Linked Frameworks and Libraires 删除所有的RCT 就可以打包了

    解决方案3:删除pod 里面的React文件夹

    最后我在群里413381701 得到了解决 这个群大牛很多并且乐意助人

    相关文章

      网友评论

          本文标题:React-native 新手遇到的坑

          本文链接:https://www.haomeiwen.com/subject/vbpkrftx.html