赞
踩
NVM下载和使用
JDK下载和安装
下面这个jdk的安装和配置有配置环境变量的,下面的安卓sdk环境变量配置跟这个是差不多的也是一样的命令
参考这篇博客就行
提供一个梯子地址 https://ikuuu.pw/
本人的环境配置
export ANDROID_HOME=/Users/admin/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/emulator
// 上面是安卓sdk配置
// 下面这个是jdk环境配置
export JAVA_HOME=/Users/admin/Desktop/jdk-17.0.10.jdk/Contents/Home
PATH=$JAVA_HOME/bin:$PATH
export PATH
export CLASSPATH
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
npm install -g yarn
brew install cocoapods
npx react-native init AwesomeProject
pod install
执行pod install
可能会遇到[!] Failed to load 'glog' podspec: [!] Invalid glog.podspecfile: undefine
或者yarn run ios
遇到下面
error Error: Command failed with exit code 1: xcodebuild -list -json
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance.
Error: Error: Command failed with exit code 1: xcodebuild -list -json
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
at getInfo (/Users/admin/Desktop/project/ben/Demo2/node_modules/@react-native-community/cli-platform-ios/build/tools/getInfo.js:31:11)
at getConfiguration (/Users/admin/Desktop/project/ben/Demo2/node_modules/@react-native-community/cli-platform-ios/build/commands/buildIOS/getConfiguration.js:34:37)
at Object.runIOS [as func] (/Users/admin/Desktop/project/ben/Demo2/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js:115:52)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Command.handleAction (/Users/admin/Desktop/project/ben/Demo2/node_modules/@react-native-community/cli/build/index.js:118:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
这种错误,只需要在终端输入以下命令即可解决
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
这会将 Xcode 开发者目录设置为 Xcode 应用程序的目录。并确认已经安装了 Xcode,并且路径正确。
然后重新pod install和yarn run ios即可
如果问题仍然存在,可以尝试清除项目的缓存并重新构建项目:
yarn cache clean
cd ios
rm -rf Pods Podfile.lock
pod install
cd ..
yarn run ios
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。