فهرست منبع

[Swift 6] Fix mutable state error in FirebaseDataEncoder.swift (#14556)

Nick Cooke 1 سال پیش
والد
کامیت
e34ab016f3

+ 3 - 3
.github/workflows/shared-swift.yml

@@ -31,9 +31,9 @@ jobs:
           - os: macos-15
             xcode: Xcode_16.2
             swift_version: 5.9
-          # - os: macos-15
-          #   xcode: Xcode_16.2
-          #   swift_version: 6.0
+          - os: macos-15
+            xcode: Xcode_16.2
+            swift_version: 6.0
     runs-on: ${{ matrix.build-env.os }}
     steps:
     - uses: actions/checkout@v4

+ 8 - 0
FirebaseSharedSwift/Sources/third_party/FirebaseDataEncoder/FirebaseDataEncoder.swift

@@ -2611,11 +2611,19 @@ fileprivate struct _JSONKey : CodingKey {
 //===----------------------------------------------------------------------===//
 
 // NOTE: This value is implicitly lazy and _must_ be lazy. We're compiled against the latest SDK (w/ ISO8601DateFormatter), but linked against whichever Foundation the user has. ISO8601DateFormatter might not exist, so we better not hit this code path on an older OS.
+#if compiler(>=6)
+nonisolated(unsafe) fileprivate var _iso8601Formatter: ISO8601DateFormatter = {
+  let formatter = ISO8601DateFormatter()
+  formatter.formatOptions = .withInternetDateTime
+  return formatter
+}()
+#else
 fileprivate var _iso8601Formatter: ISO8601DateFormatter = {
   let formatter = ISO8601DateFormatter()
   formatter.formatOptions = .withInternetDateTime
   return formatter
 }()
+#endif
 
 //===----------------------------------------------------------------------===//
 // Error Utilities