Chapter    19

Mix and Match

Whether you’ve decided to start a new project that uses Swift, or want to update an existing Objective-C project to use Swift, you’ll end up needing both languages in your projects. Apple calls this feature mix and match, where code written in either language can co-exist and work with the other.

Xcode has made the process of working in a mix-and-match environment quite easy. You simply create the files you need and Xcode will prompt you with the appropriate actions to take.

You start with couple of important header files. The first is the bridging header where you define the Objective-C API you need to expose to Swift source files. And the other is the reverse bridging header, which the compiler generates and will ...

Get Learn Swift on the Mac: For OS X and iOS now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.