Purpose and setup of an Objective-C bridging header
WHAT IT TESTS: mixed-language project setup. OUTLINE: the bridging header imports ObjC headers into Swift; Xcode auto-creates it or you add it manually and set the build setting. RED FLAG: confusing it with the generated Swift-to-ObjC header.
WHAT IT TESTS: comfort wiring Objective-C and Swift together in one target. ANSWER OUTLINE: a bridging header is a single header where you #import the Objective-C headers you want visible to Swift; Xcode offers to create it when you add a mixed file and wires the Objective-C Bridging Header build setting to its path; the symbols then become available without manual import. RED FLAG: confusing it with the compiler-generated ModuleName-Swift.h that goes the other direction, or thinking each ObjC class needs its own bridging header.
Read the original → interview
- #ios
- #swift
- #objective-c
- #interop
- #xcode
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.