Apple releases Swift since WWDC 2014, a whole new language to replace Objective-C, and they did a lot of work to make the transition as seamless as possible. It’s so good that you can use both languages in the same project.
Now, lets see how easy is to use Swift in an existing Objective-C project:
1. Open up your existing Objective-C project
If you don’t have one, feel free to create a new one and follow on. We’ll name it “ObjectiveSpring” here.
2. Drag and Drop your .swift files into the project
If it ask do you wanted to add a bridging header, unless you plan to write Swift code to use your Objective-C classes, you can click NO for now.
If you don’t have a decent Swift framework, scroll to the bottom ;D
3. Using Swift classes in Interface Builder
Xcode automatically scans all .swift files you added in the project, so you can use a Swift UI component in Interface Builder without extra steps.
4. Using Swift classes in Objective-C implementation files (.m)
You may notice something like this if you tried to use a Swift class in code.
It’s because we actually have to tell Objective-C to import an “Umbrella” header to make it available for your class.
In our case should be something like this:
So that’s it for mixing Swift in Objective-C project, pretty easy right?
Update: You can download ObjectiveSpring from my github now ☺