BadmintonCat
BadmintonCat

Reputation: 9576

Using XCTest in non-Test Target

I'm writing a reusable framework around XCTest for UI testing of several of our projects. For this I created a Cocoa Touch Framework project that I want to share via pods.

Is it possible to include XCTest into such a project (without extra test targets)? I'm getting errors that the XCTest module cannot be found even though I've linked XCTest.framework in the build phases.

Upvotes: 2

Views: 1454

Answers (1)

imnosov
imnosov

Reputation: 856

You should add $(PLATFORM_DIR)/Developer/Library/Frameworks into Framework Search Paths which in the Build Settings of your framework target. Basically, you don't have to link your framework against XCTest.framework.

Also, if you're going to share the framework via pods you can add following code to your podspec file:

Pod::Spec.new do |s|
  ...
  s.weak_framework = "XCTest"
  s.pod_target_xcconfig = {
    'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks"',
  }
  ...
end

Upvotes: 9

Related Questions