概要
pod installしたライブラリのswiftバージョンが古くてBuildできないときの対処法について
実際に僕が陥った状況と、どのように対処したかをまとめます
環境
Xcode Version 10.1
cocoapods version 1.5.3
やりたかったこと
Swift 4.2
の開発環境に、Tinder風UIライブラリZLSwipeableViewSwiftを導入(pod install
)したかった
やったこと
Podfileを以下のように作成し、pod install
した
Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'AppName' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for AppName
pod 'ZLSwipeableViewSwift'
end
起きたこと
直すためにやったこと
対象のライブラリのcommitログを拝見し、swift4
対応まで行われていることを確認。
ではなぜpod 'ZLSwipeableViewSwift'
では、swift3系でinstallされたのか。
→無理やり最新のコミットを指定すれば、swift4系の改修が取り込まれているはず。
そこで、pod installしたいライブラリの最新のcommitを指定し、pod update
を実行
Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'AppName' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for AppName
pod 'ZLSwipeableViewSwift', :git => 'https://github.com/zhxnlai/ZLSwipeableViewSwift.git', :commit => '18d6109'
end
無事、ビルド成功しました。
参考文献
あとがき
一旦、 ちからわざ即席で対応しましたが、もっとスマートな解決方法がありましたら、どなたかご教授ください