當使用 Cocoapods 的 pod lib create YourLib 後,只會得到 Example Project 下的 Test 資料夾,這 Test 是包含 Host App 的,而在 Development Pod 中並不會包含 Test 資料夾。 這有點不方便也不直覺,不過經由設定即可得到以下比較好的檔案結構

如要在 Development Pod 中加入 Test,則需要額外設定 (以CCRegionSelector為例):
在 CCRegionSelector.podspec 中需要增加這段
s.test_spec 'Tests' do |test_spec| |
在 Example 中的 Podfile 中也需要增加 :testspecs => ['Tests']
target 'CCRegionSelector_Example' do |
這邊要注意的是必須先在 Tests 資料夾內先隨便新增一個檔案,不然會得到以下錯誤… 有點雷
Unable to install the
CCRegionSelectorpod, because theCCRegionSelector-Unit-Teststarget in Xcode would have no sources to compile.
最後在 Example 資料夾內跑完 pod install 後如果沒看到新的 scheme,則在 Xcode 中 manage scheme 內將 CCRegionSelector-Unit-Tests show 打勾就完成了

不過這樣即使還沒有 Host App,但跑測試還是會默默需要模擬器而無法更快測試,需要再看看有沒有解法可以加速
在 CocoaPods 1.4 時支援設定是否需不需要 app host
s.test_spec 'Tests' do |test_spec| |
在 CocoaPods 1.8 時支援 UITest bundle
s.test_spec 'UITests' do |test_spec| |
Ref: