Xcode Test step fails with:
/Users/vagrant/git/REDACTED/Models/REDACTED.swift:9:8: error: no such module 'X'
import X
...
Testing failed:
No such module 'X'
** TEST FAILED **
Module is a CocoaPods pod, installed with pod install / with the CocoaPods Install step.
Doing a clean git clone and Build and Run from Xcode.app works fine.
Note: Build works, but not Test!
Explanation:
CocoaPods Podfile config issue. The given pod/framework is specified for the non test main target, maybe even for the (unit) Test target, but not for the UI Test target!
E.g.:
platform :ios, '9.0'
use_frameworks!
target 'Xyz' do
pod 'MessageKit', "0.13.1"
end
target 'XyzTests' do
pod 'MessageKit', "0.13.1"
end
With a config like this you can successfully build & run the project in Xcode, even archive it, but running the Test action in Xcode.app will fail with compilation error, as the pod is only defined for the main and the (unit) test target, but not for the UI Test target, and by default Xcode compiles & runs both Unit and UI tests when you run the Test action in Xcode.app!
See e.g. https://github.com/CocoaPods/CocoaPods/issues/4944#issuecomment-188527223
target 'Demo App' do
pod 'Alamofire'
target 'Demo AppTests' do
inherit! :search_paths
pod 'OHHTTPStubs'
end
target 'Demo AppUITests' do
inherit! :search_paths
pod 'OHHTTPStubs'
end
end
defines the pod for both the Tests
and for the UITests
target.