【React Native】使用React Native的第一天

杂谈

这两天,闲着,给自己找点事做。

看了Swift版的Pinlayout布局方式,了解了之前计算view和cell高度一直使用了错误的方法,算是进步吧。

看了单元测试,终于明白了怎么用,都不知道是第几次看了,以后总算是会用了,也算是进步吧。

看了一眼React Native,然后突发奇想,用React Native重新写一遍用oc和Swift混编的app会怎么样,然后用Flutter也写一遍,正好两个都熟悉一下,说干就干。

理想是美好的,现实是残酷的,装环境就搞了一天。

开始

本文使用React Native参考链接

安装依赖

安装node
node在我上次用Sublime Text的时候安装了,这里略过

安装watchman
Watchman是由 Facebook 提供的监视文件系统变更的工具。安装此工具可以提高开发时的性能(packager 可以快速捕捉文件的变化从而实现实时刷新)。

DreamdeMac-mini:git Dream$ brew install watchman
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
######################################################################### 100.0%
==> Pouring portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
...
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python@3.8/3.8.3_1
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python@3.8/3.8.3
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

打印的东西太多,中间省略的好多,重点是最后报错了,没有权限,那就手动创建了,然后再分配权限

DreamdeMac-mini:git Dream$ sudo mkdir /usr/local/Frameworks
Password:
DreamdeMac-mini:git Dream$ sudo chown $(whoami):admin /usr/local/Frameworks/

再来,这回成功了

DreamdeMac-mini:git Dream$ brew install watchman
Updating Homebrew...
fatal: unable to access 'https://github.com/Homebrew/brew/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
==> Downloading https://homebrew.bintray.com/bottles/watchman-4.9.0_4.catalina.b
Already downloaded: /Users/Dream/Library/Caches/Homebrew/downloads/e89d6c1565baa4d0503c6fe7f16e268f33459e2797971d5bb2ddde142fba0264--watchman-4.9.0_4.catalina.bottle.tar.gz
==> Pouring watchman-4.9.0_4.catalina.bottle.tar.gz
==> launchctl unload -F /Users/Dream/Library/LaunchAgents/com.github.facebook.wa
🍺  /usr/local/Cellar/watchman/4.9.0_4: 24 files, 2.1MB
DreamdeMac-mini:git Dream$ watchman -v
4.9.0

安装yarn
Yarn是 Facebook 提供的替代 npm 的工具,可以加速 node 模块的下载。
安装完 yarn 之后就可以用 yarn代替 npm 了,例如用yarn代替npm install命令,用yarn add xxx 代替npm install xxx

DreamdeMac-mini:git Dream$ npm install -g yarn
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Dream/.npm/_logs/2020-07-09T03_00_20_693Z-debug.log

又是没有权限,分配权限,然后安装

DreamdeMac-mini:git Dream$ sudo chown -R $USER /usr/local/lib/node_modules
Password:
DreamdeMac-mini:git Dream$ ls -l /usr/local/lib/node_modules
total 0
drwxr-xr-x  24 Dream  wheel  768  6  3 00:03 npm
DreamdeMac-mini:git Dream$ npm install -g yarn
/usr/local/bin/yarn -> /usr/local/lib/node_modules/yarn/bin/yarn.js
/usr/local/bin/yarnpkg -> /usr/local/lib/node_modules/yarn/bin/yarn.js
+ yarn@1.22.4
added 1 package in 1.017s

安装Xcode和cocoapods
已经安装了,这里也略过

新建React Native项目
环境安装完了,开始新建项目

DreamdeMac-mini:React_Native Dream$ npx react-native init AwesomeProject
                                                          
               ######                ######               
             ###     ####        ####     ###             
            ##          ###    ###          ##            
            ##             ####             ##            
            ##             ####             ##            
            ##           ##    ##           ##            
            ##         ###      ###         ##            
             ##  ########################  ##             
          ######    ###            ###    ######          
      ###     ##    ##              ##    ##     ###      
   ###         ## ###      ####      ### ##         ###   
  ##           ####      ########      ####           ##  
 ##             ###     ##########     ###             ## 
  ##           ####      ########      ####           ##  
   ###         ## ###      ####      ### ##         ###   
      ###     ##    ##              ##    ##     ###      
          ######    ###            ###    ######          
             ##  ########################  ##             
            ##         ###      ###         ##            
            ##           ##    ##           ##            
            ##             ####             ##            
            ##             ####             ##            
            ##          ###    ###          ##            
             ###     ####        ####     ###             
               ######                ######               
                                                          

                  Welcome to React Native!                
                 Learn once, write anywhere               

