1

I have a CocoaPod which uses the XCTest framework. To import XCTest to the pod, I added s.frameworks = 'XCTest' to the .podspec file.

I am now able to import XCTest to the pod classes but when trying to run the Example project, I am getting the following error:

dyld: Library not loaded: @rpath/XCTest.framework/XCTest

Referenced from: /Developer/CoreSimulator/Devices/DEVICE_UUID/data/Containers/Bundle/Application/ID/TestPod_Example.app/Frameworks/TestPod.framework/TestPod

Reason: image not found

Community
  • 1
  • 1
Tal Zion
  • 6,308
  • 3
  • 50
  • 73

1 Answers1

3

Found a solution, when adding XCTest framework in the podspec, make sure to add it to your UITesting and Testing targets only in the Podfile.. This is because XCTest cannot run on a developed target, only on a test targets.

In your Podfile

target 'MyProjectTestTarget' do
   pod 'PodFramework that includes XCTest as a dependency'
end
Tal Zion
  • 6,308
  • 3
  • 50
  • 73
  • Hi, can you give an example what you mean by "add it to your UITesting and Testing targets only in the Podfile"? – BadmintonCat Jul 18 '17 at 06:49
  • Sure @BadmintonCat I amended the answer. If you can bump up my question and answer, that would be awesome! ;) – Tal Zion Jul 18 '17 at 06:55