はじめに
最近、cocoapodsが1.x系のアナウンスをしてくるので、WWDC2016まえにアップデートしたみました。
環境
- OS X El Captian 10.11.5
- Xcode7.3.1
- Swift2.2
- cocoapods-1.0.1
違い
バージョンの古い記述のPodfileでpod install
仕様としても、コマンドの実行自体は行えますが、以下のようなメッセージが表示され、ライブラリがインストールされません。
$ pod install
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 0 dependencies from the Podfile and 0 total pods installed.
[!] The Podfile does not contain any dependencies.
ちなみにcocoapods0.x系のPodfileはこのような形でした
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!
target 'ClipCast' do
pod 'Firebase'
end
target 'ClipCastTests' do
end
target 'ClipCastUITests' do
end
こちらが、cocoapods1.x系です
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'ClipCast' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for ClipCast
pod 'Firebase'
target 'ClipCastTests' do
inherit! :search_paths
# Pods for testing
end
target 'ClipCastUITests' do
inherit! :search_paths
# Pods for testing
end
end
cocoapodsのBlogでもあるように
Defines a CocoaPods target and scopes dependencies defined within the given block. A target should correspond to an Xcode target. By default the target includes the dependencies defined outside of the block, unless instructed not to inherit! them.
とあり、デフォルトでは、メインのブロックのそとで定義した依存関係が含まれるとあります。
cocoapods1.0系では、pod initすると
use_frameworks!
がメインブロックになかに記述されている事がわかります。
おわりに
詳しい実装は、ソースコードを追っていないためよく理解はしていませんが、なには無くともpod init
をしていれば、そこまでハマる事もないかと思いますので、ツールのドキュメントに沿って、使用する事が望ましいと思いました。