If you were using the Turbolinks iOS framework, we recommend migrating to Turbo. Though Turbo iOS is a new a framework, it is not a major change from the old Turbolinks iOS framework. Most of the code is the same, but has been improved, refactored, and better tested. It is compatible both with Turbolinks 5 and Turbo 7 JS on the server. There are some breaking API changes, but mostly in name.
Follow these steps, and you should be up and running in no time. I was able to update Basecamp 3 and HEY in about 15 minutes to give you an idea of the scope:
- Update your dependency manager to point to
hotwired/turbo-ios
insteadturbolinks/turbolinks-ios
, see the installation doc for more info. - Change all your imports from
import Turbolinks
toimport Turbo
. This also would apply if you have any place you're using the full module for a type, likeTurbolinks.Session
would need to change toTurbo.Session
- Try to build, at which point you should start to see a few errors for API changes.
session(_ session: Session, didProposeVisitToURL url: URL, withAction action: Action)
is nowsession(_ session: Session, didProposeVisit proposal: VisitProposal)
. The newVisitProposal
type includes the url and a newVisitOptions
type. TheVisitOptions
type includes the action.func session(_ session: Session, didFailRequestForVisitable visitable: Visitable, withError error: NSError)
is nowfunc session(_ session: Session, didFailRequestForVisitable visitable: Visitable, error: Error)
. What was previously anNSError
is now anError
. To access the statusCode from a failure, you can check if the error is a newTurboError
type like so:let turboError = error as? TurboError, case .http(let statusCode) = turboError
- That should be the major code changes, please test your app first and open an issue if you run into blockers during migration. Note: the old Turbolinks.framework is now deprecated, but you can continue to use it as long as it works for you.
- Requires iOS 14 and later.
- Fixed numerous scroll inset issues with the web view. Almost all of these culminated from underlying WebKit bug across versions iOS 10 and iOS 11. It seems they were all fixed in iOS 12, so that's why iOS 12+ is now required. That means we could drop our hacks for getting the correct inset for the web view and rely on the iOS to do it automatically. The web view now sits full under the nav bar/tab bars and works as expected as far as scroll positioning and restoration
- Introduced a new
PathConfiguration
concept, documented here - PathConfiguration - Support for Turbo 7 apps as well as new
VisitOptions
provided by Turbo 7 - Support for Swift Package Manager now that as of Swift 5.3 it supports resources
- Bug fixes and additional tests