Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test bundle could not be loaded because an unanticipated error

Recently I have started writing test case for one old static library. I have loaded the library to Xcode 5,Since Static Library is old , I have to manually add TestProject with Test Target.

When I am trying "Product-->Test" , It launches emulator and Console shows following error

The test bundle at /xxx/xxx/xxx/StaticLibTest.xctest could not be
loaded because an unanticipated error occurred: Error
Domain=NSCocoaErrorDomain Code=3587 "The bundle “StaticLibTest.xctest”
couldn’t be loaded because it is damaged or missing necessary
resources."
(dlopen_preflight(/xxx/xxxx/xxx/Debug-iphonesimulator/StaticLibTest.xctest/StaticLibTests):
no suitable image found.  Did find:

I don't have any clue why this error comes.

Any help for pointing out to the right direction will be really appreciated.

like image 977
Brijesh Thakur Avatar asked Aug 01 '14 11:08

Brijesh Thakur


3 Answers

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.

Adding frameworks from Carthage

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.

like image 102
odlp Avatar answered Nov 19 '22 07:11

odlp


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.

like image 25
Lukas Spieß Avatar answered Nov 19 '22 08:11

Lukas Spieß


I was able to resolve this issue by setting the host application for the test target: Host Application

like image 21
Menno Avatar answered Nov 19 '22 07:11

Menno