✔ Downloading template
✔ Copying template
✔ Processing template
ℹ Installing dependencies
? CocoaPods (https://cocoapods.org/) is not installed. CocoaPods is necessary for
 the iOS project to run correctly. Do you want to install it? Yes, with gem (may 
require sudo)
✖ Installing CocoaPods
error 
✖ Installing CocoaPods
error Error: An error occured while trying to install CocoaPods, which is required by this template.
Please try again manually: sudo gem install cocoapods.
CocoaPods documentation: https://cocoapods.org/

提示我要装cocoapods,这...,都用了好几年了,怎么还要装。结果鬼使神差的执行了安装,然后就出现了数不清的问题。
先根据提示,用gem安装cocoapods

DreamdeMac-mini:React_Native Dream$ sudo gem install cocoapods
Password:
Error loading RubyGems plugin "/Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/executable-hooks-1.3.2/lib/rubygems_plugin.rb": dlopen(/Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/openssl.bundle
  Reason: image not found - /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/openssl.bundle (LoadError)
Error loading RubyGems plugin "/Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/gem-wrappers-1.2.7/lib/rubygems_plugin.rb": dlopen(/Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/openssl.bundle
  Reason: image not found - /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/openssl.bundle (LoadError)
ERROR:  Loading command: install (LoadError)
    dlopen(/Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/openssl.bundle
  Reason: image not found - /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/openssl.bundle
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

报错,然后尝试用brew安装cocoapods

DreamdeMac-mini:React_Native Dream$ brew install cocoapods
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
termcolor
==> Updated Formulae
ballerina           onednn              tomcat@7            websocat

==> Downloading https://homebrew.bintray.com/bottles/cocoapods-1.9.3.catalina.bot
==> Downloading from https://akamai.bintray.com/70/70f8c793bb60631422db028bbebb64
######################################################################## 100.0%
==> Pouring cocoapods-1.9.3.catalina.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/pod
Target /usr/local/bin/pod
already exists. You may want to remove it:
  rm '/usr/local/bin/pod'

To force the link and overwrite all conflicting files:
  brew link --overwrite cocoapods

To list all files that would be deleted:
  brew link --overwrite --dry-run cocoapods

Possible conflicting files are:
/usr/local/bin/pod
/usr/local/bin/xcodeproj
==> Summary
🍺  /usr/local/Cellar/cocoapods/1.9.3: 12,523 files, 28.3MB

提示pod已存在,选择remove或者overwrite,我选了个overwrite

DreamdeMac-mini:React_Native Dream$ brew link --overwrite cocoapods
Linking /usr/local/Cellar/cocoapods/1.9.3... 2 symlinks created

然后顺手查看了下pod版本

DreamdeMac-mini:React_Native Dream$ pod -v
/Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/digest/sha2.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (LoadError)
  Referenced from: /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/digest/sha2.bundle
  Reason: image not found - /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/digest/sha2.bundle
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/digest/sha2.rb:14:in `<top (required)>'
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/typhoeus-1.3.1/lib/typhoeus.rb:1:in `<top (required)>'
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/sources_manager.rb:5:in `<top (required)>'
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/core_overrides.rb:1:in `<top (required)>'
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.9.1/lib/cocoapods.rb:75:in `<module:Pod>'
    from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.9.1/lib/cocoapods.rb:17:in `<top (required)>'
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
    from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.9.1/bin/pod:36:in `<top (required)>'
    from /Users/Dream/.rvm/gems/ruby-2.3.0/bin/pod:22:in `load'
    from /Users/Dream/.rvm/gems/ruby-2.3.0/bin/pod:22:in `<main>'
    from /Users/Dream/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
    from /Users/Dream/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

这什么情况,看这个错误和前面命令sudo gem install cocoapods报错都是ruby找不到了,难道是刚才overwrite哪里出问题了,懵逼。
不管了,重新创建项目看下会不会有问题

DreamdeMac-mini:React_Native Dream$ npx react-native init AwesomeProject
                                                          
               ######                ######               
             ###     ####        ####     ###             
            ##          ###    ###          ##            
            ##             ####             ##            
            ##             ####             ##            
            ##           ##    ##           ##            
            ##         ###      ###         ##            
             ##  ########################  ##             
          ######    ###            ###    ######          
      ###     ##    ##              ##    ##     ###      
   ###         ## ###      ####      ### ##         ###   
  ##           ####      ########      ####           ##  
 ##             ###     ##########     ###             ## 
  ##           ####      ########      ####           ##  
   ###         ## ###      ####      ### ##         ###   
      ###     ##    ##              ##    ##     ###      
          ######    ###            ###    ######          
             ##  ########################  ##             
            ##         ###      ###         ##            
            ##           ##    ##           ##            
            ##             ####             ##            
            ##             ####             ##            
            ##          ###    ###          ##            
             ###     ####        ####     ###             
               ######                ######               
                                                          

                  Welcome to React Native!                
                 Learn once, write anywhere               

error Cannot initialize new project because directory "AwesomeProject" already exists.
DreamdeMac-mini:React_Native Dream$ cd AwesomeProject/
DreamdeMac-mini:AwesomeProject Dream$ yarn ios
yarn run v1.22.4
$ react-native run-ios
error Could not find "Podfile.lock" at /Users/Dream/Desktop/React_Native/AwesomeProject/ios/Podfile.lock. Did you run "pod install" in iOS directory?
info Found Xcode project "AwesomeProject.xcodeproj"
info Launching iPhone 11 (iOS 13.5)
info Building (using "xcodebuild -project AwesomeProject.xcodeproj -configuration Debug -scheme AwesomeProject -destination id=FD02AE2D-EDEE-4672-9AE3-33F21586C0A4")
▸ Running script 'Start Packager'
▸ Compiling AppDelegate.m

❌  /Users/Dream/Desktop/React_Native/AwesomeProject/ios/AwesomeProject/AppDelegate.h:1:9: 'React/RCTBridgeDelegate.h' file not found

#import <React/RCTBridgeDelegate.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~


▸ Compiling main.m

❌  /Users/Dream/Desktop/React_Native/AwesomeProject/ios/AwesomeProject/AppDelegate.h:1:9: 'React/RCTBridgeDelegate.h' file not found

#import <React/RCTBridgeDelegate.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~


▸ Compiling AwesomeProject_vers.c
▸ Compiling LaunchScreen.storyboard
▸ Processing Info.plist
▸ Running script 'Bundle React Native code and images'
▸ Touching AwesomeProject.app (in target 'AwesomeProject' from project 'AwesomeProject')
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening AwesomeProject.xcodeproj. Run CLI with --verbose flag for more details.

我不知道是不是因为pod出问题了,没有默认执行pod install,导致后面报错一大堆。

进入创建的项目ios目录下,执行pod install看看

DreamdeMac-mini:ios Dream$ pod install
/Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/digest/sha2.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (LoadError)

  Referenced from: /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/digest/sha2.bundle

  Reason: image not found - /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin16/digest/sha2.bundle

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/digest/sha2.rb:14:in `'

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/typhoeus-1.3.1/lib/typhoeus.rb:1:in `'

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/sources_manager.rb:5:in `'

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/core_overrides.rb:1:in `'

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'

from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.9.1/lib/cocoapods.rb:75:in `'

from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.9.1/lib/cocoapods.rb:17:in `'

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'

from /Users/Dream/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'

from /Users/Dream/.rvm/gems/ruby-2.3.0/gems/cocoapods-1.9.1/bin/pod:36:in `'

from /Users/Dream/.rvm/gems/ruby-2.3.0/bin/pod:22:in `load'

from /Users/Dream/.rvm/gems/ruby-2.3.0/bin/pod:22:in `'

from /Users/Dream/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'

from /Users/Dream/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `'

看这错误,还是是ruby版本不对,好,卸载ruby,重装ruby,过程是漫长的,在此过程中,我重新开了一个终端,进入到React Native创建的项目中,运行了pod install命令,结果,结果没报错,但是另外一边,我已经卸载ruby了,还要重新安装,我真是心疼崩了。

卸载ruby

简单,先查看当前ruby 版本

DreamdeMac-mini:ios Dream$ ruby --version

ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin16]

然后卸载

DreamdeMac-mini:ios Dream$ rvm uninstall ruby-2.3.0
ruby-2.3.0 - #removing src/ruby-2.3.0..
ruby-2.3.0 - #removing rubies/ruby-2.3.0.........................................-
Error running '__rvm_rm_rf /Users/Dream/.rvm/rubies/ruby-2.3.0',
please read /Users/Dream/.rvm/log/1594274115_ruby-2.3.0/remove.rubies.log

这都能报错,强制卸载,

DreamdeMac-mini:ios Dream$ sudo rvm uninstall ruby-2.3.0
Password:
ruby-2.3.0 - #removing rubies/ruby-2.3.0..
ruby-2.3.0 - #removing default ruby interpreter..............

输入密码,ok

重新安装ruby

再看下ruby版本

DreamdeMac-mini:ios Dream$ ruby -v
-bash: /Users/Dream/.rvm/rubies/ruby-2.3.0/bin/ruby: No such file or directory

成功报错,说明可以安装新版了,列出所有可用版本

DreamdeMac-mini:ios Dream$ rvm list known
# MRI Rubies

[ruby-]1.8.6[-p420]

[ruby-]1.8.7[-head] # security released on head

[ruby-]1.9.1[-p431]

[ruby-]1.9.2[-p330]

[ruby-]1.9.3[-p551]

[ruby-]2.0.0[-p648]

[ruby-]2.1[.10]

[ruby-]2.2[.10]

[ruby-]2.3[.8]

[ruby-]2.4[.9]

[ruby-]2.5[.7]

[ruby-]2.6[.5]

[ruby-]2.7[.0]

ruby-head

选择一个版本安装,在这里的时候,脑子抽了,跑了下面一句


DreamdeMac-mini:ios Dream$ rvm install ruby 2.6.5

Searching for binary rubies, this might take some time.

No binary rubies available for: osx/10.15/x86_64/ruby-2.6.5.

Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.

Checking requirements for osx_brew.

Installing requirements for osx_brew.

Updating system.......\

Xcode version older than 4.6.2 installed, download and install newer version from:

    http://connect.apple.com

After installation open Xcode, go to Downloads and install Command Line Tools.

.

Error running 'requirements_osx_brew_update_system ruby-2.6.5',

please read /Users/Dream/.rvm/log/1594274623_ruby-2.6.5/update_system.log

Requirements installation failed with status: 1.

不出意外的,报错了,找了半天,ruby和后面的版本号之间还有一个'-',我看到了,但是直接忽略了,懵逼,经过一番尝试(我不会说我又错误了很多次,而且还又装了一遍Command Line Tools),成功开始安装

DreamdeMac-mini:ios Dream$ rvm install ruby-2.6.5
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.6.5.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx_brew.
Installing requirements for osx_brew.
Updating system...........Failed to update Homebrew, follow instructions at

    https://docs.brew.sh/Common-Issues

and make sure `brew update` works before continuing.
.
Error running 'requirements_osx_brew_update_system ruby-2.6.5',
please read /Users/Dream/.rvm/log/1594275199_ruby-2.6.5/update_system.log
Requirements installation failed with status: 1.

好吧,先更新brew,这回一下就运行完了

DreamdeMac-mini:ios Dream$ brew update
Updated 1 tap (homebrew/core).
==> Updated Formulae
fastlane ✔                  batik                       teleport
azure-storage-cpp           ser2net

再来安装ruby


DreamdeMac-mini:ios Dream$ rvm install ruby-2.6.5

Searching for binary rubies, this might take some time.

No binary rubies available for: osx/10.15/x86_64/ruby-2.6.5.

Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.

Checking requirements for osx_brew.

Installing requirements for osx_brew.

Updating system..........

Installing required packages: coreutils, zlib|

前面的一串和我输入错误的时候,打印出来的东西一样,刚开始我还以为又要失败了,结果好像没有报错,至少在我写到这里的时候,还没报错,庆幸吧。

转过头看pod install怎么样了,结果报错了,嗯,报错了。再来一遍呗,我习惯了。

补充

ruby安装成功了

DreamdeMac-mini:ios Dream$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 205,386评论 6 479
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,939评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,851评论 0 341
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,953评论 1 278
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,971评论 5 369
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,784评论 1 283
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,126评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,765评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,148评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,744评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,858评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,479评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,080评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,053评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,278评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,245评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,590评论 2 343