0

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?

Sachin Dobariya
  • 744
  • 7
  • 16

3 Answers3

2

You can add bridging these steps.

Select Target -> Build Settings -> Objective-C Bridging Header -> fill the specified field.

1

Please follow the steps below to add Swift Bridging Header in your project,

  1. Add a new file to Xcode (File > New > File), and select Source and choose Header File
  2. Create your file ProjectName-Bridging-Header.h
  3. In Build Settings, Next to Objective-C Bridging Header you need to add the path of your header file. i.e ProjectName/ProjectName-Bridging-Header.h or ProjectName-Bridging-Header.h.
  4. 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