iT邦幫忙

2023 iThome 鐵人賽

DAY 12
0
Mobile Development

SwiftUI 男孩系列 第 12

Day 12 : Mac M系列遇到 Ruby 坑 (回憶篇

  • 分享至 

  • xImage
  •  

https://ithelp.ithome.com.tw/upload/images/20230926/20130138tjIMmv10aB.jpg

Photo by Sander Lenaerts on Unsplash

今日聚餐來個回憶篇遇到的坑

接手新專案

$ pod install

後發現 CocoaPods 需要升級

$ sudo gem install cocoapods

執行後又說 Ruby 要先升級 ಠ_ಠ

但我也忘記當初怎麼裝 Ruby , 絕對沒有多版本 Ruby 环境的管理和切换。

$ brew install ruby

用 brew 安裝 Ruby ?

我又跑去裝 RVM

https://rvm.io/

$ \curl -sSL https://get.rvm.io | bash -s stable
$ source ~/.bashrc
$ source ~/.bash_profile

我開始走下面步驟:

列出已知的 Ruby 版本

$ rvm list known

安装一個 Ruby 版本

$ rvm install 2.7.2

但爆出安装 Ruby 在 Mac M 系列晶片,無法安裝

What the Fxxk (╯°Д°)╯︵┻━┻

ruby-2.7.2 - #removing src/ruby-2.7.2 - please wait
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/13.5/x86_64/ruby-2.7.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.

https://github.com/rvm/rvm/issues/5033

冷靜冷靜

仔細找問題

是 openssl 出問題

默認執行brew install openssl,安裝的是openssl@3,我試了發現得用openssl@1.1才行

$ brew list 

還真的是 openssl@3

$ brew uninstall openssl@3

跟著大神走下面步驟

$ sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.old
$ xcode-select --install

手沖個咖啡等 xcode-select --install

sudo rm -rf /Library/Developer/CommandLineTools.old
rvm get stable
rvm reload

brew install openssl@1.1
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

rvm install 2.7.2 --with-openssl-dir=`brew --prefix openssl@1.1`

我忘了還需要裝 ffi 嗎?

sudo gem install ffi

結論:我只是 pod install 怎麼被 apple 搞了,開始使用 swift package 管理套件好了

下一篇介紹 swift package

Refer: https://juejin.cn/post/7188810184217591868


上一篇
Day 11 : SwiftUI List (下)
下一篇
Day 13: Swift package
系列文
SwiftUI 男孩30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

0
leoho0722
iT邦新手 4 級 ‧ 2023-09-27 00:14:30

我自己裝 CocoaPods 的方法,給你參考一下

執行下面的指令前,要先將 Xcode 裝好

  • Intel 架構的 Mac
    • 方法一
    # Step 1:安裝 Ruby Version Manager (RVM)
    # 安裝完 RVM 後,要將 Terminal Command+Q 關閉重開
    \curl -sSL https://get.rvm.io | bash -s stable
    
    # Step 2:透過 RVM 安裝最新版 Ruby
    rvm install ruby <最新版 Ruby 的版號>
    
    # Step 3:安裝 CocoaPods
    sudo gem install cocoapods
    
    • 方法二 (推薦)
    brew install cocoapods
    
  • Apple Silicon 架構的 Mac
brew install cocoapods

我是 intel 轉移到 M1,過了一年遇到Ruby 升版問題,但邏輯推敲,重裝CocoaPods還會到 Ruby 升版問題吧。🤔

我要留言

立即登入留言