顯示具有 CocoaPods 標籤的文章。 顯示所有文章
顯示具有 CocoaPods 標籤的文章。 顯示所有文章

CocoaPods could not find compatible versions for pod

最近開始用Swift 4開發,想當然third party也要用到最新,以Alamofire、PKHUD為例,我分別需要4.7版、5.0版

        根據Alamofire官方PKHUD官方pod file應該是
        pod 'Alamofire', '~>  4.7'
        pod 'PKHUD', '~> 5.0'










結果pod install會遇到如下錯誤
        [!] CocoaPods could not find compatible versions for pod "Alamofire":
        In Podfile:
           Alamofire (~> 4.7)
        None of your spec sources contain a spec satisfying the dependency: `Alamofire (~> 4.7)`.
















實際上用pod search也的確是找不到Alamofire 4.7版、PKHUD 5.0版,解決方式參考CocoaPods Guides - The PodfileFrom a podspec in the root of a library repo.
修正後的pod file為
        pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '4.7.0'
        pod 'PKHUD', :git => 'https://github.com/pkluz/PKHUD.git', :branch => 'release/swift4'
   

再pod install成功執行如下
    

申請安裝Crashlytics

Crashlytics真的做得非常好,還沒真的導入到專案,就在安裝過程中感受到Twitter的誠意,無論是安裝流程或是後來的使用方式,真的是連笨蛋都會用XD

但還是紀錄一下吧,網路上目前的文章都有點舊了呢
安裝時間:2016年5月
安裝環境:Xcode 7.3

1.前往登入頁,申請使用Crashlytics


2.收到驗證信並開通
驗證信基本上幾分鐘內會收到(我是一提出申請馬上收到)
開通並輸入團隊名稱(方便管理專案)




3.開通成功,開始下載對應IDE的安裝檔




4.打開fabric.app並登入


5.選擇要導入的專案


6.選擇要安裝的SDK
這邊我先選Crashlytics而已


7.選擇安裝加載的方式(CocoaPods或Framework)
選完後會自動幫你把Xcode打開,我選CocoaPods,所以右圖是如何修改Podfile的指示


8.依照說明安裝
修改Podfile並update



9.將Fabric整合到Xcode(Add Run Script)
實際Add Run Script的步驟可參考官網步驟




10.開始寫code,讓Crashlytics可以在app中執行
按照指令將藍色highlight處貼到專案的AppDelegate.m


11.Done
給他一點時間跑,就完成啦!


真的很簡單呢!只要跟著第3步驟中安裝好的fabric.app,一步一步完成他所指示的所有事項,就能導入Crashlytics  ^_^
PS:登入過程中如果遭遇錯誤,可能是你的公司網路環境有阻擋,請暫時先改用其他網路環境安裝嚕

The dependency `AFNetworking ` is not used in any concrete target

今天終於更新到最新版CocoaPods 1.0.0

結果所有pod都報錯
The dependency `pod名稱 ` is not used in any concrete target

原來是新版CocoaPods的Podfile要開始指定target了
記錄一下新舊版差別,給遇到的人參考

舊版


新版


check in the Pods into source control ?

在Xcode搭配Git請參考這篇  將Xcode現有專案加入Git

如果專案有使用CocoaPods,.gitignore是否需要針對Pods處理呢?
答案是看你高興XD
只有Podfile 與 Podfile.lock一定要簽入版本控管,其他Pods就依照開發需求決定,簽入與否可參考CocoaPods的官方說明

Benefits of checking in the Pods directory
After cloning the repo, the project can immediately build and run, even without having CocoaPods installed on the machine. There is no need to run pod install, and no Internet connection is necessary.
The Pod artifacts (code/libraries) are always available, even if the source of a Pod (e.g. GitHub) were to go down.
The Pod artifacts are guaranteed to be identical to those in the original installation after cloning the repo.

Benefits of ignoring the Pods directory
The source control repo will be smaller and take up less space.
As long as the sources (e.g. GitHub) for all Pods are available, CocoaPods is generally able to recreate the same installation. (Technically there is no guarantee that running pod install will fetch and recreate identical artifacts when not using a commit SHA in the Podfile. This is especially true when using zip files in the Podfile.)
There won't be any conflicts to deal with when performing source control operations, such as merging branches with different Pod versions.
Whether or not you check in the Pods directory, the Podfile and Podfile.lock should always be kept under version control.

若上述優缺點還是無法協助你決定,可再參考stackoverflow的討論,看看哪種方式適合你~

參考資料
Should I check the Pods directory into source control?
What goes into your .gitignore if you're using CocoaPods?