Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference header files in Bridging-Header.h after updating CocoaPods to 0.36.x and above?

After updating to CocoaPods 0.36.x, I am unable to add imports into my Bridging-Header.h file. I get the "DBSphereView.h file not found".

The file is indeed present in:

"Pods/DBSphereTagCloud/DBSphereView.h" "Headers/public/DBSphereTagCloud/DBSphereView.h" "Headers/private/DBSphereTagCloud/DBSphereView.h" 

My bridge file:

#ifndef Loan_Bridging_Header_h #define Loan_Bridging_Header_h #import "DBSphereView.h" #endif 

I am able to use Frameworks. I have a reference to a well known Framework (Alamofire), and it works great!

My podfile:

source 'https://github.com/CocoaPods/Specs.git' use_frameworks! pod 'DBSphereTagCloud', '~> 1.0' pod 'Alamofire', '~> 1.1' 

Before updating, I had no problems with importing header files.

How do I reference header files in Bridging-Header.h after updating CocoaPods to 0.36.x?

Thank you!

EDIT:

I also tried to create a separate project based on the example "Get Started" from cocoapods.org, without success. After using Frameworks, I can't seem to reference header files in my bridging header file. I must be missing some detail?

like image 244
nmdias Avatar asked Mar 16 '15 14:03

nmdias


People also ask

How do you make a bridging header H?

To create an Objective-C bridging header file, all you need to do is drag some Objective-C code into your Swift project – Xcode should prompt you with the message "Would you like to configure an Objective-C bridging header?" Click "Creating Bridging Header" and you'll see a file called YourProjectName-Bridging-Header.

How do you add Objective-C bridging header file and configure it manually?

Alternatively, you can create a bridging header yourself by choosing File > New > File > [operating system] > Source > Header File. Edit the bridging header to expose your Objective-C code to your Swift code: In your Objective-C bridging header, import every Objective-C header you want to expose to Swift.


2 Answers

In your Podfile, you specified use_frameworks!.

As a result, the Objective-C code you're including as a dependency (DBSphereTagCloud) is packaged as a framework, instead of a static library. Please see CocoaPods 0.36 - Framework and Swift Support for more details.

As a consequence, you don't need a bridging header file. It's enough for you to add:

import DBSphereTagCloud 

in all the Swift files that need that module.

like image 153
Para Avatar answered Sep 18 '22 13:09

Para


I had problems with this. My bridging header wasn't finding pod libs. I ended up finding out that I have to do this.

enter image description here

like image 35
villy393 Avatar answered Sep 20 '22 13:09

villy393