There are, mainly, three different approaches to create and use an Objective-C bridging header:
1. Using the Advanced Project Converter
When trying to convert the first Objective-C file in your project to Swift using the Advanced Project Converter, it will first prompt you to create a bridging header before actually doing the conversion. By clicking Yes on the prompt, the converter would then proceed to create the file as well as maintaining its content with the following:
-
A copy of all imports found in the Precompiled Header file
-
All internal (non-framework) imports from all Objective-C file(s) in the project
Files converted to Swift are automatically removed from the bridging header.
2. Using Xcode
When trying to add a .swift file to an Objective-C project for the first time through Xcode, it will prompt you to create a bridging header for you, however, this time you’ll need to manage its content on your own.
3. Doing it manually
If both these options are not suitable for you, you can still manually create the bridging header but then you’ll need to tell Xcode what this file is called so it can use it. This Stack Overflow answer explains how to do so.
Comments
0 comments
Please sign in to leave a comment.