最新創(chuàng)建的React Native項(xiàng)目旋恼,對(duì)于ios需要Pod管理工具
最開始可以直接使用React Native的官方推薦的Pod安裝方法:
https://reactnative.cn/docs/getting-started.html
image.png
安裝過程中斯议,可能會(huì)出現(xiàn)如下問題:
pod[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master`.You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.
解決方案:
pod repo add master https://github.com/CocoaPods/Specs.git
然后提示執(zhí)行
pod setup
如果出現(xiàn)
pod[!] The `master` repo is not a git repo.
進(jìn)入/users/你的用戶名/.cocoapods/repos靶橱,刪除master文件夾然后執(zhí)行
(注意此處的.cocoapods隱藏文件夾)
pod setup
如果是安裝多個(gè)Xcdoe承璃,還需要選擇Xcode的路徑
sudo xcode-select -switch /Applications/Xcode.app/
在終端里輸入下方命令可以知道Xcode的路徑:
xcode-select -p
最后需要注意的是用.xcworkspace的文件打開iOS項(xiàng)目:
image.png