XCTest Framework imported in Swift when using Ninja as generator
I'm working on a project where we build a shared framework in Objective C/ C / C++. The project is setup using CMake and this toolchain file https://github.com/leetal/ios-cmake to create libraries for different Apple devices. Everything works well building the library when using Xcode or Ninja as generator. The framework is built as a module to be imported in a Swift application.
As a reference we're implementing unit tests of the framework in Swift to show the App team how to utilise it. In CMakeLists we setup XCTest according to your instructions and if using Xcode as generator it works properly. All good there, but when using Ninja as generator a problem arises when linking the Swift test target due to:
error: cannot find 'XCTAssert' in scope
^~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/Headers/XCTestAssertions.h:72:9: note: macro 'XCTAssert' not imported: function like macros not supported
#define XCTAssert(expression, ...) \
error: cannot find 'XCTAssertNotNil' in scope
^~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/Headers/XCTestAssertions.h:63:9: note: macro 'XCTAssertNotNil' not imported: function like macros not supported
and so on. To be able to run the unit tests on the host machine I'm compiling the framework using Mac Catalyst support (the framework has a dependency to UIKit). As seen above it looks like the Swift target is trying to use the XCTest framework instead of the XCTestSwiftSupport library. I've done some reading on this and found https://forums.swift.org/t/missing-libxctestswiftsupport-dylib/35314/8 Now I don't know what the Xcode property "Enable Testing Search Paths" does but either way it doesn't matter when using Ninja.
So in some way I would like the linker to use the XCTestSwiftSupport library instead. I've tried to modify the linker properties but without any luck, the Framework seems to be checked first.
Thanks for your fantastic work.