Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bridging Header for Swift Pod with dependent Objective-C Pod?

I created a Swift pod (podspec) which depends on a pod written in Objective-C. In my podspec I use:

s.dependency 'ObjectiveCPod', '~>3.2.1'

To specify the dependent pod. To use it I need a bridging header being installed automatically when my Swift pod is installed. I do not want to create a bridging header in my project myself to integrate the objective-c pods header files.

How can I configure my podspec such that a bridging header file is automatically integrated and linked in my project when I install my Swift pod?

like image 267
confile Avatar asked Oct 31 '22 03:10

confile


1 Answers

CocoaPods generates an umbrella header for the framework created for your Swift pod. This imports all public headers defined in the podspec. Everything, which is transitively imported from your umbrella header, is available in the Clang module of your framework. So just add a header to your project, which imports whatever is needed from your Objective-C dependency and declare it as public header in your podspec.

If you have a project to build and test your pod, you still want to import that header in the default umbrella header, which has by default the same name as your framework and is part of the template from Xcode.

Alternatively, you should be able to import the Objective-C dependency by using @import ObjectiveCPod from Swift.

like image 137
marius Avatar answered Nov 11 '22 23:11

marius