Skip to content

Commit 16dc680

Browse files
authored
SWIFT-855 Add minimum macOS version and document OS support policy (#487)
1 parent 7e60c3c commit 16dc680

File tree

6 files changed

+14
-27
lines changed

6 files changed

+14
-27
lines changed

Package.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import PackageDescription
33
let package = Package(
44
name: "mongo-swift-driver",
5+
platforms: [
6+
.macOS(.v10_14)
7+
],
58
products: [
69
.library(name: "MongoSwift", targets: ["MongoSwift"]),
710
.library(name: "MongoSwiftSync", targets: ["MongoSwiftSync"])

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Bug reports in JIRA for all driver projects (i.e. NODE, PYTHON, CSHARP, JAVA) an
3434
Core Server (i.e. SERVER) project are **public**.
3535

3636
## Installation
37-
The driver supports use with Swift 5.1+ on MacOS and Linux.
37+
The driver supports use with Swift 5.1+. The minimum macOS version required to build the driver is 10.14. The driver is tested in continuous integration against macOS 10.14, Ubuntu 16.04, and Ubuntu 18.04.
3838

3939
Installation is supported via [Swift Package Manager](https://swift.org/package-manager/).
4040

Sources/MongoSwift/BSON/BSONDecoder.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,6 @@ extension _BSONDecoder {
396396
let seconds = try unboxNumber(value, as: Double.self)
397397
return Date(timeIntervalSince1970: seconds)
398398
case .iso8601:
399-
guard #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) else {
400-
fatalError("ISO8601DateFormatter is unavailable on this platform.")
401-
}
402399
let isoString = try self.unboxCustom(value) { $0.stringValue }
403400
guard let date = BSONDecoder.iso8601Formatter.date(from: isoString) else {
404401
throw DecodingError.dataCorrupted(

Sources/MongoSwift/BSON/BSONEncoder.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,6 @@ extension _BSONEncoder {
438438
case let .formatted(formatter):
439439
return formatter.string(from: date)
440440
case .iso8601:
441-
guard #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) else {
442-
fatalError("ISO8601DateFormatter is unavailable on this platform.")
443-
}
444441
return BSONDecoder.iso8601Formatter.string(from: date)
445442
case let .custom(f):
446443
return try self.handleCustomStrategy(encodeFunc: f, forValue: date)

Sources/MongoSwift/BSON/CodingStrategies.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ public enum DateCodingStrategy: RawRepresentable {
8282
case (.secondsSince1970, .secondsSince1970):
8383
self = .secondsSince1970
8484
case (.iso8601, .iso8601):
85-
guard #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) else {
86-
fatalError("ISO8601DateFormatter is unavailable on this platform.")
87-
}
8885
self = .iso8601
8986
case let (.formatted(encodingFormatter), .formatted(decodingFormatter)):
9087
guard encodingFormatter == decodingFormatter else {
@@ -109,9 +106,6 @@ public enum DateCodingStrategy: RawRepresentable {
109106
case .secondsSince1970:
110107
return (.secondsSince1970, .secondsSince1970)
111108
case .iso8601:
112-
guard #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) else {
113-
fatalError("ISO8601DateFormatter is unavailable on this platform.")
114-
}
115109
return (.iso8601, .iso8601)
116110
case let .formatted(formatter):
117111
return (.formatted(formatter), .formatted(formatter))

Tests/BSONTests/DocumentTests.swift

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -711,11 +711,9 @@ final class DocumentTests: MongoSwiftTestCase {
711711
let millisecondsSince1970 = try encoder.encode(dateStruct)
712712
expect(millisecondsSince1970["date"]).to(equal(.int64(date.msSinceEpoch)))
713713

714-
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
715-
encoder.dateEncodingStrategy = .iso8601
716-
let iso = try encoder.encode(dateStruct)
717-
expect(iso["date"]).to(equal(.string(BSONDecoder.iso8601Formatter.string(from: date))))
718-
}
714+
encoder.dateEncodingStrategy = .iso8601
715+
let iso = try encoder.encode(dateStruct)
716+
expect(iso["date"]).to(equal(.string(BSONDecoder.iso8601Formatter.string(from: date))))
719717

720718
let formatter = DateFormatter()
721719
formatter.timeStyle = .full
@@ -819,15 +817,13 @@ final class DocumentTests: MongoSwiftTestCase {
819817
expect(try decoder.decode(DateWrapper.self, from: badlyFormatted)).to(throwError(CodecTests.dataCorruptedErr))
820818
expect(try decoder.decode(DateWrapper.self, from: sDouble)).to(throwError(CodecTests.typeMismatchErr))
821819

822-
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
823-
decoder.dateDecodingStrategy = .iso8601
824-
let isoDoc: BSONDocument = ["date": .string(BSONDecoder.iso8601Formatter.string(from: date))]
825-
let isoStruct = try decoder.decode(DateWrapper.self, from: isoDoc)
826-
expect(isoStruct.date).to(equal(date))
827-
expect(try decoder.decode(DateWrapper.self, from: formatted)).to(throwError(CodecTests.dataCorruptedErr))
828-
expect(try decoder.decode(DateWrapper.self, from: badlyFormatted))
829-
.to(throwError(CodecTests.dataCorruptedErr))
830-
}
820+
decoder.dateDecodingStrategy = .iso8601
821+
let isoDoc: BSONDocument = ["date": .string(BSONDecoder.iso8601Formatter.string(from: date))]
822+
let isoStruct = try decoder.decode(DateWrapper.self, from: isoDoc)
823+
expect(isoStruct.date).to(equal(date))
824+
expect(try decoder.decode(DateWrapper.self, from: formatted)).to(throwError(CodecTests.dataCorruptedErr))
825+
expect(try decoder.decode(DateWrapper.self, from: badlyFormatted))
826+
.to(throwError(CodecTests.dataCorruptedErr))
831827

832828
decoder.dateDecodingStrategy = .custom({ decode in try Date(from: decode) })
833829
let customDoc: BSONDocument = ["date": .double(date.timeIntervalSinceReferenceDate)]

0 commit comments

Comments
 (0)