ios – How can I embody XCTest as a dependency in a Swift (SPM) package deal?


I’m making a Swift package deal to increase the performance of XCTest, however am having bother constructing my app’s assessments when the package deal is used.

I’ve begun by importing XCTest to considered one of my package deal’s (non-test) class recordsdata. In that file, I will use that class to work with XCTest (for instance, XCUIScreen). The complete package deal compiles with out error.

I’ve added my take a look at helper package deal as an area dependency to a different app I am constructing on my machine. Then I arrange the package deal within the app’s take a look at goal, underneath the “Hyperlink Binary With Libraries” part.

I can import my take a look at helper package deal to my app’s take a look at class, however when I attempt to use the package deal’s class, I get the next construct error:

ld: warning: Couldn't discover or use auto-linked library 'XCTestSwiftSupport': library 'XCTestSwiftSupport' not discovered
ld: warning: Couldn't discover or use auto-linked framework 'XCTest': framework 'XCTest' not discovered
ld: Undefined symbols:
  _OBJC_CLASS_$_XCUIScreen, referenced from:
       in MyXcodeTestHelper.o
  __swift_FORCE_LOAD_$_XCTestSwiftSupport, referenced from:
      __swift_FORCE_LOAD_$_XCTestSwiftSupport_$_MyXcodeTestHelper in MyXcodeTestHelper.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is there a configuration I’ve missed, or one thing I can add to my package deal description file to point XCTest must be a dependency? If it is not attainable, are there any good alternate options? I’m utilizing Xcode 15.0.

Any assistance is appreciated.