Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Swift 6 preparation #90

Closed
31 changes: 31 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,37 @@ let package = Package(
]
)

// Use https://www.swift.org/swift-evolution/ to see details of the upcoming/experimental features
let upcomingFeatureSwiftSettings: [SwiftSetting] = [
"ConciseMagicFile", // SE-0274
"ForwardTrailingClosures", // SE-0286
"ExistentialAny", // SE-0335
"BareSlashRegexLiterals", // SE-0354
"ImportObjcForwardDeclarations", // SE-0384
"DeprecateApplicationMain", // SE-0383
"DisableOutwardActorInference", // SE-0401
"IsolatedDefaultValues", // SE-0411
"GlobalConcurrency" // SE-0412
].map {
.enableUpcomingFeature($0)
}

let experimentalFeatureSwiftSettings: [SwiftSetting] = [
"AccessLevelOnImport", // SE-0409
"StrictConcurrency" // SE-0412
].map {
.enableExperimentalFeature($0)
}

package.targets.forEach { target in
guard target.name != "XCStringsToolPlugin" else {
return /// Plugins don't support setting `swiftSettings`
}

let swiftSettings = target.swiftSettings ?? []
target.swiftSettings = swiftSettings + upcomingFeatureSwiftSettings + experimentalFeatureSwiftSettings
}

// https://swiftpackageindex.com/swiftpackageindex/spimanifest/0.19.0/documentation/spimanifest/validation
// On CI, we want to validate the manifest, but nobody else needs that.
if ProcessInfo.processInfo.environment.keys.contains("VALIDATE_SPI_MANIFEST") {
Expand Down
2 changes: 1 addition & 1 deletion Sources/StringCatalog/Types/StringExtractionState.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public struct StringExtractionState: Codable, Hashable, RawRepresentable, ExpressibleByStringLiteral {
public struct StringExtractionState: Codable, Hashable, RawRepresentable, ExpressibleByStringLiteral, Sendable {
public let rawValue: String

public init(rawValue: String) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/StringCatalog/Types/StringLanguage.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public struct StringLanguage: Codable, Hashable, RawRepresentable, ExpressibleByStringLiteral, CodingKeyRepresentable {
public struct StringLanguage: Codable, Hashable, RawRepresentable, ExpressibleByStringLiteral, CodingKeyRepresentable, Sendable {
public let rawValue: String

public init(rawValue: String) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/StringCatalog/Types/StringUnitState.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public struct StringUnitState: Codable, Hashable, RawRepresentable, ExpressibleByStringLiteral {
public struct StringUnitState: Codable, Hashable, RawRepresentable, ExpressibleByStringLiteral, Sendable {
public let rawValue: String

public init(rawValue: String) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/StringCatalog/Types/StringVariations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct StringVariations: Codable {
}

extension StringVariations {
public struct DeviceKey: Codable, Hashable, RawRepresentable, ExpressibleByStringLiteral, CodingKeyRepresentable {
public struct DeviceKey: Codable, Hashable, RawRepresentable, ExpressibleByStringLiteral, CodingKeyRepresentable, Sendable {
public let rawValue: String

public init(rawValue: String) {
Expand All @@ -32,7 +32,7 @@ extension StringVariations {
public static let other = Self(rawValue: "other")
}

public struct PluralKey: Codable, Hashable, RawRepresentable, ExpressibleByStringLiteral, CodingKeyRepresentable {
public struct PluralKey: Codable, Hashable, RawRepresentable, ExpressibleByStringLiteral, CodingKeyRepresentable, Sendable {
public let rawValue: String

public init(rawValue: String) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/StringExtractor/ExtractionError.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public enum ExtractionError: Error {
public struct Context {
public struct Context: Codable, Sendable {
liamnichols marked this conversation as resolved.
Show resolved Hide resolved
/// The key of the localization being parsed
public let key: String

Expand Down
2 changes: 1 addition & 1 deletion Sources/xcstrings-tool/XCStringsTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import XCStringsToolConstants

@main
struct XCStringsTool: ParsableCommand {
static var configuration = CommandConfiguration(
static let configuration = CommandConfiguration(
commandName: "xcstrings-tool",
abstract: "Generates Swift code from String Catalogs (.xcstrings files)",
version: version,
Expand Down
2 changes: 1 addition & 1 deletion Tests/XCStringsToolTests/FixtureTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class FixtureTestCase: XCTestCase {
fixtures = try XCTUnwrap(bundle.urls(forResourcesWithExtension: "xcstrings", subdirectory: "__Fixtures__"))
}

func eachFixture(_ test: (URL) throws -> Void) throws {
@MainActor func eachFixture(_ test: (URL) throws -> Void) throws {
for fileURL in fixtures {
try XCTContext.runActivity(named: fileURL.lastPathComponent) { activity in
do {
Expand Down
5 changes: 3 additions & 2 deletions Tests/XCStringsToolTests/GenerateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SnapshotTesting
import XCTest

final class GenerateTests: FixtureTestCase {
func testGenerate() throws {
@MainActor func testGenerate() throws {
try eachFixture { inputURL in
if !inputURL.lastPathComponent.hasPrefix("!") {
try snapshot(for: inputURL)
Expand Down Expand Up @@ -79,7 +79,7 @@ private extension GenerateTests {
func assertError(
for inputURL: URL,
localizedDescription expected: String,
file: StaticString = #file,
file: StaticString = #filePath,
line: UInt = #line
) {
XCTAssertThrowsError(try run(for: inputURL), file: file, line: line) { error in
Expand All @@ -106,6 +106,7 @@ private extension GenerateTests {

// Cleanup any temporary output
addTeardownBlock {
let fileManager = FileManager.default /// Needed because `FileManager` is not `Sendable`
if fileManager.fileExists(atPath: outputURL.path()) {
try? fileManager.removeItem(at: outputURL)
}
Expand Down
Loading