[ios] Swift Bridging Header import issue

Following instructions, I've created a bridging header and added to my project. Unfortunately, the following error occurred:

:0: error: could not import Objective-C header '---path--to---header/....h'

Screenshot 1

In build settings I added header search path string to the location of bridging header, but nothing helped.

Has anyone experienced this problem?

The answer is


After initial few days of struggle, I finally managed to successfully integrate Facebook signup to my iOS app. Here are the steps(I am assuming you have already installed Facebook SDK v4.1 or above in your machines):

  1. Add the Facebook frameworks - FBSDKCoreKit,FBSDKLoginKit under your project.
  2. Make no changes in the Build settings as FB SDK v4.1 and above doesn't need anymore bridging header files.
  3. Import the FBSDKCorekit, FBSDKLoginKit in ViewController.swift, AppDelegate.swift files
  4. Add informations in the pList as mentioned here

  5. Build your app. And wohoo! no compile time errors.


For me it was because I forgot to add it to the Target's Build Settings.

enter image description here


Amongst the other fixes, I had the error come up when I tried to do Product->Archive. Turns out I had this :

Objective-C Bridging Header
  Debug (had the value)
  Release (had the value)
    Any architecture | Any SDK (this was blank - problem here!)

After setting it in that last line, it worked.


I have the same issue for different reason , here is my case I build project that needs slide menu to be included , I am using SWRevealViewController lib to approach that

when I import the library files I add sub-folder(SWRevealViewController) under Supporting Files for .h && .m files , it fire two errors , cant import bridge and SWRevealViewController.h is not found .

How I fix it

when I move files to Supporting Files directly (delete sub-folder) , SWRevealViewController.m automatically added to Build Phases --> Compile Sources and issue is gone

enter image description here


Add a temporary Objective-C file to your project. You may give it any name you like.

Select Yes to configure an Objective-C bridging header.

Delete the temporary Objective-C file you just created.

In the projectName-Bridging-Header.h file just created, add this line:

'#import < GoogleMaps/GoogleMaps.h >'

Edit the AppDelegate.swift file:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    GMSServices.provideAPIKey("AIza....") //iOS API key

    return true
}

Follow the link for full sample


I experienced that kind of error, when I was adding a Today Extension to my app. The build target for the extension was generated with the same name of bridging header as my app's build target. This was leading to the error, because the extension does not see the files listed in the bridging header of my app.

The only thing You need to to is delete or change the name of the bridging header for the extension and all will be fine.

Hope that this will help.


In my case this was actually an error as a result of a circular reference. I had a class imported in the bridging header, and that class' header file was importing the swift header (<MODULE_NAME>-Swift.h). I was doing this because in the Obj-C header file I needed to use a class that was declared in Swift, the solution was to simply use the @class declarative.

So basically the error said "Failed to import bridging header", the error above it said <MODULE_NAME>-Swift.h file not found, above that was an error pointing at a specific Obj-C Header file (namely a View Controller).

Inspecting this file I noticed that it had the -Swift.h declared inside the header. Moving this import to the implementation resolved the issue. So I needed to use an object, lets call it MyObject defined in Swift, so I simply changed the header to say

@class MyObject;

This will probably only affect a small percentage of people, but in my case my project was using CocoaPods and one of those pods had a sub spec with its own CocoaPods. The solution was to use full angle imports to reference any files in the sub-pods.

#import <HexColors/HexColor.h>

Rather than

#import "HexColor.h"

I imported in some files from bridgin header files from cocoapods not in a proper way.

Instead of importing

#import <SomeCocoaPod/SomeCocoaPod.h>

I wrote

#import "SomeCocoaPod.h"

And this was my HUGE mistake


Set Precompile Bridging Header to No fix the problem for me.


For me it was not selecting 'Copy items if needed' in destination path while adding the framework. Simply re-add the framework with this option selected.


"we need to tell Xcode where to look for the header files we’re listing in our bridging header. Find the Search Paths section, and change the project-level setting for User Header Search Paths, adding a recursive entry for the ‘Pods’ directory: Pods/** " http://swiftalicio.us/2014/11/using-cocoapods-from-swift/


I actually created an empty OSX Source Objective C file under the project (where all my swift files are).

I added the imports and then deleted the .m file.


for others who have troubles to add swift class into objective-c project. this is what work for me :

  1. create NEW swift file. this will make xcode to prompt if you want xcode to create all settings for mix swift-objective-c project including brigde-header.h for you. press yes.
  2. now, add your existing swift files you want to use in your project.
  3. in the implementation file you are going to use the swift class add : #import "YOURPROJECTNAME-swift.h" . this file xcode create for you. if your xcode project is myProject then "myProject-swift.h"

and that's it. now create the swift class in your code like it was objective-c.


For me deleting the derived data fixed it , I noticed even if I check out from an old commit, the same issue happens.

You can reach that option form Window-> Projects .


Had similar issue that could not be solved by any solution above. My project uses CocoaPods. I noticed that along with errors I got a warning with the following message:

Uncategorized: Target 'Pods' of project 'Pods' was rejected as an implicit dependency for 'Pods.framework' because its architectures 'arm64' didn't contain all required architectures 'armv7 arm64'

enter image description here

So solution was quite simple. For Pods project, change Build Active Architecture Only flag to No and original error went away.


I've also experienced this problem and sadly it is just a bug in the SDK + Xcode. I talked to an engineer at WWDC, about this and a few other problems I was having with CloudKit. These bugs will be addressed in the next seed of Xcode.

It's the fun part about using beta software.


Find the path at:

Build Settings/Swift Compiler-Code Generation/Objective-C Bridging Header

and delete that file. Then you should be ok.


Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to swift

Make a VStack fill the width of the screen in SwiftUI Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code in Xcode 10 Convert Json string to Json object in Swift 4 iOS Swift - Get the Current Local Time and Date Timestamp Xcode 9 Swift Language Version (SWIFT_VERSION) How do I use Safe Area Layout programmatically? How can I use String substring in Swift 4? 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator Safe Area of Xcode 9 The use of Swift 3 @objc inference in Swift 4 mode is deprecated?

Examples related to xcode6

'Framework not found' in Xcode No suitable records were found verify your bundle identifier is correct unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard Move a view up only when the keyboard covers an input field My prerelease app has been "processing" for over a week in iTunes Connect, what gives? Programmatically navigate to another view controller/scene Changing the Status Bar Color for specific ViewControllers using Swift in iOS8 Change tab bar item selected color in a storyboard How do I change UIView Size? How to get textLabel of selected row in swift?

Examples related to bridging-header

Getting "file not found" in Bridging Header when importing Objective-C frameworks into Swift project Swift Bridging Header import issue

Examples related to objective-c-swift-bridge

Swift Bridging Header import issue