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
4
votes
2 answers

swift compiler error "found this candidate" after adding objective c files in Swift

I have created bridging header in my swift project, for use of objective c files. whenever I import the objective c files in my project, then my swift files showing error. I have tried all solutions available on stack overflow bt not working. same…
4
votes
2 answers

Can/Should I have more than one Objective-C bridging header?

I'm attempting to implement some new Siri integrations into my app. I have an old Objective-C header that I've been using on my project as a whole, but now this new Siri Intents target also needs a header. So now I have two objective-c bridging…
LuKenneth
  • 2,197
  • 2
  • 18
  • 41
4
votes
1 answer

Adding Objective C framework inside Swift Framework

I am writing a Cocoa Framework for iOS in Swift language. I need to add a third party framework (written in Objective-C) inside this framework. I have added headers to the bridging file. But when i build the project i get the following error: "using…
sachin.j
  • 125
  • 1
  • 6
4
votes
1 answer

Use Objective-C code in Swift project which uses Swift code at the same time

I have a Swift project in which I'm using an Objective-C class. I've done this by importing the .h file inside my bridging header. Everything works fine. Now I need to use a Swift class inside this Objective-C code, so I imported the…
Mike Nathas
  • 1,247
  • 2
  • 11
  • 29
4
votes
1 answer

Include C++ header file in Swift

I have a C++ header file (named header.h) which I want to include into my Swift project. Since the C++ framework I want to include is not finished yet I just have the header file for now. My C++ header file header.h looks a little like…
ferdyyy
  • 515
  • 4
  • 16
4
votes
1 answer

Can't access objective-c method from swift. Bridge setup, and obj-c class instantiates

This is my first IOS application and all has gone well up to this point. My code is in Swift and I need to use the Gold Raccoon FTP library, which is in Obj-C, in my application: https://github.com/albertodebortoli/GoldRaccoon I imported the Gold…
DannyP
  • 200
  • 2
  • 10
4
votes
2 answers

“file not found” in Bridging Header when importing Objective-C frameworks into Swift project by CocoaPod

I got a swift project ,and use CocoaPod to import the third part repositories. In pod file I use use_frameworks!, so the repositories will build into framework to use. And I import the ObjC framework like #import "" or #import <> in my Bridging…
childrenOurFuture
  • 1,889
  • 2
  • 14
  • 23
4
votes
0 answers

Swift Bridging Header not finding classes

I have some Objective-C files that are imported into a swift bridging header. Some files that I added a while ago are working perfectly but I added some more files today and in Swift code none of the classes in the new files are found at all, as in…
jacobsieradzki
  • 1,108
  • 2
  • 10
  • 32
4
votes
1 answer

Include Pod's Bridging-Header to Build Settings of Project's Target?

I created an objective-c pod with two files: Source/SomeViewController.h Source/SomeViewController.m I also created a bridging header in the pod: Source/Bridging-Header.h with the content: #import "SomeViewController.h" My podspec looks like…
user4788711
3
votes
0 answers

How to temporarily disable Swift to Objective-C bridging header auto-generation?

Background Let's say project App is a 50/50 mixed Swift/Objective-C codebase. Objective-C files import some Swift via auto-generated "App-Swift.h" file. #import "App-Swift.h" Recap on How it Works "App-Swift.h" file automatically includes all the…
tar500
  • 171
  • 2
  • 8
3
votes
1 answer

Can't include C-files in Swift-package with Xcode 11 package manager

I created a Swift 5.1 app with Xcode 11.0 which contains c-files and h-files. A bridging header was automatically generated by Xcode. I entered the necessary #imports. The project compiles and runs as expected. Now I wanted to create a Swift-package…
Heinz M.
  • 668
  • 3
  • 8
3
votes
1 answer

Why internal classes appear in ProductName-Swift.h? May I change this file manually?

I build Swift framework that is dependent on another Objective C framework (so, the project contains bridging header file). When I open auto-generated ProductName-Swift.h file inside my framework's headers I see that classes that I would not like to…
Boris
  • 404
  • 1
  • 7
  • 20
3
votes
2 answers

failed to emit precompiled header

Good Afternoon I am trying to implement googles heatmaps into my map based project. In this particular project, I get the following errors when trying to build. failed to emit precompiled header…
3
votes
1 answer

Not able to use objective-C class in swift unit tests

I want to use objective C class in my swift tests. My project is initially set up in objective c. I have bridging header set up already working for my project. I have import statement already in place in bridging header for the file, which I want…
pk75
  • 511
  • 7
  • 18
3
votes
1 answer

Use of undeclared identifier when I want use swift file in objective c project

when I want use swift file in objective c project and I declare an object from swift class, I get "Use of undeclared identifier" error. the way that I pass: coping swift file in project and type @objc before declare swift class create header file…