Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 340
Shoaib Pathan Avatar asked May 16 '19 07:05

Shoaib Pathan


2 Answers

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
like image 135
Naveen Kommuri Avatar answered Nov 18 '22 21:11

Naveen Kommuri


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.

like image 42
ysnzlcn Avatar answered Nov 18 '22 22:11

ysnzlcn