Test bundle could not be loaded because an unanticipated error
I was able to resolve this issue by setting the host application for the test target:
I had a similar problem. For me, the problem was a unit testing framework that was a dynamic framework but not copied over to the xctest bundle.
The solution was to add a "Copy Files" phase to my unit test target, set its destination to "Frameworks" and add my framework as an input file.
If other readers are getting this error, and you're using Carthage to add a framework, ensure the Copy Files
phase is with Destination: Frameworks.
If you accidentally add the frameworks to a Copy Files
phase with a different target (other than Frameworks), or Copy Bundle Resources
, this will also produce the damaged / invalid bundle error message.
I found the answer by myself.
Your Build Settings -> Architectures should be same for Library and Test Project
Architectures -> Architectures = Standrad Architectures (armv7 ,armv7s , arm64)$(ARCHS_STANDARD)
Your Test Project's Linking -> Mach-O Type should be Bundle
Linking -> Mach-O Type = Bundle
Do Build and Run Tests. Thats it