extension Backport where Content: View { @ViewBuilder func badge(_ count: Int) -> some View {
if #available(iOS 15, *) {
content.badge(count)
} else {
// some fallback?
content
}
}
}
Advantages:
- keep all version-specific checks in a single file
- use the same method name on all os versions
- Backport<T> isn't a view; forgetting the method = helpful compiler error
- basically a namespace for compatibility shims
- easy to ID usage: search for ".backport"
You can use this for other things too, by doing:
extension Backport where Content: UIViewController { … }
etc
When you up your minimum SDK version, go through the relevant usage sites and delete ".backport" and that's it. 🎉
This works especially well for methods and modifiers; less when when you want to backport an entirely new *type*, although you can make it work:
This should probably be a blog post, but I’m lazy and it’s easier to ⌘N in @tweetbot:
I had the privilege of attending and speaking at the Tokyo edition of @tryswiftconf recently. I had a fantastic and inspiring time, and want to share a couple observations with you
1/?
First off, I was totally impressed with the organization and logistics of the whole thing. It is HARD to pull a conference off well, but the @tryswiftconf team did it admirably.
2/?
Second: a huge kudos to the @tryswiftconf translators. Simultaneous translation is one of the most mentally taxing things I’ve ever done; to see these folks doing it for two days straight, at super-speed, with crazy amounts of technical language was awe-inspiring