I have a single codebase that needs to be compatible with Xcode 7 beta and Xcode 6.4. This is because beta testing and App Store builds should be built with the stable version of the compiler and SDK, but I also have iOS 9 beta on a phone I use for testing.
This hasn't been a problem with Objective-C, but now that I'm adding a bit of Swift, I'm finding it hard to maintain compatibility with both version of Xcode.
What can I do?
I know Swift has an #ifdef directive, but are there #ifdefs than can distinguish between Swift 1.2 and 2.0? I can't find a list of valid ones for Swift except for DEBUG, os, and arch.
Here's an example of what I mean:
#ifdef __IPHONE_9_0
some Swift code that works in Swift 2.0 but won't compile in Swift 1.2
#else
some Swift code that works in Swift 1.2 but won't compile in Swift 2.0
#endif
Or a more concrete example:
public final class MessageParser : NSObject {
#ifdef __IPHONE_9_0
static let sharedHashtagRegex = try! NSRegularExpression(pattern:"(^|\\W)(#|\\uFF03)(\\w*\\p{L}\\w*)", options:[]);
#else
static let sharedHashtagRegex = NSRegularExpression(pattern:"(^|\\W)(#|\\uFF03)(\\w*\\p{L}\\w*)", options:nil, error:nil)!
#endif
// ...
}