
Try to compile the project, and fix any conversion errors.m files from the project, and add the converted. swift file and use the “Convert File to Swift” command in the Swiftify Xcode Extension. The Finder extension included in Swiftify for Xcode is the easiest way to do that. Convert the pair of Objective-C files to Swift.

This helps to avoid circular references between header files. h files: Replace #import “MyViewController.h“ with a forward class declaration: MyViewController. m files: Replace instances of #import “MyViewController.h“ with #import “-Swift.h“ to import your Swift umbrella header instead. Remove #import “MyViewController.h” from the Obj-C Bridging Header File (-Bridging-Header.h).Search for #import “MyViewController.h” through your whole project.If your goal is to convert the entire project to Swift, leave the AppDelegate class for last. MyViewController.h and MyViewController.m).
#OBJC TO SWIFT CONVERTER CODE#
There may be pieces of code that you want to leave in Objective-C, and there’s nothing wrong with that.įor more information, please take a look at our post, Should I Convert Everything to Swift?. To use the modern Objective-C converter, choose Edit → Refactor → Convert to Modern Objective-C Syntax.ĭon’t feel obligated to convert all your code to Swift. Make sure to manually review and confirm any changes the converter offers to make to your code. For example, it won’t detect that your -toggle method is an action that affects your object’s state, and it will erroneously offer to modernize this action to make it a property.

Migration provides an opportunity to revisit an existing Objective-C app and improve its architecture, logic, and performance by replacing pieces of it with Swift. Migrating Your Objective-C Project to Swift
