How to keep tests from getting "stuck" on previously compiled macro expansion?

I seem to be running into situations from time to time where my swift-testing tests seem to get "stuck" on a previously compiled version. I might write a test (which fails)… make a change in the test function (that should pass when running)… run the test again… and it fails. Cleaning the build folder (and compiling and running again) builds the "new" version of the test. I can also usually comment out the whole test and then uncomment the test (and build again). That usually does the trick so the compiler sees the new code.

This might be a general limitation of macros (where we are liberal with assuming our cached expansion is still correct) and working around this is just part of the DevX for now. Any more tips or tricks for working around that? It kind of slows me down when I make a change that should pass but keeps failing (and then starts passing once I remember to shake up the compiler).

This sounds like it may be a bug in Swift Package Manager or in Xcode (depending on which you're using to build your code.) If you're using SwiftPM, would you please open a GitHub issue against the SwiftPM repo? If you're using Xcode, please use Apple's Feedback Assistant to report the bug.

1 Like

Ahh… I forgot to mention that I am on Xcode_16_beta_4 seeing these expansion bugs. I also saw this from previous betas over the summer.