Can anybody tell me a clean way to compile a Swift protocol and its implementation in Xcode 9 but not in Xcode 10?
I tried various options, including some based on conditional compilation like #if swift(>=4.2), and currently use a very ugly method based on duplicating the target. I wonder if there isn't any clean way.
The concrete reason is the protocol CaseIterable. I welcome the addition of this protocol to Swift 4.2 in Xcode 10, as it enables iterations over all cases of an enumeration. I look forward to removing my own implementation of that protocol, which was based on the fact that hashValue and rawValue in an enumeration used to return the same thing (described at various places, in this blog for example). This implementation does not work in Xcode 10 anymore, since hashValue has changed. That should not be a problem, I can just use the new compiler-supported implementation of CaseIterable, right? Unfortunately I cannot see a clean way of excluding my implementation of the protocol in Xcode 10 while keeping it for Xcode 9.