This guide should help you with migrating projects on previous version of Swift to newer versions.
IMPORTANT: Make granular commits after each step and substep in this guide. Make sure the commit messages follow the proper rules.
- Clone project and pull/checkout all branches (script here).
- Clean up all branches and keep only
master
anddevelop
- Make sure
develop
is even or ahead ofmaster
- Clean up all branches and keep only
- From
develop
branch rungit checkout -b feature/swift3-migration
. - (optional) Clean project, remove unused files, update file structure.
- Update
Cartfile
to point to Swift 3 versions of dependencies. 📦- Update framework names if used in project
NStack
→NStackSDK
Serializable
→Serpent
- Remove existing Carthage folder and run
carthage update --platform ios
(change platform as needed)
- Update framework names if used in project
- (optional) Update translations generator.
- Download from latest Swift 3 release on Github, do NOT add to Xcode
- Remove any old translations generator and templates present in project
- Open
YourProject.xcodeproj
in Xcode 8 and run Swift migrator.- Go through suggested changes to double check
- Go to Build Phases and modify current run scripts.
- Update build settings.
- Enable whole module optimizations for release/adhoc
- Enable bitcode if possible
- Remove unused/old user-defined build settings (scroll to the bottom of build settings)
- Build and fix errors, rinse & repeat until project compiles. 😬
- Alamofire (official migration guide)
- Change
Manager
toSessionManager
- Update completion type to
DataResponse
- Rename completion closure paramter to response instead of result
- Requests have to start with the url, followed by method and other parameters
- Switch on
response.result
instead of result - Update switch cases to
.success(let data)
and.failure(let error)
- Change
- Serpent
- Replace
import Serializable
withimport Serpent
- Remove
completionHandler:
named parameter in Alamofire requests - (important) Set default unwrapper, or manually specify per request
- Replace
- Blobfish
- Completely replace ErrorHandler or add error handling if not present
- Properly setup blobs for token expired, connection error, unknown error
- NStackSDK
- Replace
import NStack
withimport NStackSDK
- Start function now takes also a
launchOptions:
parameter
- Replace
- and more (read documentation of frameworks)
- (optional) Refactor code to newer standards along the way (small changes)
- Alamofire (official migration guide)
- Fix as many (ideally all) warnings in the project, so that it's clean and updated.
- (optional) If using HockeySDK, add
NSPhotoLibraryUsageDescription
to theInfo.plist
. - Add or udpate README.
- Change Swift / Xcode versions
- Small project description
- Things to watch out for
- Add test users if necessary
- (optional) Implement CI, if applicable (refer here).
- After you're done open a pull request to
develop
branch.- Make sure that CI / other checks pass and someone does code-review
- After it gets merged, delete the feature branch
- If this is a framework, also open a PR to
master
(don't do this on projects if not ready for release)
- Enjoy life and pat yourself on the back for succeeding at this. 🎉
Coming late 2017.