React Native 环境安装

Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.
 

搭建开发环境 · React Native 中文网

Homebrew(包管理器) → rvm(ruby版本管理) → ruby → cocoapods

安装 Homebrew

Homebrew

/bin/bash -c "$(curl -fsSL )"

安装RVM

// 输入命令
curl -L get.rvm.io | bash -s stable
// 成功响应结果
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   194  100   194    0     0    347      0 --:--:-- --:--:-- --:--:--   351
100 24532  100 24532    0     0  11270      0  0:00:02  0:00:02 --:--:-- 23143
Downloading 
Downloading 
Found PGP signature at: '',
but no GPG software exists to validate it, skipping.
Upgrading the RVM installation in /Users/helongfei/.rvm/
    RVM PATH line found in /Users/helongfei/.mkshrc /Users/helongfei/.profile /Users/helongfei/.bashrc /Users/helongfei/.zshrc.
    RVM sourcing line found in /Users/helongfei/.profile /Users/helongfei/.bash_profile /Users/helongfei/.zlogin.
Upgrade of RVM in /Users/helongfei/.rvm/ is complete.

Thanks for installing RVM 
Please consider donating to our open collective to help us maintain RVM.

  Donate: 
// 失败响应,网络连接问题
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   194  100   194    0     0    113      0  0:00:01  0:00:01 --:--:--   113
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
curl: (7) Failed to connect to raw.githubusercontent.com port 443 after 99 ms: Couldn't connect to server
// host 文件增加
185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com

使用RVM 安装Ruby

// 输入命令
rvm install ruby-3.2.1 --with-openssl-dir=`brew --prefix openssl`
// 成功响应
Checking requirements for osx.
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
==> Updated Homebrew from 6f20c0300a to 4.2.3 (e74dc47d67).
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
csvlens
==> New Casks
emby                ia-presenter        jyutping            prettyclean

You have 14 outdated formulae installed.
==> Migrating formula usbmuxd to libusbmuxd
==> Unlinking usbmuxd
==> Moving usbmuxd versions to /usr/local/Cellar/libusbmuxd
==> Relinking libusbmuxd
Warning: libusbmuxd is outdated!
To avoid broken installations, as soon as possible please run:
  brew upgrade
Or, if you're OK with a less reliable fix:
  brew upgrade libusbmuxd

The 4.2.0 release notes are available on the Homebrew Blog:
  
The 4.2.3 changelog can be found at:
  
Updating certificates bundle '/usr/local/etc/[email protected]/cert.pem'
Requirements installation successful.
Installing Ruby from source to: /Users/helongfei/.rvm/rubies/ruby-3.2.1, this may take a while depending on your cpu(s)...
ruby-3.2.1 - #downloading ruby-3.2.1, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 14 19.5M   14 2924k    0     0  30905      0  0:11:01  0:01:36  0:09:25 29638
 23 19.5M   23 4672k    0     0  28157      0  0:12:06  0:02:49  0:09:17 18563
 67 19.5M   67 13.0M    0     0  27700      0  0:12:18  0:08:15  0:04:03  9104
 78 19.5M   78 15.3M    0     0  26825      0  0:12:42  0:09:59  0:02:43 29501
100 19.5M  100 19.5M    0     0  26031      0  0:13:05  0:13:05 --:--:-- 28218
No checksum for downloaded archive, recording checksum in user configuration.
ruby-3.2.1 - #extracting ruby-3.2.1 to /Users/helongfei/.rvm/src/ruby-3.2.1 - please wait
ruby-3.2.1 - #configuring - please wait
ruby-3.2.1 - #post-configuration - please wait
ruby-3.2.1 - #compiling - please wait
ruby-3.2.1 - #installing - please wait
ruby-3.2.1 - #making binaries executable - please wait
Installed rubygems 3.4.6 is newer than 3.0.9 provided with installed ruby, skipping installation, use --force to force installation.
ruby-3.2.1 - #gemset created /Users/helongfei/.rvm/gems/ruby-3.2.1@global
ruby-3.2.1 - #importing gemset /Users/helongfei/.rvm/gemsets/global.gems - please wait
ruby-3.2.1 - #generating global wrappers - please wait
ruby-3.2.1 - #gemset created /Users/helongfei/.rvm/gems/ruby-3.2.1
ruby-3.2.1 - #importing gemsetfile /Users/helongfei/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-3.2.1 - #generating default wrappers - please wait
ruby-3.2.1 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-3.2.1 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri

