Unit test target added to xcode - import of import header has not disappeared

I added a new Test target to my XCode project. My project has Swift code and Objective-C code, and has a bridging header. Upon either adding the bridging header to UnitTesting's build settings, or doing import MyTarget , I'm getting the error:

failed to import bridging header

I've tried:

  • Adding the bridging header to project, unit testing and main target's build settings.
  • Changing defines modules to Yes .
  • Moving the bridging header file to the root folder.

I've also tried making a sample project, which built and worked fine. Taking everything I have over into a clean new project isn't an option at this point.

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

try add this in Podfile

target 'YourProductTests' do
    inherit! :search_paths
    # Pods for testing
end

and pod install

It works for me.

If the above solution does not for you. Try set manually

  1. Click your Test target -> Build Setting-> tab: All & Combined -> Swift Compiler -Code Genration -> 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.

我来评几句
登录后评论

已发表评论数()

相关站点

+订阅
热门文章