Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit 8fa5185

Browse files
authored
Use Swift 5.10 toolchain (#355)
2 parents 33b6e4a + 8969098 commit 8fa5185

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

.buildkite/pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ common_params:
33
plugins: &common_plugins
44
- automattic/a8c-ci-toolkit#3.1.0
55
env: &common_env
6-
IMAGE_ID: xcode-15.0.1
6+
IMAGE_ID: xcode-15.3-v3
77

88
# This is the default pipeline – it will build and test the pod
99
steps:

Package.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// swift-tools-version:5.5
1+
// swift-tools-version:5.10
22

33
import Foundation
44
import PackageDescription
55

66
let package = Package(
77
name: "WordPressShared",
8-
platforms: [.iOS(.v13)],
8+
platforms: [.iOS(.v13), .macOS(.v12)],
99
products: [
1010
.library(name: "WordPressShared", targets: ["WordPressShared"])
1111
],
@@ -15,7 +15,7 @@ let package = Package(
1515
// See https://github.com/erikdoe/ocmock/issues/500#issuecomment-1002700625
1616
.package(url: "https://github.com/erikdoe/ocmock", revision: "afd2c6924e8a36cb872bc475248b978f743c6050"),
1717
.package(url: "https://github.com/Quick/Quick", from: "6.0.0"),
18-
.package(url: "https://github.com/realm/SwiftLint", .exactItem(loadSwiftLintVersion()))
18+
.package(url: "https://github.com/realm/SwiftLint", exact: loadSwiftLintVersion())
1919
],
2020
targets: [
2121
.target(
@@ -63,10 +63,12 @@ let package = Package(
6363
)
6464

6565
func loadSwiftLintVersion() -> Version {
66-
guard let yamlString = try? String(contentsOf: URL(fileURLWithPath: #file)
66+
let swiftLintConfigURL = URL(fileURLWithPath: #file)
6767
.deletingLastPathComponent()
68-
.appendingPathComponent(".swiftlint.yml")) else {
69-
fatalError("Failed to read YAML file.")
68+
.appendingPathComponent(".swiftlint.yml")
69+
70+
guard let yamlString = try? String(contentsOf: swiftLintConfigURL) else {
71+
fatalError("Failed to read SwiftLint config file at \(swiftLintConfigURL).")
7072
}
7173

7274
guard let versionLine = yamlString.components(separatedBy: .newlines)

Sources/WordPressShared/Utility/NSDate+Helpers.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,9 @@ extension Date {
140140
}
141141

142142
/// Formats the current date as a medium relative date/time.
143-
/// - Parameter timeZone: An optional time zone used to adjust the date formatters.
144-
///
145-
/// - Example: Tomorrow, 6:45 AM
146-
/// - Example: Today, 8:09 AM
147-
/// - Example: Yesterday, 11:36 PM
148-
/// - Example: Jan 28, 2017, 1:51 PM
149-
/// - Example: Jan 22, 2017, 2:18 AM
143+
/// That is, it uses the `DateFormatter` `dateStyle` `.medium` and `timeStyle` `.short`.
150144
///
145+
/// - Parameter timeZone: An optional time zone used to adjust the date formatters.
151146
public func mediumStringWithTime(timeZone: TimeZone? = nil) -> String {
152147
let formatter = DateFormatters.mediumDateTime
153148
if let timeZone = timeZone {

Tests/WordPressSharedTests/NSDateHelperTest.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,26 @@ class NSDateHelperTest: XCTestCase {
5656
}
5757

5858
/// Verifies that `mediumStringWithTime` takes into account the time zone adjustment
59-
/// If this test is failing, check that the Test Plan is still using en-US as its language
59+
///
60+
/// This legacy test is a bit silly because it is simply testing that the code calls `DateFormatter` with the expected configuration.
61+
/// This was done to make the test robust against underlying changes in `DateFormatter`'s behavior.
62+
/// Example failure this avoids: https://buildkite.com/automattic/wordpress-shared-ios/builds/235#018ed45e-c2be-40e5-9759-6bd7c0735ce9/6-2623
6063
func testMediumStringTimeZoneAdjust() {
6164
let date = Date()
6265
let timeZone = TimeZone(secondsFromGMT: Calendar.current.timeZone.secondsFromGMT() - (60 * 60))
6366
XCTAssertEqual(date.toMediumString(inTimeZone: timeZone), "now")
6467

6568
let timeFormatter = DateFormatter()
66-
timeFormatter.dateStyle = .none
69+
timeFormatter.doesRelativeDateFormatting = true
70+
timeFormatter.dateStyle = .medium
6771
timeFormatter.timeStyle = .short
6872
let withoutTimeZoneAdjust = timeFormatter.string(from: date)
6973

70-
XCTAssertEqual(date.mediumStringWithTime(), "Today, \(withoutTimeZoneAdjust)")
74+
XCTAssertEqual(date.mediumStringWithTime(), withoutTimeZoneAdjust)
7175

7276
timeFormatter.timeZone = timeZone
7377
let withTimeZoneAdjust = timeFormatter.string(from: date)
7478

75-
XCTAssertEqual(date.mediumStringWithTime(timeZone: timeZone), "Today, \(withTimeZoneAdjust)")
79+
XCTAssertEqual(date.mediumStringWithTime(timeZone: timeZone), withTimeZoneAdjust)
7680
}
7781
}

0 commit comments

Comments
 (0)