0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Pods(cocoaPods)ってなに!?!? - iOS Swift

Posted at

podsってなに

cocoaPodsとは

Androidで言うGradle的な立ち位置で、ライブラリ管理が簡単にできるツール(公式サイト)
読み方は「ココアポッズ」もしくは「ポッズ」

cocoaPodsのインストール方法

インストールはこちらのQiitaを参考に実施しました

brew update
brew upgrade

brew install rbenv ruby-build

rbenv install -l # 最新の安定版が表示されるので確認
rbenv install 3.4.5 # 確認した最新版を指定
rbenv global 3.4.5

nano ~/.zshrc
# 下記2行を追加
# export PATH="$HOME/.rbenv/bin:$PATH"
# eval "$(rbenv init -)"
CTRL + O # nanoで編集した内容を保存
# File name to write? はそのままエンターキーを押下
CTRL + X # nanoを終了

source ~/.zshrc
# ここまででcocoaPodsのインストール準備が完了

# ここからがcocoaPodsのインストールと設定
sudo gem install cocoapods
pod setup
cd "podsを設定したいパス(Xcodeのプロジェクト先)"
pod setup
pod init
ls # Podfileが表示されたらOK

初めてのライブラリのインストール方法

下記はGoogle Mapsを導入しています

cd "Podfileのあるパス(Xcodeのプロジェクト先)"
nano Podfile
# Podfileの中身↓
target 'プロジェクト名' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for プロジェクト名
  pod 'GoogleMaps', '6.1.0'
  pod 'Google-Maps-iOS-Utils', '3.4.0'
  
  target 'プロジェクト名' do
    inherit! :search_paths
    # Pods for testing
  end
  
  target 'プロジェクト名' do
    # Pods for testing
  end
# Podfileの中身↑

CTRL + O # nanoで編集した内容を保存
# File name to write はそのままエンターキーを押下
CTRL + X # nanoを終了

pod install

ここまで完了すると、プロジェクトフォルダ内に「プロジェクト名.xcworkspace」ができます。
Xcodeを開いている場合は終了し、次回からはxcworkspaceを開いて編集してください。

次回からはPodsの下にあるPodfileを直接変更できるようになります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?