基于M1下的ReactNative init 失败的解决方案!Do not use “pod install“ from

阅读: 评论:0

基于M1下的ReactNative init 失败的解决方案!Do not use “pod install“ from

基于M1下的ReactNative init 失败的解决方案!Do not use “pod install“ from

初次尝试RN,结果搞死我了,在M1芯片下安装环境,各种不明所以的问题。找了各种解决方案,最后还是自己瞎搞出来了…

首先我是按照官网的操作配置的,搭建开发环境,到init项目的时候 报错了。

  1. node

    node我是用nvm安装了nodev18

  2. watchman
    brew install watchman

  3. npm源
    npx nrm use taobao

  4. yarn
    npm install -g yarn
    其实之前我已经安装过,毕竟yarn很好用。

  5. Xcode
    每个苹果开发者都要安装的App,之前开发过swift,所以没有安装的朋友自行 安装就可以了。至于官网提到的Xcode的相关配置,照做就好了,不过在下方官网提到的,新版Xcode已经将Preferences改成setting…,在这里面找就行。

    在 Xcode 中安装 iOS 模拟器,安装模拟器只需打开 Xcode > Preferences… 菜单

  6. Cocoapods
    这个搞了我好长时间,一来是按照官网傻瓜式操作,也没有说验证安装成功的命令,二来很久不写swift,记错了验证命令行。我采用了
    brew install cocoapods
    安装完要
    pod -v 验证是否安装成功

  7. 初始化项目
    npx react-native@latest init AwesomeProject
    这是官网的命令,照做了…
    重点来了…
    我收到了以下的报错

✔ Downloading template
✔ Copying template
✔ Processing template
✔ Installing Ruby Gems
✖ Installing CocoaPods dependencies (this may take a few minutes)
error 
[!] Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64).[!]  - Emulated x86_64 is slower than native arm64[!]  - May result in mixed architectures in rubygems (eg: ffi_c.bundle files may be x86_64 with an arm64 interpreter)[!] Run "env /usr/bin/arch -arm64 /bin/bash --login" then try again.
✖ Installing CocoaPods dependencies (this may take a few minutes)
error Looks like your iOS environment is not properly set. Please go to /docs/environment-setup?os=macos&platform=android and follow the React Native CLI QuickStart guide for macOS and iOS.
info Run CLI with --verbose flag for more details.

如此反复,我一直认为是M1芯片的事情,去了RN的github也看了,各种方法各种不管用。然后我仔细看了一下
Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64).
不让我pod install,我偏执行,然后得到

No `Podfile' found in the project directory.

我打开文件目录看到在AwesomeProject的一级目录确实没有啊,联想之前看了众多资料,看到一个ios文件夹,打开一看,在里面有个Podfile,这不才是该pod install的目录吗?????
于是在终端已经在AwesomeProject文件目录下的条件下,
cd ios
pod install
然后就…居然开始装第三方包了… 我不懂为什么官网不提这个,很坑人啊…
也许在pod install过程中会卡在某个包很久,这时候果断结束任务,重新pod install,不要怕重新下载之前下载好的,pod会自动检测是否安装过,如果会跳过,但在终端界面,会给你一种重新安装的错觉。
就这样pod install直到看到下面这个
Pod install took 83 [s] to run Integrating client project
说明安装完了,在ios的目录下,执行
yarn ios等待 building app… ,也许会花费一点时间,耐心等待,最后你的虚拟手机会开机,安装app,打开界面,大功告成!好不容易。

本文发布于:2024-01-31 00:54:23,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170663377424131.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:解决方案   init   ReactNative   install   pod
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23