While the accepted answer solves this problem for majority of times, there is one more way you can come across this error.
If you have already ensured that:
As pointed out by @pwc @nick-n and others
- The
ClassTest.swift
file for target membership by ensuring that it is only attached to the Testing target.
- The
ClassTest.swift
is not visible under you main app target > Build Sources > Compile Sources
Here is what else you can check:
in your .podspecs
file
Ensure that your source_files
does not directly or indirectly includes the testing directory.
for example :
s.source_files = ["Classes/**/*.{swift}", "Classes/**/*.{xib}"]
s.exclude_files = ["Classes/Exclude", "Classes/MyPodProjTests/"]
Note that Classes/**/*.{swift}
includes everything overriding the fact that the directory MyPodProjTests
must be excluded.
Solution:
s.source_files = ["Classes/MyPodProj/**/*.{swift}", "Classes/**/*.{xib}"]
Note:
This is extremely edge case and completely human error but I thought it will be worth pointing out.