Error when adding s.frameworks 'XCTest' to podspec dyld: Library not loaded: rpath/XCTest.framework/XCTest

820 Views Asked by At

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

1

There are 1 best solutions below

2
Tal Zion On BEST ANSWER

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