0
点赞
收藏
分享

微信扫一扫

电脑安装双系统windows和ubuntu server

酷子腿长一米八 03-24 06:30 阅读 4

1.前期准备

NVM下载和使用
JDK下载和安装
下面这个jdk的安装和配置有配置环境变量的,下面的安卓sdk环境变量配置跟这个是差不多的也是一样的命令

2.android 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

3.ios环境配置

    1. 终端执行如下代码参考网站,预防链接有更新
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • 安装 Node(前面安装过nvm就可以了) 和 Watchman(这个我没下载,本人下载了各种报错),因此本人这一步省略了,有需要的朋友可以下载
    1. 安装yarn
npm install -g yarn
    1. 安装Xcode(这个各位百度自行下载配置)
    1. 安装cocoapods
brew install cocoapods
    1. 创建项目
npx react-native init AwesomeProject
  • 7.在项目下的ios文件夹打开终端输入以下命令安装ios依赖
pod install

bug

执行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
举报

相关推荐

0 条评论