简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM