I recently updated to Xcode 7 beta 5. I tried adding a unit test to an earlier project, but I am getting the error message \"No such module [myModuleName]\" on the @te
My solution is here.
Firstly OdeAlSwiftUITest.swift click, then check Project TargetName in target membership.
After spending couple of days on this issues finally I make it to work with my project. Problem was in Bridging Header - path in Tests target can't be empty if you are using Bridging Header in your main target
Hope it will save some time for someone.
In my case , I had 3 issues. The first was that I had to specify the import path in :
Target -> Build Settings -> Swift Compiler - Search Paths -> Import Paths
The second was that I was using Pods and I had to import these pods to my tests as well using :
target 'MyAppTests' do
inherit! :complete
end
The third one as that I was using a bridging header in my target , thus I had to specify the bridging header to be the same for the test.
One gotcha to watch for is that if your module name has a dash character in it -
then you will have to refer to it with an underbar instead _
. For some reason I suspected this might be an issue and it was indeed my issue.
eg. @testable import Ocean-Swift
becomes @testable import Ocean_Swift
Just one other thing, if you do use the @testable
syntax be sure to not include your production code in your test target. I've found this will cause inexplicable weirdness.
For those who have scrolled until the last answer and still nothing worked, here is what did it for me after following all other answers advices. I am using Xcode 11:
What caused the issue in my case was that I changed my Product Name
I didn't know that changing the product name would also change the Product Module Name, that is the one used for the module import in my test files. I changed my import as follows:
@testable import New_Name
It worked
I hope it helps
I think this may have happened because I deleted the example tests.
I removed the Unit test bundle then re-added it as shown in the pictures below and all was well again.