Converting your Project to Swift with Swiftify’s Advanced Project Converter
Swiftify provides multiple options for converting Objective-C to Swift, but the new Advanced Project Converter (included in Swiftify for Xcode) is the easiest. The Advanced Project Converter lets you convert individual files, groups of files, or entire projects with a desktop UI that is easy to use.
The Advanced Project Converter is a desktop application that handles more than just converting blocks of code. You can:
- Explore your entire project like in Xcode;
- Select groups of files to convert;
- Automatically add newly generated Swift files to the project file;
- Automatically generate the Objective-C bridging header.
The Advanced Project Converter comes bundled with Swiftify for Xcode. You can download it here.
Note that the Advanced Project Converter only works on the Swiftify Unlimited plan. You can see the different plan options for Swiftify here.
To start, you’ll need to enter an API Key. You can get yours from the Swiftify Apps page. Your API Key will give you access to all the features of your plan.
Next, choose Open Project Folder. In the file dialog, navigate to your chosen project and select Open.
You’ll be presented with a view of your entire project, much like that of an IDE.
Everything here works at the project level rather than the file level. This means that converting a class will modify the project file as well.
Converting Objective-C Classes to Swift
The Advanced Project Converter lets you easily convert multiple classes and automatically integrate them back into the project. Converting groups of related classes at the same time lets you avoid breaking references between them. You don’t have to worry about Objective-C code incorrectly referencing classes that have been converted because you can convert those classes at the same time.
In our example project, the NetworkingService and ViewController classes are used together, so we’ll convert them at the same time. Select the checkbox to the left of either
ViewController.m, and then the checkbox to the left of either
Hit the Convert button (the “Play” triangle) at the top left to start the conversion. When it’s finished, your project should look like this:
In the left pane, you can see the newly created
NetworkingService.swift. The old Objective-C classes are still there for you to delete at your own discretion. When you’re ready to delete the Objective-C class, just right-click on it and choose Move To Trash.
In the right pane, you can see the new Swift class and make any tweaks that are necessary.
The project file has also been updated to remove the Objective-C classes that you converted and to include the new Swift equivalents.
The full conversion process is shown here:
Build the Project
To open the project in Xcode, just double-click the project file (alternatively, right-click on the project file and choose Open in Xcode).
You can follow the tips from our Migrating Your Objective-C Project to Swift post to guide you in updating all of the references to your converted classes. When you’re ready, build the project in Xcode.
Finishing the Conversion
Now that the project is compiling correctly with your newly converted Swift code, you can repeat the process by switching back to the Advanced Project Converter, converting more classes, and testing the project again.
An Effortless Conversion Tool
Using the Advanced Project Converter to work at the project level streamlines the process of converting Objective-C to Swift. It’s easy to get a birds-eye view of your whole project and to convert many files at once.
For more guidance, read our post on migrating from Objective-C to Swift, and please share your questions in the comments below.