Is it possible to include typealias entries only if the code is compiled for *lower* targets?

We have a codebase that we're targeting iOS 9 through 12 and we're using Xcode 9 and 10 as a result. We always try to write our code to target the latest APIs, then add backwards compatibility if needed.

For instance, this code is in iOS 11 and newer...

UITableView.RowAnimation

However, prior to iOS 11, it's this...

UITableViewRowAnimation

To allow our code to be compiled in Xcode9 against iOS9, we've created a 'compatibility.swift' file that includes things like this...

extension UITableView {

    public typealias RowAnimation = UITableViewRowAnimation

    public static var automaticDimension = UITableViewAutomaticDimension
    public func performBatchUpdates(_ batchFunction:() -> Void, completion:(() -> Void)? = nil){

        beginUpdates()

        batchFunction()

        endUpdates()

        completion?()
    }
}

What we're trying to do is only include the above if iOS is less than 11.

I know about attributes on methods, as well as the if-checks against versioning, but from what I can tell, they don't actually exclude it from being compiled, meaning if you included the above, even if attributed, you will get compilation errors in iOS 11.

Now while I could create a second target, then include and exclude the files as needed, other languages actually let you specify compiler directive to exclude them right from within the file.

Does Swift have any such functionality? If not, how can the above be achieved in a project that's being opened in both iOS 9/Xcode 9 and iOS 11/Xcode 10?