I have created two targets of my application i.e Dev and Prod. How can I add bridging header to it for both the version? Is one bridging header is works for both or I have to create two for different targets?
Asked
Active
Viewed 1,118 times
3 Answers
2
You can add bridging these steps.
Select Target -> Build Settings -> Objective-C Bridging Header -> fill the specified field.

Halil İbrahim YILMAZ
- 720
- 1
- 7
- 20
-
means I have to add two bridging headers for both the targets? – Sachin Dobariya Dec 25 '18 at 12:01
-
Yes, you should add both target. – Halil İbrahim YILMAZ Dec 25 '18 at 12:02
1
Please follow the steps below to add Swift Bridging Header
in your project,
- Add a new file to Xcode
(File > New > File)
, and selectSource
and chooseHeader File
- Create your file
ProjectName-Bridging-Header.h
- In
Build Settings
, Next toObjective-C Bridging Header
you need to add the path of your header file. i.eProjectName/ProjectName-Bridging-Header.h
orProjectName-Bridging-Header.h
. - Import your Objective-C classes using
#import <Class Name>

Bappaditya
- 9,494
- 3
- 20
- 29
1
In Swift you can use the "#if/#else/#endif" in Bridging Header file.
#if DEBUG
#import "devVersion.h"
#else
#import "prodVersion.h"
#endif
"Now, you must set the "DEBUG" symbol elsewhere, though. Set it in the "Swift Compiler - Custom Flags" section, "Other Swift Flags" line. You add the DEBUG symbol with the -D DEBUG entry. As usual, you can set a different value when in Debug or when in Release."
Ref: https://stackoverflow.com/a/24152730/3089616
Hope this help!

Rurouni
- 963
- 10
- 31