RVM 查看版本,并设置默认Ruby版本

// ruby查看版本
rvm list
// 成功响应
=* ruby-3.2.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default
// 设置默认ruby版本
rvm use 3.2.1 --default
// 成功响应
Using /Users/helongfei/.rvm/gems/ruby-3.2.1
// 安装不成功rvm,重新安装
sudo rm -rf .rvm .rvmrc   /etc/rvmrc ;gem uninstall rvm

安装cocoapods

// 安装命令 查看mac版本大于10.11 
sudo gem install -n /usr/local/bin cocoapods
// mac版本小于10.11
sudo gem install cocoapods
Password:
Fetching colored2-3.1.2.gem
Fetching nanaimo-0.3.0.gem
Fetching xcodeproj-1.23.0.gem
Fetching nap-1.1.0.gem
Fetching atomos-0.1.3.gem
Fetching ruby-macho-2.5.1.gem
Fetching claide-1.1.0.gem
Fetching escape-0.0.4.gem
Fetching molinillo-0.8.0.gem
Fetching gh_inspector-1.1.3.gem
Fetching cocoapods-trunk-1.6.0.gem
Fetching fourflusher-2.3.1.gem
Fetching CFPropertyList-3.0.6.gem
Fetching cocoapods-try-1.2.0.gem
Fetching netrc-0.11.0.gem
Fetching cocoapods-search-1.0.1.gem
Fetching cocoapods-plugins-1.0.0.gem
Fetching concurrent-ruby-1.2.2.gem
Fetching cocoapods-downloader-2.1.gem
Fetching cocoapods-deintegrate-1.0.5.gem
Fetching ffi-1.16.3.gem
Fetching ethon-0.16.0.gem
Fetching i18n-1.14.1.gem
Fetching typhoeus-1.4.1.gem
Fetching public_suffix-4.0.7.gem
Fetching httpclient-2.8.3.gem
Fetching algoliasearch-1.27.5.gem
Fetching addressable-2.8.6.gem
Fetching tzinfo-2.0.6.gem
Fetching fuzzy_match-2.0.4.gem
Fetching cocoapods-1.14.3.gem
Fetching connection_pool-2.4.1.gem
Fetching activesupport-7.1.2.gem
Fetching cocoapods-core-1.14.3.gem
Successfully installed nanaimo-0.3.0
Successfully installed colored2-3.1.2
Successfully installed claide-1.1.0
Successfully installed CFPropertyList-3.0.6
Successfully installed atomos-0.1.3
Successfully installed xcodeproj-1.23.0
Successfully installed ruby-macho-2.5.1
Successfully installed nap-1.1.0
Successfully installed molinillo-0.8.0
Successfully installed gh_inspector-1.1.3
Successfully installed fourflusher-2.3.1
Successfully installed escape-0.0.4
Successfully installed cocoapods-try-1.2.0
Successfully installed netrc-0.11.0
Successfully installed cocoapods-trunk-1.6.0
Successfully installed cocoapods-search-1.0.1
Successfully installed cocoapods-plugins-1.0.0
Successfully installed cocoapods-downloader-2.1
Successfully installed cocoapods-deintegrate-1.0.5
Building native extensions. This could take a while...

