做了个安卓的app,打算试试打包ios。但是mac中遇到许多挑战。在这记录下。
刚开始就是按照文档的操作的,
实际上这里Watchman 不是必须的, 这是监听文件变化然后自动同步更新模拟器效果的,完全可以修改后自己重新打包看效果,毕竟可以用windos来写代码开发。在mac只是打包成ios格式的app而已。然而我的是mac10.15 Catalina.也不支持安装。
这里有个前提,就是一定要使用代理。在终端输入
export http_proxy=http://proxyAddress:port
export https_proxy=http://proxyAddress:port
运行
brew install watchman
报错
Last 15 lines from /Users/lllomh/Library/Logs/Homebrew/folly/02.cmake:
AsyncSocket::setSendMsgParamCB(&sendMsgCob_);
^~~~~~~~~~~~~~~~~
/tmp/folly-20230815-30381-1s1x4l8/folly-2023.08.07.00/folly/io/async/fdsock/AsyncFdSocket.cpp:136:16: error: cannot initialize object parameter of type 'folly::AsyncSocket' with an expression of type 'folly::AsyncFdSocket'
AsyncSocket::releaseIOBuf(std::move(buf), callback);
^~~~~~~~~~~~
/tmp/folly-20230815-30381-1s1x4l8/folly-2023.08.07.00/folly/io/async/fdsock/AsyncFdSocket.cpp:298:18: error: cannot initialize object parameter of type 'folly::AsyncSocket' with an expression of type 'folly::AsyncFdSocket'
AsyncSocket::failRead(__func__, ex);
^~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/folly_base.dir/folly/io/async/fdsock/AsyncFdSocket.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/folly_base.dir/all] Error 2
make: *** [all] Error 2
Do not report this issue to Homebrew/brew or Homebrew/homebrew-core!
Error: You are using macOS 10.15.
We (and Apple) do not provide support for this old version.
It is expected behaviour that some formulae will fail to build in this old version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from Homebrew or its maintainers on social media.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.
这个当然没影响,这里只是记录我的过程。
接下来就是安装
这个最麻烦的,使用代理的情况下,安装有几个可能出现的错误,一个是网络延时。则需要多次反复尝试。有可能会 报错说要你安装 brew install gcc。 还有可能会要你报错 ruby 相关的。 这多半是使用的mac自带的ruby版本过低导致的。可以先用 react-native doctor 检查下环境是否完整.下面是命令历史记录
511 brew install cocoapods
512 brew install gcc
513 brew install gcc
514 brew update-ca-certificates
515 brew install cocoapods
516 brew install cocoapods
517 brew install watchman
518 npm run ios
519 react-native doctor //检环境可以直接修复,需要安装java sdk
520 react-native doctor
521 brew cleanup cocoapods
522 react-native doctor
523 ruby -v
524 which -a ruby
525 brew install ruby //安装新的版本的 ruby 执行会显示新的版本
526 brew reinstall ruby
527 brew cleanup ruby
528 echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc //把新的ruby写入
529 source ~/.zshrc
530 ruby -v // 就可以看到新的版本的ruby了
都安装完之后 进入 ios 目录 中心 pod install 安装ios 需要的依赖,如正常无错误就可以运行了.如果有错误按照提示操作。
由于需要开发者账号才可以打包ipa,上架,我就连接上真机调试安装到iPhone上了。反正是自己用的app。