Unable to build Swift Macro package

I want to play with Swift Macros, but I'm unable to build the template. I use File -> New -> New Package and the generated project doesn't compile.

How to make it work?

Xcode: Version 15.0 beta 4 (15A5195m)
macOS: 13.4 Ventura
MacBook M1 Pro

I asked also my friends at work to try it on their computers and all of them ended up with the same result. Even though they were using different Xcode betas - 2 and 3.

2 Likes

You'll need to go into the tests and disable test coverage.

2 Likes

Do you know if there's any way to use test coverage with macros?

Also I'm not entirely sure what the best way to disable coverage is in the beta - it seems like the dropdown from the scheme editor is missing in packages with macros.

1 Like

I don't blame you, here's how to get there:

Under the tests tab in the sidebar, you'll see a new dropdown for testplans.

image

If you click that dropdown, you'll click to edit the test plan:

image

Then in your main editor, click "Configurations"

Scroll down 'till you see "Code Coverage"

Turn that off by unchecking the checkbox:

I really think it's an unnecessary and confusing change right now, but :man_shrugging: I guess it's better for the long term. I don't know how to run it with Test Coverage enabled.

4 Likes

Wait what... I can't believe it worked... What the hell :D? Why?

And how did you figure it out :D?

You sir, are a legend. Thank you!

If you expand the error, it states the missing symbols.

One solution from there is to look it up: xcode - Undefined symbols ___llvm_profile_runtime - Stack Overflow

But when we noticed the symbol, it pretty much clicked because of our pre-existing knowledge of the symbol.

1 Like

Didn't help in my case, even removing all tests from schemes doesn't help. But my "Undefined symbols" error is different too

The package builds on CI, but fails locally.

And I'm also confused because swift-macro-toolkit (another package with macros) compiles with no problems even with the default testsuite...

UPD:
Well, after hours of searching for workarounds I managed to fix the issue, I simply forgot to declare a compiler plugin type :sweat_smile:, but the error was not helpful at all :skull:

3 Likes

Thank you for updating your post with the solution! You spent hours and as a result I only had to spend minutes - so thank you!