Successfully installed ffi-1.16.3
Successfully installed ethon-0.16.0
Successfully installed typhoeus-1.4.1
Successfully installed public_suffix-4.0.7
Successfully installed fuzzy_match-2.0.4
Successfully installed concurrent-ruby-1.2.2
Successfully installed httpclient-2.8.3
A new major version is available for Algolia! Please now use the  gem to get the latest features.
Successfully installed algoliasearch-1.27.5
Successfully installed addressable-2.8.6
Successfully installed tzinfo-2.0.6
Successfully installed i18n-1.14.1
Successfully installed connection_pool-2.4.1
Successfully installed activesupport-7.1.2
Successfully installed cocoapods-core-1.14.3
Successfully installed cocoapods-1.14.3
Parsing documentation for nanaimo-0.3.0
Installing ri documentation for nanaimo-0.3.0
Parsing documentation for colored2-3.1.2
Installing ri documentation for colored2-3.1.2
Parsing documentation for claide-1.1.0
Installing ri documentation for claide-1.1.0
Parsing documentation for CFPropertyList-3.0.6
Installing ri documentation for CFPropertyList-3.0.6
Parsing documentation for atomos-0.1.3
Installing ri documentation for atomos-0.1.3
Parsing documentation for xcodeproj-1.23.0
Installing ri documentation for xcodeproj-1.23.0
Parsing documentation for ruby-macho-2.5.1
Installing ri documentation for ruby-macho-2.5.1
Parsing documentation for nap-1.1.0
Installing ri documentation for nap-1.1.0
Parsing documentation for molinillo-0.8.0
Installing ri documentation for molinillo-0.8.0
Parsing documentation for gh_inspector-1.1.3
Installing ri documentation for gh_inspector-1.1.3
Parsing documentation for fourflusher-2.3.1
Installing ri documentation for fourflusher-2.3.1
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for cocoapods-try-1.2.0
Installing ri documentation for cocoapods-try-1.2.0
Parsing documentation for netrc-0.11.0
Installing ri documentation for netrc-0.11.0
Parsing documentation for cocoapods-trunk-1.6.0
Installing ri documentation for cocoapods-trunk-1.6.0
Parsing documentation for cocoapods-search-1.0.1
Installing ri documentation for cocoapods-search-1.0.1
Parsing documentation for cocoapods-plugins-1.0.0
Installing ri documentation for cocoapods-plugins-1.0.0
Parsing documentation for cocoapods-downloader-2.1
Installing ri documentation for cocoapods-downloader-2.1
Parsing documentation for cocoapods-deintegrate-1.0.5
Installing ri documentation for cocoapods-deintegrate-1.0.5
Parsing documentation for ffi-1.16.3
Installing ri documentation for ffi-1.16.3
Parsing documentation for ethon-0.16.0
Installing ri documentation for ethon-0.16.0
Parsing documentation for typhoeus-1.4.1
Installing ri documentation for typhoeus-1.4.1
Parsing documentation for public_suffix-4.0.7
Installing ri documentation for public_suffix-4.0.7
Parsing documentation for fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
Parsing documentation for concurrent-ruby-1.2.2
Installing ri documentation for concurrent-ruby-1.2.2
Parsing documentation for httpclient-2.8.3
Installing ri documentation for httpclient-2.8.3
Parsing documentation for algoliasearch-1.27.5
Installing ri documentation for algoliasearch-1.27.5
Parsing documentation for addressable-2.8.6
Installing ri documentation for addressable-2.8.6
Parsing documentation for tzinfo-2.0.6
Installing ri documentation for tzinfo-2.0.6
Parsing documentation for i18n-1.14.1
Installing ri documentation for i18n-1.14.1
Parsing documentation for connection_pool-2.4.1
Installing ri documentation for connection_pool-2.4.1
Parsing documentation for activesupport-7.1.2
Couldn't find file to include 'activesupport/README.rdoc' from lib/active_support.rb
Installing ri documentation for activesupport-7.1.2
Parsing documentation for cocoapods-core-1.14.3
Installing ri documentation for cocoapods-core-1.14.3
Parsing documentation for cocoapods-1.14.3
Installing ri documentation for cocoapods-1.14.3
Done installing documentation for nanaimo, colored2, claide, CFPropertyList, atomos, xcodeproj, ruby-macho, nap, molinillo, gh_inspector, fourflusher, escape, cocoapods-try, netrc, cocoapods-trunk, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, ffi, ethon, typhoeus, public_suffix, fuzzy_match, concurrent-ruby, httpclient, algoliasearch, addressable, tzinfo, i18n, connection_pool, activesupport, cocoapods-core, cocoapods after 22 seconds
34 gems installed

pod

// 初始化CocoaPods项目的命令
pod setup
// 成功响应
Setup completed
// 查看命令
pod repo list
// 成功响应
trunk
- Type: CDN
- URL:  
- Path: /Users/helongfei/.cocoapods/repos/trunk

1 repo
// 添加CocoaPods
pod repo add master 
// 成功响应
master
- Type: file system
- URL:  
- Path: /Users/helongfei/.cocoapods/repos/master

trunk
- Type: CDN
- URL:  
- Path: /Users/helongfei/.cocoapods/repos/trunk

2 repos
// 错误响应

[!] /usr/local/bin/git clone  -- master

Cloning into 'master'...
error: RPC failed; curl 18 HTTP/2 stream 3 was reset
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
// 解决方案 手动下载 CocoaPods master


// 下载好之后放入文件位置
/Users/helongfei/.cocoapods/repos/master
// 错误响应
Framework build type is static library
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
[Codegen] Found FBReactNativeSpec
Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`
[Codegen] Found rncore
Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
Fetching podspec for `hermes-engine` from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`
[Hermes] Using release tarball from URL: 
Downloading dependencies
Installing CocoaAsyncSocket (7.6.5)
Installing DoubleConversion (1.1.6)
Installing FBLazyVector (0.73.1)
Installing FBReactNativeSpec (0.73.1)
Installing Flipper (0.201.0)
Installing Flipper-Boost-iOSX (1.76.0.1.11)
Installing Flipper-DoubleConversion (3.2.0.1)
Installing Flipper-Fmt (7.1.7)
Installing Flipper-Folly (2.6.10)
Installing Flipper-Glog (0.5.0.5)
Installing Flipper-PeerTalk (0.0.4)
Installing FlipperKit (0.201.0)
Installing OpenSSL-Universal (1.1.1100)
Installing RCT-Folly (2022.05.16.00)
Installing RCTRequired (0.73.1)
Installing RCTTypeSafety (0.73.1)
Installing React (0.73.1)
Installing React-Codegen (0.73.1)
Installing React-Core (0.73.1)
Installing React-CoreModules (0.73.1)
Installing React-Fabric (0.73.1)
Installing React-FabricImage (0.73.1)
Installing React-ImageManager (0.73.1)
Installing React-Mapbuffer (0.73.1)
Installing React-NativeModulesApple (0.73.1)
Installing React-RCTActionSheet (0.73.1)
Installing React-RCTAnimation (0.73.1)
Installing React-RCTAppDelegate (0.73.1)
Installing React-RCTBlob (0.73.1)
Installing React-RCTFabric (0.73.1)
Installing React-RCTImage (0.73.1)
Installing React-RCTLinking (0.73.1)
Installing React-RCTNetwork (0.73.1)
Installing React-RCTSettings (0.73.1)
Installing React-RCTText (0.73.1)
Installing React-RCTVibration (0.73.1)
Installing React-callinvoker (0.73.1)
Installing React-cxxreact (0.73.1)
Installing React-debug (0.73.1)
Installing React-graphics (0.73.1)
Installing React-hermes (0.73.1)
Installing React-jserrorhandler (0.73.1)
Installing React-jsi (0.73.1)
Installing React-jsiexecutor (0.73.1)
Installing React-jsinspector (0.73.1)
Installing React-logger (0.73.1)
Installing React-nativeconfig (0.73.1)
Installing React-perflogger (0.73.1)
Installing React-rendererdebug (0.73.1)
Installing React-rncore (0.73.1)
Installing React-runtimeexecutor (0.73.1)
Installing React-runtimescheduler (0.73.1)
Installing React-utils (0.73.1)
Installing ReactCommon (0.73.1)
Installing SocketRocket (0.6.1)
Installing Yoga (1.14.0)
Installing boost (1.83.0)

[!] Error installing boost
Verification checksum was incorrect, expected 6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e, got 5e89103d9b70bba5c91a794126b169cb67654be2051f90cf7c22ba6893ede0ff
// 错误原因 SHA256 Hash 不匹配,下载对应版本



// 放入对应目录 /usr/local/Cellar/boost  在boost下解压文件名调整为 1.83.0

生成项目

  • 进入指定目录下生成项目
npx react-native@latest init AwesomeProject

install

  • 进入项目的ios目录下执行
// 下载依赖
pod install
// 错误响应
Framework build type is static library
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
[Codegen] Found FBReactNativeSpec
Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`
[Codegen] Found rncore
Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
Fetching podspec for `hermes-engine` from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`
[Hermes] Using release tarball from URL: 
Downloading dependencies
Installing CocoaAsyncSocket (7.6.5)
Installing DoubleConversion (1.1.6)
Installing FBLazyVector (0.73.1)
Installing FBReactNativeSpec (0.73.1)
Installing Flipper (0.201.0)
Installing Flipper-Boost-iOSX (1.76.0.1.11)
Installing Flipper-DoubleConversion (3.2.0.1)
Installing Flipper-Fmt (7.1.7)
Installing Flipper-Folly (2.6.10)
Installing Flipper-Glog (0.5.0.5)
Installing Flipper-PeerTalk (0.0.4)
Installing FlipperKit (0.201.0)

