I created a Swift library with swift package init --type library
and generated an Xcode project with swift package generate-xcodeproj
.
Now I'm trying to run the Test scheme in Xcode. It prints following error:
Module '<title>' was not compiled for testing
However when I run swift build
and swift test
in terminal, it works fine.
I have ENABLE_TESTABILITY
set to YES
in all of the targets. I didn't change anything in the project except this. How can I make Xcode perform unit testing?
You need to set the "Enable Testability" to Yes in build setting over your "Main Target"
I was having this issue today, it seems like @testable
cannot be used with projects generated by Swift Package Manager.
Removing @testable
from my import statements solved this issue. Of course, this means we can only test the public interface of our modules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With