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
8
votes
6 answers

What is the use of bridging header? Should we avoid using bridging header?

What is the use of bridging header? Is it just for using Objective-C and Swift code in the same project? Should we avoid using bridging header? Say, if there are two third party library which are very similar; one of them is in Objective-C and…
Ankur Arya
  • 4,693
  • 5
  • 29
  • 50
8
votes
1 answer

ATLAddressBarViewController.h not found in Atlas.h

I am trying to run https://github.com/kwkhaw/quick-start-ios-swift this project. But facing this error while compiling the code.
Nishant Dongare
  • 549
  • 3
  • 16
8
votes
5 answers

Why additional #import in bridging header failed in swift?

Before I added a new dependency to my test project via CocoaPods, I have already added a C header file ('wahoo.h') and exposed it to the swift code via a bridging header file "wahoo-Bridging-Header.h". The test app could be compiled and run without…
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
7
votes
1 answer

Exclude Swift Class from Bridging Header

In a Swift project that has mixed Obj-C and C++, I have a class that extends the class belonging to a 3rd party framework. When I compile the project, the compiler complains that it Cannot find interface declaration for '',…
bleeckerj
  • 554
  • 7
  • 18
7
votes
1 answer

iOS mixed dynamic framework - bridge objc headers with private module

In regards to a "dynamic framework" target, I need to bridge internal (private) objective-c headers to my swift counterparts. From my understanding I need to use a private module. Some of these swift counterparts are bridged back to objective-c…
Avba
  • 14,822
  • 20
  • 92
  • 192
7
votes
2 answers

Swift Bridging Header and visibility of Obj-C class

I've aded bridging header, specified in build settings the full path to it, bridging header was created automatically. After this, i've included my obj-c header files in it. But every attempt of calling constructor of object fails : "Use of…
Nikita Semenov
  • 2,111
  • 4
  • 18
  • 31
6
votes
0 answers

C-style struct in Objc not importing to Swift

The problem I'm encountering, and absolutely not understanding, is why can my Swift code not access an bridged C-style struct import from objective-c when a NSString pointer is contained, whereas the struct is visible when then NSString is replaced…
MQLN
  • 2,292
  • 2
  • 18
  • 33
6
votes
2 answers

Could not build Objective-C module, when using swift in objective-c module

In an iOS application I have a subproject (not cocoapods) in which I have included a swift file and ObjC file (that is used by the swift file). XCode automatically created a bridging file but could not build it because apparantly bridging is not…
user426132
  • 1,341
  • 4
  • 13
  • 28
6
votes
1 answer

ProjectName-Swift.h Not Found / Generated Xcode 10

Running my project in Xcode 10 throws me this error fatal error: 'Stories-Swift.h' file not found I've tried multiple things including: Adding a new swift file to the project and rebuilding it Setting Defines Modules to Yes Double checking my…
6
votes
2 answers

Swift classes not found in Objective-C project

I am working on an iOS project developed using Objective-C. I need to integrate some Swift files in it. So, did following: Added a new Swift file named "temp", so that MyProject-Bridging-Header.h is added by my Xcode IDE (Version 9.1). Added the…
Harish J
  • 525
  • 1
  • 4
  • 16
6
votes
2 answers

Expected a type & Failed to import bridging header

I'm working on a project that contains Swift and Objective_C code, it works without any problem until i was trying to import a ".h" class in my "Bridging-Header" file: Expected a type : in the class that i was trying to import it Failed to import…
khouloud
  • 107
  • 11
6
votes
2 answers

How to import objective c header file in swift project

enter image description here I am trying to use SDWebImage in a Swift project. I dragged and dropped the SDWebImage library folder into my Swift project and created a bridging header by name listingApp-Bridging-Header.h Then I imported the header…
virat
  • 117
  • 1
  • 1
  • 7
6
votes
2 answers

Swift Bridging Header - New Target

I have an objective-c project with one class implemented in Swift. The project has with two targets: A and B. For both of them the Xcode created the bridging header files, A-Swift.h and B-Swift.h, and the app builds and runs both targets without any…
jaumevn
  • 439
  • 1
  • 5
  • 14
6
votes
1 answer

Errors after importing Obj-C files through bridging header

I am trying to import this project into my swift project. What I have done is add the PanoromaView.h and PanoromaView.m files, and added #import "PanoramaView.h" to my bridging header. I have also added the OpenGLES.framework and GLKit.Framework to…
Henry Brown
  • 2,219
  • 8
  • 31
  • 48
6
votes
2 answers

Using An Objective-C Function that Returns an Optional or Throw in Swift

I'm working on a swift project that need to interact with an existing objective-c api. I've run into a bit of a roadblock with one of the functions though. In the objective-c header file (OrderItem.h) I have this function definition: + (NSString…
pbuchheit
  • 1,371
  • 1
  • 20
  • 47
1
2
3
23 24