diff --git a/Sources/FoundationInternationalization/Locale/Locale_ICU.swift b/Sources/FoundationInternationalization/Locale/Locale_ICU.swift index c22025ee8..ca9b86e43 100644 --- a/Sources/FoundationInternationalization/Locale/Locale_ICU.swift +++ b/Sources/FoundationInternationalization/Locale/Locale_ICU.swift @@ -1209,8 +1209,8 @@ internal final class _LocaleICU: _LocaleProtocol, Sendable { } } - // Check prefs - if let firstWeekdayPref = prefs?.firstWeekday { + // Check prefs. The value doesn't matter here - we check it again in the `forceFirstWeekday` function, and it is immutable. + if prefs?.firstWeekday != nil { let calendarId = calendarIdentifier if let first = forceFirstWeekday(calendarId) { state.firstDayOfWeek = first diff --git a/Sources/FoundationInternationalization/Locale/Locale_ObjC.swift b/Sources/FoundationInternationalization/Locale/Locale_ObjC.swift index ea79592cc..ff2c995b6 100644 --- a/Sources/FoundationInternationalization/Locale/Locale_ObjC.swift +++ b/Sources/FoundationInternationalization/Locale/Locale_ObjC.swift @@ -308,7 +308,10 @@ internal class _NSSwiftLocale: _NSLocaleBridge, @unchecked Sendable { switch locale.temperatureUnit { case .celsius: return NSLocaleTemperatureUnitCelsius case .fahrenheit: return NSLocaleTemperatureUnitFahrenheit +#if !FOUNDATION_FRAMEWORK + // On non-framework builds, the enum is non-closed and `package` visibility, so we need a default default: return NSLocaleTemperatureUnitCelsius +#endif } case .decimalSeparator: return self.decimalSeparator case .groupingSeparator: return self.groupingSeparator diff --git a/Sources/FoundationInternationalization/TimeZone/TimeZone_ICU.swift b/Sources/FoundationInternationalization/TimeZone/TimeZone_ICU.swift index f1b35e649..931807868 100644 --- a/Sources/FoundationInternationalization/TimeZone/TimeZone_ICU.swift +++ b/Sources/FoundationInternationalization/TimeZone/TimeZone_ICU.swift @@ -222,6 +222,12 @@ internal final class _TimeZoneICU: _TimeZoneProtocol, Sendable { return Self.timeZoneDisplayName(for: c, timeZoneName: identifier, localeName: locID, isShort: false, isGeneric: true, isDaylight: false) case .shortGeneric: return Self.timeZoneDisplayName(for: c, timeZoneName: identifier, localeName: locID, isShort: true, isGeneric: true, isDaylight: false) +#if FOUNDATION_FRAMEWORK + // We only need this when building in ObjC mode, when the enum comes from a .h + @unknown default: + // Use standard style + return Self.timeZoneDisplayName(for: c, timeZoneName: identifier, localeName: locID, isShort: false, isGeneric: false, isDaylight: false) +#endif } } } diff --git a/Tests/FoundationEssentialsTests/AttributedString/AttributedStringIndexValidityTests.swift b/Tests/FoundationEssentialsTests/AttributedString/AttributedStringIndexValidityTests.swift index c9a10e600..9237c0fbc 100644 --- a/Tests/FoundationEssentialsTests/AttributedString/AttributedStringIndexValidityTests.swift +++ b/Tests/FoundationEssentialsTests/AttributedString/AttributedStringIndexValidityTests.swift @@ -140,7 +140,7 @@ final class AttributedStringIndexValidityTests: XCTestCase { } public func testMutationInvalidation() { - func checkInPlace(_ mutation: (inout AttributedString) -> (), file: StaticString = #file, line: UInt = #line) { + func checkInPlace(_ mutation: (inout AttributedString) -> (), file: StaticString = #filePath, line: UInt = #line) { var str = AttributedString("Hello World") let idxA = str.startIndex let idxB = str.index(afterCharacter: idxA) @@ -158,7 +158,7 @@ final class AttributedStringIndexValidityTests: XCTestCase { XCTAssertFalse(RangeSet(idxA ..< idxB).isValid(within: str), "Initial range set was valid in in-place mutated", file: file, line: line) } - func checkCopy(_ mutation: (inout AttributedString) -> (), file: StaticString = #file, line: UInt = #line) { + func checkCopy(_ mutation: (inout AttributedString) -> (), file: StaticString = #filePath, line: UInt = #line) { let str = AttributedString("Hello World") let idxA = str.startIndex let idxB = str.index(afterCharacter: idxA) @@ -185,7 +185,7 @@ final class AttributedStringIndexValidityTests: XCTestCase { XCTAssertFalse(RangeSet(idxA ..< idxB).isValid(within: copy), "Initial range set was valid in copy", file: file, line: line) } - func check(_ mutation: (inout AttributedString) -> (), file: StaticString = #file, line: UInt = #line) { + func check(_ mutation: (inout AttributedString) -> (), file: StaticString = #filePath, line: UInt = #line) { checkInPlace(mutation, file: file, line: line) checkCopy(mutation, file: file, line: line) } diff --git a/Tests/FoundationEssentialsTests/AttributedString/AttributedStringTests.swift b/Tests/FoundationEssentialsTests/AttributedString/AttributedStringTests.swift index 99df913cc..25a44fe90 100644 --- a/Tests/FoundationEssentialsTests/AttributedString/AttributedStringTests.swift +++ b/Tests/FoundationEssentialsTests/AttributedString/AttributedStringTests.swift @@ -1882,7 +1882,7 @@ E { func check( _ a: some Sequence, _ b: some Sequence, - file: StaticString = #file, line: UInt = #line + file: StaticString = #filePath, line: UInt = #line ) { XCTAssertTrue( a.elementsEqual(b), diff --git a/Tests/FoundationEssentialsTests/DataIOTests.swift b/Tests/FoundationEssentialsTests/DataIOTests.swift index 324012c11..fdaca9b56 100644 --- a/Tests/FoundationEssentialsTests/DataIOTests.swift +++ b/Tests/FoundationEssentialsTests/DataIOTests.swift @@ -185,6 +185,7 @@ class DataIOTests : XCTestCase { #if FOUNDATION_FRAMEWORK // String(contentsOf:) is not available outside the framework yet + @available(*, deprecated) func test_emptyFileString() { let data = Data() let url = testURL() diff --git a/Tests/FoundationEssentialsTests/StringTests.swift b/Tests/FoundationEssentialsTests/StringTests.swift index 7b7cb041b..39b5d3672 100644 --- a/Tests/FoundationEssentialsTests/StringTests.swift +++ b/Tests/FoundationEssentialsTests/StringTests.swift @@ -1319,7 +1319,7 @@ final class StringTests : XCTestCase { } - func verifyEncoding(_ encoding: String._Encoding, valid: [String], invalid: [String], file: StaticString = #file, line: UInt = #line) throws { + func verifyEncoding(_ encoding: String._Encoding, valid: [String], invalid: [String], file: StaticString = #filePath, line: UInt = #line) throws { for string in valid { let data = try XCTUnwrap(string.data(using: encoding), "Failed to encode \(string.debugDescription)", file: file, line: line) XCTAssertNotNil(String(data: data, encoding: encoding), "Failed to decode \(data) (\(string.debugDescription))", file: file, line: line) diff --git a/Tests/FoundationInternationalizationTests/DateComponentsTests.swift b/Tests/FoundationInternationalizationTests/DateComponentsTests.swift index e9c9c9242..14456e5e2 100644 --- a/Tests/FoundationInternationalizationTests/DateComponentsTests.swift +++ b/Tests/FoundationInternationalizationTests/DateComponentsTests.swift @@ -141,8 +141,8 @@ final class DateComponentsTests : XCTestCase { extension DateComponentsTests { func date(from string: String, nanoseconds: Int? = nil) -> Date { let d = try! Date(string, strategy: Date.ParseStrategy(format: "\(year: .extended(minimumLength: 4))-\(month: .twoDigits)-\(day: .twoDigits) \(hour: .twoDigits(clock: .twentyFourHour, hourCycle: .zeroBased)):\(minute: .twoDigits):\(second: .twoDigits) \(timeZone: .iso8601(.short))", locale: Locale(identifier: "en_US"), timeZone: TimeZone.gmt)) - if let nanoseconds { - var comps = Calendar(identifier: .gregorian).dateComponents([.era, .year, .month, .day, .hour, .minute, .second, .nanosecond, .weekday, .weekdayOrdinal, .quarter, .weekOfMonth, .weekOfYear, .yearForWeekOfYear, .timeZone, .calendar], from: d) + if nanoseconds != nil { + let comps = Calendar(identifier: .gregorian).dateComponents([.era, .year, .month, .day, .hour, .minute, .second, .nanosecond, .weekday, .weekdayOrdinal, .quarter, .weekOfMonth, .weekOfYear, .yearForWeekOfYear, .timeZone, .calendar], from: d) return Calendar(identifier: .gregorian).date(from: comps)! } return d diff --git a/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift b/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift index c40b59741..807248f67 100644 --- a/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift +++ b/Tests/FoundationInternationalizationTests/Formatting/DateFormatStyleTests.swift @@ -712,7 +712,7 @@ final class DateAttributedFormatStyleTests : XCTestCase { func test(dateStyle: Date.FormatStyle.DateStyle, timeStyle: Date.FormatStyle.TimeStyle, dateFormatOverride: [Date.FormatStyle.DateStyle: String], expected: [Segment], file: StaticString = #filePath, line: UInt = #line) { let locale = Locale.localeAsIfCurrent(name: enUS, overrides: .init(dateFormats: dateFormatOverride)) - let style = Date.FormatStyle(date: dateStyle, time: timeStyle, locale: locale, calendar: Calendar(identifier: .gregorian), timeZone: TimeZone(identifier: "PST")!, capitalizationContext: .standalone).attributed + let style = Date.FormatStyle(date: dateStyle, time: timeStyle, locale: locale, calendar: Calendar(identifier: .gregorian), timeZone: TimeZone(identifier: "PST")!, capitalizationContext: .standalone).attributedStyle XCTAssertEqual(style.format(date), expected.attributedString, file: file, line: line) } diff --git a/Tests/FoundationInternationalizationTests/Formatting/NumberFormatStyleTests.swift b/Tests/FoundationInternationalizationTests/Formatting/NumberFormatStyleTests.swift index 652146566..2623c40cf 100644 --- a/Tests/FoundationInternationalizationTests/Formatting/NumberFormatStyleTests.swift +++ b/Tests/FoundationInternationalizationTests/Formatting/NumberFormatStyleTests.swift @@ -597,7 +597,7 @@ final class NumberFormatStyleTests: XCTestCase { func testCurrency_Codable() throws { let gbpInUS = Decimal.FormatStyle.Currency(code: "GBP", locale: enUSLocale) - let encoded = try JSONEncoder().encode(gbpInUS) + let _ = try JSONEncoder().encode(gbpInUS) // Valid JSON presentation of the format style let previouslyEncoded = """ {