IOS
RN ios android原生環境搭建有時候是真惡心,電腦環境不一樣配置也有差異。
我已經安裝官網的文檔配置了ios環境
執行
npx react-native@latest init AwesomeProject
報錯
?然后自己百度查呀執行
gem update --system
說是沒有權限,執行失敗。因為Mac自帶的Ruby有權限限制,加sudo也不行。
網上找沒辦法使用Homebrew安裝Ruby,
brew search ruby
brew install ruby@3.1
安裝完成之后在.bash_profile增加環境變量配置
export PATH=/usr/local/opt/ruby/bin:$PATH
然后執行
source ~/.bash_profile
執行
ruby -v
重新初始化項目
然后繼續報錯,我c,
現在不卡在install Ruby gems 卡在install?cocoapods 的依賴,還好cocoapods支持斷點下載,那就等吧,最后還是報錯,就多試幾次,最后終于初始成功(是到第二天才初始化成功,我中間不知道試了多少次,我都要快放棄了,什么玩意啊)。
npm 源?registry = "https://registry.npmmirror.com/",中間還試過幾次翻墻初始化也失敗。
報錯?error Couldn't find any versions for "@react-native/metro-config" that matches "^0.72.11" 找不到版本
Android
我運行安卓報錯,Could not find com.android.tools.build:gradle,我打開AS配置
之前選擇的是JKD1.8現在選擇15,重新build
報錯
關閉項目再次打開讓它去下載。?