Import XCTest into a dynamic framework Import XCTest into a dynamic framework swift swift

Import XCTest into a dynamic framework


I've run into similar issue and used build settings from Nimble project. To fix issue:

1: Add to Other Linker Flags:

-weak_frameworkXCTest-weak-lswiftXCTest

2: Add to Framework Search Paths:

$(DEVELOPER_FRAMEWORKS_DIR)$(PLATFORM_DIR)/Developer/Library/Frameworks

Now dynamic framework can import XCTest.

Sidenote: I also wanted to write something similar. I've ended up creating mini-framework for unit testing error handling in Swift, maybe someone will find it useful. Works both with CocoaPods and Carthage.


If you are creating a framework using Cocoapods, you need to add the XCTest in your .podspec file:

Pod::Spec.new do |spec|  ...  spec.framework = 'XCTest'end