Cha*_*hok 19 javascript react-native
我尝试创建新的 React Native 项目,但由于发现多个 podfiles 错误而失败。
error: warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via "project.ios.sourceDir". You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
Run Code Online (Sandbox Code Playgroud)
par*_*par 15
react-native.config.js创建一个在项目根级别调用的文件,其中包含以下内容:
module.exports = {
project: {
ios: {
sourceDir: './ios',
},
},
};
Run Code Online (Sandbox Code Playgroud)
然后,当您运行npx react-native run-iosios/ 目录中的 Podfile 时,您将不会看到错误。
小智 13
也许这只是我的问题,但这是我的经验和修复:
第一次当我跑步时xcode-select -p它正在返回/Library/Developer/CommandLineTools
然而,这看起来很奇怪,因为这里的另一个答案似乎表明这可能导致了问题。结果是我没有按照 React Native 文档中的描述正确设置我的 CLI 工具。由于下拉列表中只有一个选项,我假设 CLI 工具已经设置完毕。然而,当我返回并专门单击一个选项时,它对我的系统进行了更改。
现在运行xcode-select -p返回
/Application/Xcode.app/Contents/Developer
TL;DR:打开 Xcode,转到菜单栏中的“设置...”。然后转到“位置”选项卡,单击“命令行工具”下拉列表,然后单击最新版本(即使看起来已经设置了版本,也单击一个版本)。现在再次尝试安装 pod!
此处相同,下面有一些更多详细信息可帮助解决问题。\n全新 Macbook Pro (M1 Pro) 并遵循 rn 文档中的安装步骤后。初始化最新版本时出现同样的错误,也与 0.69.0 相同npx react-native init AwesomeProject:
\xe2\x9c\x96 Installing CocoaPods dependencies (this may take a few minutes)\nerror warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via "project.ios.sourceDir". You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md\n\n\xe2\x9c\x96 Installing CocoaPods dependencies (this may take a few minutes)\nerror Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.\nRun Code Online (Sandbox Code Playgroud)\n.zshrc
\nexport PATH=/opt/homebrew/bin:$PATH\neval "$(rbenv init - zsh)\nRun Code Online (Sandbox Code Playgroud)\n”
\n.z配置文件
\neval "$(/opt/homebrew/bin/brew shellenv)"\nexport ANDROID_SDK_ROOT=$HOME/Library/Android/sdk\nexport PATH=$PATH:$ANDROID_SDK_ROOT/emulator\nexport PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools\nRun Code Online (Sandbox Code Playgroud)\nXcode 14
\n后
\n ruby --version\n brew info cocoapods\nRun Code Online (Sandbox Code Playgroud)\n我得到:
\n ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [arm64-darwin21]\n /opt/homebrew/Cellar/cocoapods/1.11.3\nRun Code Online (Sandbox Code Playgroud)\n我不明白为什么它在我的 rn 项目中创建带有 ruby cocoapods 的新文件夹:/vendor\n我的旧 M1 上从未遇到过这个问题。我已经尝试过sudo arch -x86_64 gem install ffi
编辑 1:pod install --project-directory=ios向我显示类似于另一个cocoaPods 问题的错误,但没有修复
该问题的答案有帮助。尝试:
\nsudo xcode-select --switch /Applications/Xcode.app\nRun Code Online (Sandbox Code Playgroud)\n它修复了我的错误并允许我构建 0.70.3 rn init。\n但在此之前我也将我的 xcode 降级到 13.4,不确定是否有必要。
\n但我仍然在我的 rn 应用程序中得到这个奇怪的 /vendor 文件夹,但删除它后,它仍然可以在 ios 上正常构建。
\n| 归档时间: |
|
| 查看次数: |
11111 次 |
| 最近记录: |