import Foundation

#if os(Linux)
typealias NSTextCheckingResult = TextCheckingResult
#endif

internal extension NSTextCheckingResult {
  var ranges: [NSRange] {
#if swift(>=4) || os(Linux)
  return stride(from: 0, to: numberOfRanges, by: 1).map(range)
#else
  return stride(from: 0, to: numberOfRanges, by: 1).map(rangeAt)
#endif
  }
}

internal extension String {
  var entireRange: NSRange {
    return NSRange(location: 0, length: utf16.count)
  }
}

import Foundation

#if os(Linux)
typealias NSTextCheckingResult = TextCheckingResult
#endif

internal extension NSTextCheckingResult {
  var ranges: [NSRange] {
#if os(Linux)
  return stride(from: 0, to: numberOfRanges, by: 1).map(range)
#else
  return stride(from: 0, to: numberOfRanges, by: 1).map(rangeAt)
#endif
  }
}

internal extension String {
  var entireRange: NSRange {
    return NSRange(location: 0, length: utf16.count)
  }
}

--- 
+++ 
@@ -6,7 +6,7 @@
 
 internal extension NSTextCheckingResult {
   var ranges: [NSRange] {
-#if os(Linux)
+#if swift(>=4) || os(Linux)
   return stride(from: 0, to: numberOfRanges, by: 1).map(range)
 #else
   return stride(from: 0, to: numberOfRanges, by: 1).map(rangeAt)
Fix compile error on swift 4
