iOS Bridging Header Setup for React Native
Source: Dev.to
Setting Up the Bridging Header
-
Create the bridging header file
- Right‑click on your project folder in Xcode.
- Choose New File → Header File.
- Name it
YourAppName-Bridging-Header.h. - Select all targets (main app, development, production) and click Create.
-
Configure the bridging header path
For each target:- Open Build Settings.
- Search for “Objective‑C Bridging Header”.
- Set the path to
YourAppName/YourAppName-Bridging-Header.h.
Importing Objective‑C Headers
Open YourAppName-Bridging-Header.h and add the required imports, for example:
// React Native Config
#import "RNCConfig.h"
// Google Maps
#import
// Your custom modules
#import "CustomNativeModule.h"
Example AppDelegate.swift
import UIKit
import Firebase // Make sure Firebase is imported if used
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Access environment variables via React Native Config
if let apiKey = RNCConfig.env(for: "API_KEY") {
GMSServices.provideAPIKey(apiKey)
}
// Initialize Firebase
FirebaseApp.configure()
return true
}
}
Cleaning, Building, and Running
- Clean:
Cmd + Shift + K - Build:
Cmd + B - Run:
Cmd + R
Project Structure Overview
YourAppName/
├── ios/
│ ├── YourAppName/
│ │ ├── AppDelegate.swift
│ │ ├── YourAppName-Bridging-Header.h ✅
│ │ └── Info.plist
│ └── Pods/
└── package.json