1427796173_full.jpeg

上一篇講到CocoaPods的基本安裝與使用方法,

而對於 CocoaPods 在 .gitignore 檔案中的設定,

這篇討論中有網友好心列出了幾個原則:

  • The  Podfile must always be under source control.
  • The  Podfile.lock must always be under source control.
  • The Workspace generated by CocoaPods should be kept under source control.
  • Any Pod referenced with the  :path option should be kept under source control.
  • The  ./Pods folder can be kept under source control.

在我們公司目前協做的案子中,
有遇到一個 CocoaPods 使用上的問題,
我們使用的一個第三方 Library 中的檔案有被稍做更動以符合目前專案所需,
卻也因為這個更動讓每次新加入專案的同仁都需要手動去更改 Pods 中的某個套件,
此外每當 pull 一個 commits 下來時都需要再下 pod install 來確保 pods 中各項版本一致(這個問題有部分原因是出在我和同事的 cocoapods 版本不一致所造成),
我花了許多時間在網路上爬文,
發現有不少人建議將Pods資料夾一併加入版本控管之中,
比如說上面的連結中,
Luke Redpath這位老兄強而有力的論點獲得了近百個正面投票:

I commit my Pods directory. I don’t agree that the Pods directory is a build artefact. In fact I’d say it most definitely isn’t. It’s part of your application source: it won’t build without it!

It’s easier to think of CocoaPods as a developer tool rather than a build tool. It doesn’t build your project, it simply clones and installs your dependencies for you. It shouldn’t be necessary to have CocoaPods installed to be able to simply build your project.

By making CocoaPods a dependency of your build, you now need to make sure it’s available everywhere you might need to build your project…a team admin needs it, your CI server needs it. You should, as a rule, always be able to clone your source repository and build without any further effort.

Not committing your Pods directory also creates a massive headache if you frequently switch branches. Now you need to run pod install every time you switch branches to make sure your dependencies are correct. This might be less hassle as your dependencies stabilise but early in a project this is a massive time sink.

So, what so I ignore? Nothing. Podfile, the lock file and the Pods directory all get committed. Trust me, it will save you a lot of hassle. What are the cons? A slightly bigger repo? Not the end of the world.

 

又或是Including your Pods directory in source control這篇,
他們的開發團隊商量了一個多月後終於決定要把 Pods 資料夾加入版本控管中,
他整理出的優點有:

  • 在切換 branch 或是查看舊的 commits 時不用再下 pod install
  • 掌握 Pods 資料夾內檔案的更動,不會因第三方軟體更新到毀滅版本而不知所措
  • 擁抱所有的開發者,包括那些不愛使用CocoaPods的人

而他唯一能想到的負面影響是:

  • 從git上pull包含Pods的內容檔案會比較巨大

從結果來看是 Z > B,
也許未來在開發專案中真的可以考慮把Pods加入版本控管中。