How to fix @testable import failed to load module in xcode unit testing

风流意气都作罢 提交于 2020-12-05 08:29:04

问题


I had created an Xcode project without unit testing. I have added cocoa pods when I try to create a new unit testing and try to import @testable import 'ProjectName' it gives an error Failed to load module 'ProjectName'. can u please help me out to solve the problem

@testable import 'ProjectName' Failed to load module


回答1:


Update Podfile like this and check

target 'App' do
  pod 'Alamofire'

  target 'Demo AppTests' do
    inherit! :search_paths

  end

  target 'Demo AppUITests' do
    inherit! :search_paths

  end  
end



回答2:


If your problem is not solved after trying @Naveen's answer and you have Obj-c bridging-header in your main target, you should create another briding-header with the same values for your tests.



来源:https://stackoverflow.com/questions/56163189/how-to-fix-testable-import-failed-to-load-module-in-xcode-unit-testing

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