Test bundle could not be loaded because an unanticipated error

大兔子大兔子 提交于 2019-11-30 08:22:04

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 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.

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

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

For me this issue was due to the "iOS Deployment Target" Build Setting being different in my test target than my main app. Once I made them the same the problem went away.

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

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

Turning off the pod configuration for the test target fixed the problem for me, it had something to do with the pod configuration messing with it.

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

Had a similar issue:

FrameworkA imports FrameworkB

FrameworkA-Tests also imports FrameworkB

What solved the issue was to remove(comment) all references to FrameworkB in FrameworkA-Tests, then Run Tests once and uncomment the references.

FrameworkA-Tests now imports FrameworkB and runs fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!