How to perform platform check with typealias and @available
Issue #38
The other day, I was building Anchors which needs to support iOS and macOS. What’s clever way to not use #if os(iOS) || os(tvOS)
in all files? Use typealias
This is the first version. I’m trying to support iOS 8, macOS 10.10
1 | #if os(iOS) || os(tvOS) |
But then because of LayoutGuide
, I need to bump deployment target to iOS 9, macOS 10.11. Which is not what I want. @available
to the rescue, but it will affect everything below it. The solution is to split the platform check, the first as normal, the second with @available
check
1 | #if os(iOS) || os(tvOS) |