Questions tagged [bridging-header]

Special header that facilitates cross-language developments between Swift, Objective-C, Objective C++, C and C++ on MacOS and iOS. Use exclusively cross-language development.

The bridging header is a special header in MacOS and iOS projects that aims at facilitating multi-language development by sharing definitions that are common between Swift and Objective C code.

In view of the (limited) interoperability between Objective-C and other programming languages, the bridging header also facilitates Objective-C++, C and C++ interoperability.

External references:

350 questions
128
votes
19 answers

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' In build settings I added header search path…
Nikita Semenov
  • 2,111
  • 4
  • 18
  • 31
108
votes
25 answers

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

I have a Swift project for which I'm trying to import ObjC-based frameworks. The framework is located in a directory under the project's path and is referenced by the project in Xcode. It's also added to the "Link Binary with Libraries" in the…
Dia Kharrat
  • 5,948
  • 3
  • 32
  • 43
83
votes
9 answers

Xcode not automatically creating bridging header?

I imported an Obj-C file into my swift project and Xcode automatically prompted me to create a bridging header file as expected. However, I deleted both the files (moved to trash) to make some changes, but when i try to import the Obj-C file once…
John Durand
  • 1,934
  • 5
  • 22
  • 34
66
votes
1 answer

Can I have Swift, Objective-C, C and C++ files in the same Xcode project?

Can all 4 languages be used in the same project at all, and if so how? There are similar questions in the flavor: Can I mix Swift with C++? Like the Objective - C .mm files to which the accepted answer is no. Using Bridging Header adequately, .h…
SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
47
votes
5 answers

Objective-C Bridging Header not getting created with Xcode 8

I am trying to add objective-c libraries to my Swift 3 project (Xcode 8 IDE). But objective c interface header is not getting generated automatically. I tried to add bridging header manually but showing linking error saying bridging header .h is not…
Augustine P A
  • 5,008
  • 3
  • 35
  • 39
47
votes
6 answers

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

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…
Andrew
  • 7,693
  • 11
  • 43
  • 81
29
votes
2 answers

Cocoapods 1.0: Header files not found

I just tried to update from cocoapods 0.39.x to Cocoapods 1.0. Running pod install from the terminal causes no warnings. Everything seems normal. However, when I try to build my project it outputs: AFNetworking/AFNetworking.h file not found My…
productioncoder
  • 4,225
  • 2
  • 39
  • 65
28
votes
5 answers

"Non-portable path to file "File.h"; specified path differs in case from file name on disk" warning in bridging header after updating to Xcode 8.3

I updated to Xcode 8.3 and Swift 3.1 and got this warning in my bridging header file, referencing to an Objective-C header file: Non-portable path to file "File.h"; specified path differs in case from file name on disk How can I resolve this?
Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
19
votes
2 answers

Objective-C Bridging Header for frameworks

I've made a framework that requires the sqlite3 framework. How do I add a Objective-C Bridging Header for my framework that imports sqlite3 into my Swift file? I already have a bridging header file for my project, but not for my framework.
Gustaf Rosenblad
  • 1,902
  • 2
  • 25
  • 45
17
votes
6 answers

Xcode 10 Failed to emit precompiled header for bridging header

Hi I'm getting a very annoying error on Xcode 10 that is 1 error generated. :0: error: failed to emit precompiled header…
Jaqueline
  • 465
  • 2
  • 8
  • 25
15
votes
1 answer

ReactNative Swift component: how to set the constructor

I have been working on a ReactNative project for a week now, and I want to make my own Objc/Swift native component. I followed the official documentation but I find it not that detailed. I can use a callback etc, and I also followed this, but I…
Anthony
  • 804
  • 3
  • 12
  • 32
12
votes
4 answers

Facebook SDK Swift - Use of undeclared identifier

I am getting Use of undeclared identifier for every Facebook Object I use Following this tutorial: TUTORIAL: HOW TO SHARE IN FACEBOOK SDK 4.1.X FOR SWIFT But I've got the following error: I've added Facebook framework via cocoapods: pod…
Luda
  • 7,282
  • 12
  • 79
  • 139
9
votes
1 answer

How to find path of Bridging-Header.h - Swift, Xcode

Here I'm attaching a screenshot of created header file I have created a new header file in xcode and named it as (projectname)-Bridging-Header.h. But I am not able to find the path and make it work. How to find the path of the file?
imjaydeep
  • 878
  • 1
  • 11
  • 34
8
votes
3 answers

Include an extension for a class only if iOS11 is available

I am trying to extend a class written in Obj-C and include an extension written in Swift that makes it conform to the UIDropInteractionDelegate, like so: @available(iOS 11.0, *) extension NoteEditViewController: UIDropInteractionDelegate { …
8
votes
3 answers

Existing target has no 'swift compiler code generation' section

I have an existing Objective-C iOS project and I want to add swift files to it. The project has 2 targets. I created the bridging header MyProject-Bridging-Header.h file and the automatically created bridging header MyProject-Swift.h is generated by…
brainray
  • 12,512
  • 11
  • 67
  • 116
1
2 3
23 24