Migration to Swift 4 from Swift 3.2 giving "failed to import bridging header " error

Varun Mehta picture Varun Mehta · Jul 24, 2017 · Viewed 14.4k times · Source

As apple has released Xcode 9 beta version with Swift 4.0 support. I have been trying to upgrade my code to Swift 4.0 from Swift 3.2. But it keeps giving me failed to import bridging header error whereas my project build successfully.

Xcode error detail:

Convert to Current Swift Syntax Failed

Please ensure that all selected targets build successfully with the currently configured Swift version before attempting a migration.

Has anybody faced the similar error while upgrading code base to swift 4.

Answer

Tino Krželj picture Tino Krželj · Jul 26, 2017

I had the similar problem in one of my projects and how I solved this is next:

I figured out that CocoaPods are the problem.

  1. I removed CocoaPods from my project (if you don't know how to do that check this How to remove CocoaPods from a project?)

  2. Don't forget If you have unit & ui tests you have to repeat 4th step from the link above on them as well.

  3. Upgrade your code base to Swift 4

  4. Install pods again and you are done.

Hope it helps :)