I'm trying to create automated UI tests for my iOS app. After generally failing to get this working on my existing app, I created a new one from scratch and tried there. It always seems to fail because it can't import dependencies I've installed with Cocoapods.
I'm currently running XCode Version 10.2.1 (10E1001)
Instructions to replicate:
UITestProto
pod init
on the project.HydraAsync
dependencyThe Podfile should look like this:
# Uncomment the next line to define a global platform for your project
platform :ios, '12.2'
target 'UITestProto' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for UITestProto
target 'UITestProtoTests' do
inherit! :search_paths
# Pods for testing
end
target 'UITestProtoUITests' do
inherit! :search_paths
# Pods for testing
pod 'HydraAsync'
end
end
UITestProtoUITests
target in XCode and set "Always Embed Swift Standard Libraries" to $(inherited)
:pod install
UITestProto.xcworkspace
UITestProtoUITests.swift
file and try to import the OHHTTPStubs module.import XCTest
import Hydra
class UITestProtoUITests: XCTestCase {
...
At this point you should see the error:
No such module 'Hydra'
I've tried:
@testable import UITestProto
because I've had to do that for my unit testsAnd I've cleaned the build folder and closed/open XCode after each of those steps, but still no luck on the Hydra import.
Note: I'm not actually using Hydra for testing, it's just a library that I've successfully used in projects in the past
This is related to a CocoaPods issue. The workaround suggested here does the trick for me. You may need to rebuild the project though.
For future reference, I've cc-ed the post:
# Moving the UITests target outside of the main target
# in the Podfile seems to have helped. So now instead of this:
target 'Target' do
use_frameworks!
...
target 'TargetTests' do
inherit! :search_paths
...
end
target 'TargetUITests' do
inherit! :search_paths
...
end
end
## we have this:
target 'Target' do
use_frameworks!
...
target 'TargetTests' do
inherit! :search_paths
...
end
end
target 'TargetUITests' do
inherit! :search_paths
... # all the pods we normally use
end
Credits to PWrzesinski