xcode 10 安装 react-native 踩坑日常

安装 third-party

node_modules 在重新安装的时候,报错如下

'config.h' file not found

主要原因在于 ./node_modules/react-native/third-party 下的文件没有被完整下载。

google 找到的方法整理如下:

  1. cd node_modules/react-native/scripts 下面,执行 ./ios-install-third-party.sh
    • 执行脚本安装,执行完成后在 scripts 有一个 third-party 文件夹,移动到 react-native 目录下
  2. cd cd node_modules/react-native/third-party/glog-0.3.4,执行 ../../scripts/ios-configure-glog.sh
    • 这个脚本的作用是 check .h 头文件的引用情况,然后建立关联关系。

    • 关于为什么要到 glog 目录下载执行脚本,这是因为该脚本里面会先执行了 ./configure,configure 在 glog 目录下面

    • 在执行 ./configure 的时候,很难受又遇到错误,真的是很难受了🤕,但是很良心的给了一个建议 configure: error: C compiler cannot create executables,Why? 谷歌告诉你答案 ---- 交叉编译。这个可能跟我之前装了多个 Xcode 有关,虽然我现在只保留了最新版的 Xcode 10,但是不排除 command line tool 的路径不对。

      xcode-select -p(--print-path) 
      sudo xcode-select -s(--switch) xxx(上面命令输出的地址)
      

      按照上面的步骤执行了一遍,但是,此时只想来一句 mmp

      既然里面是先执行了 configure 的脚本,那么我 就先分开执行吧

      ./configure
      

      然后,就🙃

      configure: error: cannot run C compiled programs.
      If you meant to cross compile, use `--host'.
      See `config.log' for more details
      

      但是注意这里它告诉我们可以使用 --host,好像看到了胜利的希望?

      ./configure --host
      
      configure: error: missing argument to --host-alias
      

      告诉你需要给一个 host 别名 🙃🙃

      gcc --version  或者
      
      llvm-gcc --version  
      

      输出

      Apple LLVM version 10.0.0 (clang-1000.11.45.5)
      Target: x86_64-apple-darwin18.0.0 # 就是你了
      Thread model: posix
      InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
      

      现在我们执行

      ./configure --host x86_64-apple-darwin18.0.0
      

      终于成功了 撒花 🎉🎉🎉

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容