Applies to:
- Xcode Extension
- Finder Extension
- Advanced Project Converter
- Offline Converter
Included in plans:
- Cloud
- Offline Converter
The Advanced Project Converter automatically generates Objective-C bridging header and PCH files so that you can use Objective-C code from Swift and vice versa.
These bridging header file(s) are generated when you take any of these actions in the Advanced Project Converter:
- Open a project and confirm the prompt to generate bridging header files
- Press the "Configure Bridging Header" toolbar button to generate bridging header files at a later time
The Objective-C bridging header file is automatically added to your project, and updated while you gradually convert your project to Swift.
When you open your bridging header file (`ProjectName-Bridging-Header.h`), you will find a section that is automatically inserted and updated by Swiftify:
// -----------------------------------------------------------------------------
// Begin Swiftify generated imports
//
// #import <Foundation/Foundation.h>
// #import <UIKit/UIKit.h>
//
// End Swiftify generated imports
// -----------------------------------------------------------------------------
This section collects imports from all Objective-C source files and the PCH (precompiled header) file and excludes any imports for files already converted to Swift (so, if you convert MyViewController class to Swift, the corresponding import will be automatically deleted from this section).
If you need to import any other custom files, add your custom imports outside the section managed by Swiftify.
Swiftify imports the Swift bridging header file (ProjectName-Swift.h
) from the PCH (precompiled header) file, which is automatically created or updated by our app. Refer to the following article which describes this approach (that eliminates the need to import the Swift bridging header from every Objective-C .m file that depends on Swift code).
The Swift bridging header file is automatically created by Xcode (rather than Swiftify), only if your project compiles successfully and contains at least one Objective-C and one Swift file.
Since the Swift bridging header file cannot be imported from header (.h) files (due to circular referencing issues), Swiftify automatically generates forward @class declarations for header files that depend on Swift code.
To disable updating the Bridging Header and PCH files, you can uncheck the option under Preferences (⌘+,) => Converter and toggle the corresponding checkbox:
Comments
0 comments
Please sign in to leave a comment.