Test bundle could not be loaded because an unantic

2020-02-26 03:48发布

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.

10条回答
Evening l夕情丶
2楼-- · 2020-02-26 04:25

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.

查看更多
The star\"
3楼-- · 2020-02-26 04:26

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

查看更多
太酷不给撩
4楼-- · 2020-02-26 04:36

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.

查看更多
我想做一个坏孩纸
5楼-- · 2020-02-26 04:38

Check if you forgot to add your test target in your Podfile:

target 'MyProject' do

  # Add test target
  target 'MyProjectTests' do
    inherit! :search_paths
  end

  pod 'SomePodLibrary'

end
查看更多
Rolldiameter
6楼-- · 2020-02-26 04:40

The bundle UITests couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle

Verify if all your targets are using the same iOS version in: Build Settings -> iOS Deployment Target

查看更多
Deceive 欺骗
7楼-- · 2020-02-26 04:42

For me, we had just turned on CloudKit entitlement. For some reason that broke building.

查看更多
登录 后发表回答