I've been trying to create a library that implements Swift macros and unit tests them. For the sake of simplicity, the attached project library has just 2 targets:
MacrosCore
- the actual macros implementation with a single empty macro that does nothing.MacrosCoreTests
- the unit tests target with a single test leveraging Pointfree's swift-macro-testing.Thus, the generated project has an executable and a unit tests target.
The executable compiles fine, but when I try to run the tests the _SwiftSyntaxTestSupport
complains that it can't find XCTest symbols. I was able to get around it by manually adding the XCTest framework to _SwiftSyntaxTestSupport
's Frameworks and Libraries
section in Xcode.
Still, this does not resolve the issue completely, because at this point the linker says it can't find symbols defined in the MacrosCore
target. While this makes sense in general, since MacrosCore
is an executable, I wonder if there's a workaround.
tuist fetch
.tuist generate
.MacrosCore
scheme._SwiftSyntaxTestSupport:
Cannot find 'XCTUnwrap' in scope
Cannot find 'XCTAssertNil' in scope
Cannot find ‘XCTFail’ in scope
etc ...
ld: Undefined symbols:
protocol witness table for MacrosCore.EmptyMacro : SwiftSyntaxMacros.Macro in MacrosCore, referenced from:
MacrosCoreTests.EmptyMacroTests.testEmptyMacro() throws -> () in SomeTests.o
type metadata for MacrosCore.EmptyMacro, referenced from:
MacrosCoreTests.EmptyMacroTests.testEmptyMacro() throws -> () in SomeTests.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
14.2.1
3.41.0
15.1
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too