Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ios

swift4

xcode9

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.

like image 764
Varun Mehta Avatar asked Jul 24 '17 07:07

Varun Mehta


1 Answers

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 :)

like image 64
Tino Krželj Avatar answered Sep 18 '22 08:09

Tino Krželj