vadymmarkov / Fakery

:alien: Swift fake data generator
https://vadymmarkov.github.io
Other
1.79k stars 181 forks source link

Can't build with Swift6 #156

Open soranoba opened 1 week ago

soranoba commented 1 week ago

If we installed the library with CocoaPods, the Swift version may be 6, because https://github.com/vadymmarkov/Fakery/issues/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/