facebook twitter hatena line email

「Ios/swift/外部ライブラリ/インストール」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(Podfile編集)
(プロジェクトファイル変更)
 
(同じ利用者による、間の10版が非表示)
行18: 行18:
 
  # platform :ios, '9.0'
 
  # platform :ios, '9.0'
 
  target 'Helloworld' do
 
  target 'Helloworld' do
 +
  # Comment this line if you're not using Swift and don't want to use dynamic frameworks
 
   use_frameworks!
 
   use_frameworks!
 +
  # Pods for Helloworld
 
   target 'HelloworldTests' do
 
   target 'HelloworldTests' do
 
     inherit! :search_paths
 
     inherit! :search_paths
 +
    # Pods for testing
 
   end
 
   end
 
   target 'HelloworldUITests' do
 
   target 'HelloworldUITests' do
 
     inherit! :search_paths
 
     inherit! :search_paths
 +
    # Pods for testing
 
   end
 
   end
 
  end
 
  end
行31: 行35:
 
  $ vi Podfile
 
  $ vi Podfile
 
  platform :ios,'9.0'
 
  platform :ios,'9.0'
 +
use_frameworks!
 
  target 'Helloworld' do
 
  target 'Helloworld' do
        use_frameworks!
+
         pod 'SDWebImage', '~>3.6'
         pod 'AlamofireImage'
+
 
  end
 
  end
 +
 +
podライブラリ更新処理
 +
$ pod update
  
 
==pod install==
 
==pod install==
行40: 行47:
 
  Analyzing dependencies
 
  Analyzing dependencies
 
  Downloading dependencies
 
  Downloading dependencies
  Installing Alamofire (3.4.1)
+
  Installing SDWebImage (3.8.1)
Installing AlamofireImage (2.4.0)
+
 
  Generating Pods project
 
  Generating Pods project
 
  Integrating client project
 
  Integrating client project
 +
 +
==プロジェクトファイル変更==
 +
Helloworld.xcodeprojではなく、
 +
Helloworld.xcworkspaceを開く
 +
 +
でないと以下エラーが出る
 +
/clang:-1: linker command failed with exit code 1 (use -v to see invocation)
 +
 +
==参考==
 +
*http://program.station.ez-net.jp/special/handbook/objective-c/cocoapods/install.asp
 +
*http://dev.classmethod.jp/smartphone/iphone/cocoapods/
 +
*http://qiita.com/ShinokiRyosei/items/7187ffb71862aba7e240
 +
*http://qiita.com/so1_/items/e0b5b681890c15e05ef1

2018年7月5日 (木) 14:50時点における最新版

macにcocoapadsをインストール

$ sudo gem update --system 
$ sudo gem install cocoapods

以下のようにエラーが返ってくる場合は

Operation not permitted - /usr/bin/fuzzy_match

このようにする(El Capitanからインストールフォルダが/usrの下へのインストールがアクセスできなくなったため)

$ sudo gem install -n /usr/local/bin cocoapods

cocoapodsのsetup

$ pod setup
> Setup completed

Podfile作成

プロジェクトDirの下で

$ pod init

以下Podfileのファイルができる

# platform :ios, '9.0'
target 'Helloworld' do
 # Comment this line if you're not using Swift and don't want to use dynamic frameworks
 use_frameworks!
 # Pods for Helloworld
 target 'HelloworldTests' do
   inherit! :search_paths
   # Pods for testing
 end
 target 'HelloworldUITests' do
   inherit! :search_paths
   # Pods for testing
 end
end

Podfile編集

こんな感じでライブラリ指定

$ vi Podfile
platform :ios,'9.0'
use_frameworks!
target 'Helloworld' do
        pod 'SDWebImage', '~>3.6'
end

podライブラリ更新処理

$ pod update

pod install

$ pod install
Analyzing dependencies
Downloading dependencies
Installing SDWebImage (3.8.1)
Generating Pods project
Integrating client project

プロジェクトファイル変更

Helloworld.xcodeprojではなく、 Helloworld.xcworkspaceを開く

でないと以下エラーが出る

/clang:-1: linker command failed with exit code 1 (use -v to see invocation)

参考