Added unit testing target to Xcode - failed to import bridging header won't go away Added unit testing target to Xcode - failed to import bridging header won't go away xcode xcode

Added unit testing target to Xcode - failed to import bridging header won't go away


If you use CocoaPods as package manager, must set search path etc. Give a simple way,

Try adding this in your Podfile:

target 'YourProductTests' do    inherit! :search_paths    # Pods for testingend

and pod install

It works for me.

If the above solution does not work for you, try setting manually:

  1. Click your Test target -> Build Setting-> tab: All & Combined -> Swift Compiler -Code Generation -> Objective-C Bridging Header : add your xxx-bridging-header

  2. Check "Search Path", set up value of Framework Search Path, Header Search Paths, Library Search Path according to your main target. Maybe some search path lose here, manually add again.


@Victor Choy solution works for me, but I had to move test target inside product target like so:

target 'YourProduct' do   # Pods for product   target 'YourProductTests' do      inherit! :search_paths      # Pods for product testing   endend

This did not work for me:

target 'YourProduct' do   # Pods for productendtarget 'YourProductTests' do   inherit! :search_paths   # Pods for product testingend


I faced the same problem. I did the following and the issue of 'Failed to import bridging header' is solved.

Steps:

  1. Select your project -> Build settings -> Search for 'Defines module' -> give 'YES'
  2. Copy Objective-C bridging header path
  3. Select your test target -> Build setting -> Swift compiler - General -> Objective-C bridging header -> Give Bridging header path.
  4. Make sure 'Header Search Paths' of test targets contains all the headers in ios Targets. Add them if any of the headers are missing.
  5. Build.

Reference: Refer this link.