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

雜談

這兩天,閑著赞弥,給自己找點事做。

看了Swift版的Pinlayout布局方式趣兄,了解了之前計算view和cell高度一直使用了錯誤的方法绽左,算是進步吧。

看了單元測試艇潭,終于明白了怎么用拼窥,都不知道是第幾次看了,以后總算是會用了蹋凝,也算是進步吧鲁纠。

看了一眼React Native,然后突發(fā)奇想鳍寂,用React Native重新寫一遍用oc和Swift混編的app會怎么樣改含,然后用Flutter也寫一遍,正好兩個都熟悉一下迄汛,說干就干捍壤。

理想是美好的,現(xiàn)實是殘酷的鞍爱,裝環(huán)境就搞了一天鹃觉。

開始

本文使用React Native參考鏈接

安裝依賴

安裝node
node在我上次用Sublime Text的時候安裝了,這里略過

安裝watchman
Watchman是由 Facebook 提供的監(jiān)視文件系統(tǒng)變更的工具睹逃。安裝此工具可以提高開發(fā)時的性能(packager 可以快速捕捉文件的變化從而實現(xiàn)實時刷新)盗扇。

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

打印的東西太多,中間省略的好多,重點是最后報錯了疗隶,沒有權(quán)限躬柬,那就手動創(chuàng)建了,然后再分配權(quán)限

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

又是沒有權(quán)限史汗,分配權(quán)限,然后安裝

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
已經(jīng)安裝了拒垃,這里也略過

新建React Native項目
環(huán)境安裝完了停撞,開始新建項目

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,這...悼瓮,都用了好幾年了戈毒,怎么還要裝。結(jié)果鬼使神差的執(zhí)行了安裝横堡,然后就出現(xiàn)了數(shù)不清的問題埋市。
先根據(jù)提示,用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哪里出問題了,懵逼葬项。
不管了泞当,重新創(chuàng)建項目看下會不會有問題

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出問題了,沒有默認執(zhí)行pod install玷室,導(dǎo)致后面報錯一大堆零蓉。

進入創(chuàng)建的項目ios目錄下,執(zhí)行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創(chuàng)建的項目中落包,運行了pod install命令,結(jié)果摊唇,結(jié)果沒報錯咐蝇,但是另外一邊,我已經(jīng)卸載ruby了巷查,還要重新安裝有序,我真是心疼崩了。

卸載ruby

簡單岛请,先查看當(dāng)前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和后面的版本號之間還有一個'-'松申,我看到了云芦,但是直接忽略了,懵逼贸桶,經(jīng)過一番嘗試(我不會說我又錯誤了很多次舅逸,而且還又裝了一遍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|

前面的一串和我輸入錯誤的時候,打印出來的東西一樣水醋,剛開始我還以為又要失敗了旗笔,結(jié)果好像沒有報錯,至少在我寫到這里的時候拄踪,還沒報錯蝇恶,慶幸吧。

轉(zhuǎn)過頭看pod install怎么樣了惶桐,結(jié)果報錯了撮弧,嗯潘懊,報錯了。再來一遍唄贿衍,我習(xí)慣了授舟。

補充

ruby安裝成功了

DreamdeMac-mini:ios Dream$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市贸辈,隨后出現(xiàn)的幾起案子释树,更是在濱河造成了極大的恐慌,老刑警劉巖擎淤,帶你破解...
    沈念sama閱讀 221,273評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件躏哩,死亡現(xiàn)場離奇詭異,居然都是意外死亡揉燃,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,349評論 3 398
  • 文/潘曉璐 我一進店門筋栋,熙熙樓的掌柜王于貴愁眉苦臉地迎上來炊汤,“玉大人,你說我怎么就攤上這事弊攘∏栏” “怎么了?”我有些...
    開封第一講書人閱讀 167,709評論 0 360
  • 文/不壞的土叔 我叫張陵襟交,是天一觀的道長迈倍。 經(jīng)常有香客問我,道長捣域,這世上最難降的妖魔是什么啼染? 我笑而不...
    開封第一講書人閱讀 59,520評論 1 296
  • 正文 為了忘掉前任,我火速辦了婚禮焕梅,結(jié)果婚禮上迹鹅,老公的妹妹穿的比我還像新娘。我一直安慰自己贞言,他們只是感情好斜棚,可當(dāng)我...
    茶點故事閱讀 68,515評論 6 397
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著该窗,像睡著了一般弟蚀。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上酗失,一...
    開封第一講書人閱讀 52,158評論 1 308
  • 那天义钉,我揣著相機與錄音,去河邊找鬼级零。 笑死断医,一個胖子當(dāng)著我的面吹牛滞乙,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播鉴嗤,決...
    沈念sama閱讀 40,755評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼斩启,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了醉锅?” 一聲冷哼從身側(cè)響起兔簇,我...
    開封第一講書人閱讀 39,660評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎硬耍,沒想到半個月后垄琐,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,203評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡经柴,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,287評論 3 340
  • 正文 我和宋清朗相戀三年狸窘,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片坯认。...
    茶點故事閱讀 40,427評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡翻擒,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出牛哺,到底是詐尸還是另有隱情陋气,我是刑警寧澤,帶...
    沈念sama閱讀 36,122評論 5 349
  • 正文 年R本政府宣布引润,位于F島的核電站巩趁,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏淳附。R本人自食惡果不足惜议慰,卻給世界環(huán)境...
    茶點故事閱讀 41,801評論 3 333
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望奴曙。 院中可真熱鬧褒脯,春花似錦、人聲如沸缆毁。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,272評論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽脊框。三九已至颁督,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間浇雹,已是汗流浹背沉御。 一陣腳步聲響...
    開封第一講書人閱讀 33,393評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留昭灵,地道東北人吠裆。 一個月前我還...
    沈念sama閱讀 48,808評論 3 376
  • 正文 我出身青樓伐谈,卻偏偏與公主長得像,于是被迫代替她去往敵國和親试疙。 傳聞我的和親對象是個殘疾皇子诵棵,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,440評論 2 359