I'm trying out the macro support in Swift 5.9. I created a new macro package using:
swift package init --type macro
And in the example, unit tests come with:
func testMacro() throws {
#if canImport(SelfNamedMacros)
assertMacroExpansion(
"""
#stringify(a + b)
""",
expandedSource: """
(a + b, "a + b")
""",
macros: testMacros
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}
But I can't see actually how to make #if canImport(SelfNamedMacros)
true and run the example test (my new macro package, i.e., the package directory, was named "SelfNamed").
That is, when I run the test, it always uses the XCTSkip
path.
When I select:
I get the issue I had. I.e., "canImport" is false.
When I select: