LoginSignup
85
81

More than 5 years have passed since last update.

【iOS】cocoapodsのインストール方法

Posted at

1. cocoapodsインストール

ホームディレクトリで以下を実行。

$ gem install cocoapods

※cocoapodsはgemだけどbundlerで管理しているわけはない。一度インストールしたらMac自体にインストールされる

2. pod setup

iOSプロジェクトに移動して以下を実行。

$ pod setup

しかし、ここで下記のエラーが発生!

$ zsh: command not found pod

gemコマンドでgemをインストールしたときは、rbenv rehashすればいいんだった!!

$ rbenv rehash

再びpod setup

$ pod setup

3. Podfileを作成

同じディレクトリで以下を実行。

$ pod init

これで、Podfileが作成されました。
Podfileを開いてみると、下記のようになっています。

$ cat Podfile
# Uncomment this line to define a global platform for your project
# platform :ios, '6.0'

target 'YourAppName' do

end

target 'YourAppNameTests' do

end

4. ライブラリをインストール

インストールしたいファイルを記入。

# Uncomment this line to define a global platform for your project
# platform :ios, '6.0'

target 'YourAppName' do
    pod "HogeHoge"
end

target 'YourAppNameTests' do

end

Xcodeを落として以下を実行。

$ pod install

bundle installみたいなものです。

以下のような警告がでたら、

Pods written in Swift can only be integrated as frameworks; this feature is still in beta. Add `use_frameworks!` to your Podfile or target to opt into using it.

Podfileにuse_frameworks!を追記して、pod install

# Uncomment this line to define a global platform for your project
# platform :ios, '6.0'
use_frameworks!

target 'YourAppName' do
    pod "HogeHoge"
end

target 'YourAppNameTests' do

end

さいごに

import出来ない場合
· https://github.com/Alamofire/Alamofire/issues/441
· http://vdeep.net/xcode63-cocoapods-alamofire-swiftyjson

85
81
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
85
81