Apple is releasing new iOS versions frequently, there’s an exciting new iPhone approaching fast, and of course there is restrictions in Appstore submission for older versions of your app. This can all come as a hurricane if we don’t make a sound decision in time for migrating iOS app to the latest versions. Not long-ago Apple mentioned — As of June 30, 2020, all apps for iPhone or iPad must be built with the iOS 13 SDK or later, included with Xcode 11 or later.”
As per Apple “Starting April 2021, all iOS and iPadOS apps submitted to the App Store must be built with Xcode 12 and the iOS 14 SDK.”
After April 2021, if your app doesn’t support iOS 14 SDK, you won’t be able to submit your app to the stores. So, if you didn’t migrate to iOS 14 in 2020, do it now and start off 2021 right.
Migrating to Swift 4/5 can seem a bit daunting depending on the size of the project, but with the proper steps and procedures you should be able to get through it much sooner than later. Xcodes 10.2 through 11 don’t support Swift 3.x. So as Swift 3 is not supported in current version of Xcode, you must have to update to swift 4/5.
Why to migrate to Swift 5?
Swift 5 introduced ABI.
ABI stability enables OS vendors to embed a Swift Standard Library and runtime in the OS that is compatible with applications built with Swift 5 or later. Earlier, Swift was not ABI stable, so each binary was bundling its own version of the Swift Dynamic Library but now its embedded within the iOS Operating System and it’s ABI will be compatible with every version of Swift.
Apart from the reduced bundle size and runtime compatibility, ABI is great when it comes to the pain of migration. As ABI provides less frequent language changes and source compatibility, it shows huge difference when migrating to newer version of swift. As there are no changes to the existing format, there isn’t a syntax converter for converting between Swift 5.x versions in Xcode.
Basics of migrations
Depending on your source code’s Swift version, you might need a different Xcode version for the conversion. To get an earlier version of Xcode, you can use your Apple Developer Account to download it from the Apple Developer Portal:
Note: Xcode 12 converts your Swift code to Swift 5.3, even though in the Swift Language Version dropdown under Build Settings, it shows Swift 5
Xcode’s built-in migration assistant is a good starting point for migration, however it’s also likely to generate code that simply won’t work in your project. If you are migrating to Swift 5, make sure that the project that you intend to migrate builds successfully in Swift 4 or Swift 4.2 mode, and all its tests pass.
Another step is to update libraries, the more dependencies you have, the more complications you may get. It’s good to have the version of the cocoa-pod CLI that fits that time. It’s 1.10.1.
sudo gem install cocoapods -v 1.10.1
Lastly there will be many parts in the project that will require you to make manual changes. So, it’s also crucial to be familiar with the project as depending the size and complexity of the project, you may have to resolve 500+ errors. Fortunately, all these hassles will be overcoming once you migrate to Swift 5. Thanks to ABI stability!
To migrate to a newer version from Xcode, choose Edit -> Convert -> To Current Swift Syntax from the Xcode menu. The migrator is not perfect and there will most likely be some errors and warnings that you’ll need to go through and resolve manually.