[!] Error installing FlipperKit
[!] /usr/local/bin/git clone  /var/folders/n1/00byb5s97g573kxgy7f4qqq00000gn/T/d20240109-50222-vhka9f --template= --single-branch --depth 1 --branch v0.201.0

Cloning into '/var/folders/n1/00byb5s97g573kxgy7f4qqq00000gn/T/d20240109-50222-vhka9f'...
fatal: unable to access '': Failure when receiving data from the peer
// 网络问题,多次输入下载
pod install
// 继续输入
pod install
// 成功响应

Framework build type is static library
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
[Codegen] Found FBReactNativeSpec
Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`
[Codegen] Found rncore
Fetching podspec for `boost` from `../node_modules/react-native/third-party-podspecs/boost.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
Fetching podspec for `hermes-engine` from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`
[Hermes] Using release tarball from URL: 
Downloading dependencies
Installing CocoaAsyncSocket (7.6.5)
Installing DoubleConversion (1.1.6)
Installing FBLazyVector (0.73.1)
Installing FBReactNativeSpec (0.73.1)
Installing Flipper (0.201.0)
Installing Flipper-Boost-iOSX (1.76.0.1.11)
Installing Flipper-DoubleConversion (3.2.0.1)
Installing Flipper-Fmt (7.1.7)
Installing Flipper-Folly (2.6.10)
Installing Flipper-Glog (0.5.0.5)
Installing Flipper-PeerTalk (0.0.4)
Installing FlipperKit (0.201.0)
Installing OpenSSL-Universal (1.1.1100)
Installing RCT-Folly (2022.05.16.00)
Installing RCTRequired (0.73.1)
Installing RCTTypeSafety (0.73.1)
Installing React (0.73.1)
Installing React-Codegen (0.73.1)
Installing React-Core (0.73.1)
Installing React-CoreModules (0.73.1)
Installing React-Fabric (0.73.1)
Installing React-FabricImage (0.73.1)
Installing React-ImageManager (0.73.1)
Installing React-Mapbuffer (0.73.1)
Installing React-NativeModulesApple (0.73.1)
Installing React-RCTActionSheet (0.73.1)
Installing React-RCTAnimation (0.73.1)
Installing React-RCTAppDelegate (0.73.1)
Installing React-RCTBlob (0.73.1)
Installing React-RCTFabric (0.73.1)
Installing React-RCTImage (0.73.1)
Installing React-RCTLinking (0.73.1)
Installing React-RCTNetwork (0.73.1)
Installing React-RCTSettings (0.73.1)
Installing React-RCTText (0.73.1)
Installing React-RCTVibration (0.73.1)
Installing React-callinvoker (0.73.1)
Installing React-cxxreact (0.73.1)
Installing React-debug (0.73.1)
Installing React-graphics (0.73.1)
Installing React-hermes (0.73.1)
Installing React-jserrorhandler (0.73.1)
Installing React-jsi (0.73.1)
Installing React-jsiexecutor (0.73.1)
Installing React-jsinspector (0.73.1)
Installing React-logger (0.73.1)
Installing React-nativeconfig (0.73.1)
Installing React-perflogger (0.73.1)
Installing React-rendererdebug (0.73.1)
Installing React-rncore (0.73.1)
Installing React-runtimeexecutor (0.73.1)
Installing React-runtimescheduler (0.73.1)
Installing React-utils (0.73.1)
Installing ReactCommon (0.73.1)
Installing SocketRocket (0.6.1)
Installing Yoga (1.14.0)
Installing boost (1.83.0)
Installing fmt (6.2.1)
Installing glog (0.3.5)
Installing hermes-engine (0.73.1)
Installing libevent (2.1.12)
Generating Pods project
Setting USE_HERMES build settings
Setting REACT_NATIVE build settings
Setting CLANG_CXX_LANGUAGE_STANDARD to c++20 on /Users/helongfei/Desktop/code/App/react_native/AwesomeProject/ios/AwesomeProject.xcodeproj
Pod install took 136 [s] to run
Integrating client project

[!] Please close any current Xcode sessions and use `AwesomeProject.xcworkspace` for this project from now on.
Pod installation complete! There are 73 dependencies from the Podfile and 61 total pods installed.

[!] hermes-engine has added 1 script phase. Please inspect before executing a build. See `https://guides.cocoapods.org/syntax/podspec.html#script_phases` for more information.

你可能感兴趣的:(React,React,Native,react,native,react.js,javascript)