Post

Replies

Boosts

Views

Activity

Reply to Swift Package Tests in Test Plan: “Module was not compiled for testing”
The critical piece in making this work is ensuring you choose the correct reference to your .xctestplan file within your scheme configuration. I was running into the same errors after wanting to find a way to bundle both my app's unit testing target and multiple .testTargets included in a local SPM package into a single scheme / .xctestplan so that my build machine could run using a single scheme and hit all targets at once. Within the directory of your Xcode project, your .xctestplan file can live wherever you'd like it to (I like to keep mine within a Test Plans folder within the target folder - just make sure that you add the file as a reference within your project as well). Then open the .xctestplan file and under the Tests tab, use the + icon to add all of the test targets you want (can be from either the app's target list or the local SPM packages). Open the Edit Scheme... menu for your scheme and pull up the tests section. Use the + icon to Add existing Test Plan... and you should see a dialog appear showing two instances of the same .xctestplan file Choosing the one found under the Packages folder will give that scheme access to the targets it needs to resolve the import error, and if you've previously added the other one, you will encounter this error. If you have previously chosen the other one, you can remove it from the scheme using the - button and add back the correct one which will also solve the error Hope this solves the issue for you!
Oct ’22