0

I have a project which depends on a cocoapod dependency, this dependency has a Unit Tests target that contains some mocking files I want to use in the tests of my host application. Example:

@import testable MyPod_Unit_Tests
class HostApplicationTestCase: XCTestCase {
    func setup() {
        let mockObj = UsefulPodMockObject()
....

then I get the following building error:

ld: warning: directory not found for option '-F/Users/macuser/dev/projs/HostProject/Pods/pod-library/pod-library/Frameworks' ld: warning: Could not find or use auto-linked framework 'RandomCocoapodsDependencyFromPodfile' Undefined symbols for architecture x86_64: "MyPod_Unit_Tests.UsefulPodMockObject.init() -> MyPod_Unit_Tests.UsefulPodMockObject", referenced from: closure #1 () -> () in HostApplicationUnitTests.HostApplicationTestsCase.spec() -> () in HostApplicationTestsCase.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Thanks in advance.

chuckSaldana
  • 1,187
  • 12
  • 28

1 Answers1

1

First, exclude the mocks folder from the test-spec source files with:

test_spec.source_files = 'MyPod/Tests/**/*.{h,m,swift}'
test_spec.exclude_files = 'MyPod/Tests/Mocks'

Then, include the new path for the mocks folder in the source files attribute of the main spec:

spec.source_files = ['MyPod/Classes/**/*', 'MyPod/Tests/Mocks/**/*']

This way we keep our folder organized and the podspec takes care of target ownership, just remember to use this folder location consistently.

chuckSaldana
  • 1,187
  • 12
  • 28