Skip to content

Can't build with Swift6 #156

@soranoba

Description

@soranoba

If we installed the library with CocoaPods, the Swift version may be 6, because #127
And, currently this library cannot be built with Swift 6.
I hope that the swift_version will set or that it will be possible to build with Swift 6.

Swift6 build error

Config.swift

Static property 'dirPath' is not concurrency-safe because it is nonisolated global shared mutable state
Static property 'dirFrameworkPath' is not concurrency-safe because it is nonisolated global shared mutable state
Static property 'dirResourcePath' is not concurrency-safe because it is nonisolated global shared mutable state

The simplest solution is (However, Apple does not recommend it):

diff --git a/Sources/Fakery/Config.swift b/Sources/Fakery/Config.swift
index 819a8a5..d5799ac 100644
--- a/Sources/Fakery/Config.swift
+++ b/Sources/Fakery/Config.swift
@@ -1,7 +1,7 @@
 public struct Config {
   public static let defaultLocale: String = "en"
   public static let pathExtension: String = "json"
-  public static var dirPath: String = "Resources/Locales"
-  public static var dirFrameworkPath: String = ""
-  public static var dirResourcePath: String = ""
+  nonisolated(unsafe) public static var dirPath: String = "Resources/Locales"
+  nonisolated(unsafe) public static var dirFrameworkPath: String = ""
+  nonisolated(unsafe) public static var dirResourcePath: String = ""
 }

ref: https://www.swift.org/migration/documentation/swift-6-concurrency-migration-guide/commonproblems/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions