修改pods

This commit is contained in:
2025-09-20 17:13:38 +08:00
parent 7787b3ee30
commit 28ff2b0264
5251 changed files with 345029 additions and 285168 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#import <FirebaseFirestoreInternal/FIRTimestamp.h>
#import <FirebaseFirestoreInternal/FIRVectorValue.h>

View File

@@ -33,8 +33,8 @@ public extension CollectionReference {
return try await withCheckedThrowingContinuation { continuation in
var document: DocumentReference?
document = self.addDocument(data: data) { error in
if let err = error {
continuation.resume(throwing: err)
if let error {
continuation.resume(throwing: error)
} else {
// Our callbacks guarantee that we either return an error or a document.
continuation.resume(returning: document!)

View File

@@ -31,8 +31,8 @@ public extension Firestore {
func loadBundle(_ bundleData: Data) async throws -> LoadBundleTaskProgress {
return try await withCheckedThrowingContinuation { continuation in
self.loadBundle(bundleData) { progress, error in
if let err = error {
continuation.resume(throwing: err)
if let error {
continuation.resume(throwing: error)
} else {
// Our callbacks guarantee that we either return an error or a progress event.
continuation.resume(returning: progress!)
@@ -49,8 +49,8 @@ public extension Firestore {
func loadBundle(_ bundleStream: InputStream) async throws -> LoadBundleTaskProgress {
return try await withCheckedThrowingContinuation { continuation in
self.loadBundle(bundleStream) { progress, error in
if let err = error {
continuation.resume(throwing: err)
if let error {
continuation.resume(throwing: error)
} else {
// Our callbacks guarantee that we either return an error or a progress event.
continuation.resume(returning: progress!)
@@ -107,8 +107,8 @@ public extension Firestore {
// See https://github.com/firebase/firebase-ios-sdk/issues/9426 for more details.
return try await withCheckedThrowingContinuation { continuation in
self.runTransaction(updateBlock) { anyValue, error in
if let err = error {
continuation.resume(throwing: err)
if let error {
continuation.resume(throwing: error)
} else {
continuation.resume(returning: anyValue)
}

View File

@@ -14,6 +14,8 @@
* limitations under the License.
*/
@_exported import class FirebaseCore.Timestamp
import FirebaseSharedSwift
import Foundation
@@ -29,6 +31,7 @@ struct FirestorePassthroughTypes: StructureCodingPassthroughTypeResolver {
t is GeoPoint ||
t is Timestamp ||
t is FieldValue ||
t is DocumentReference
t is DocumentReference ||
t is VectorValue
}
}

View File

@@ -20,7 +20,7 @@
@_exported import FirebaseFirestoreInternal
#endif // SWIFT_PACKAGE
@_implementationOnly import FirebaseCoreExtension
internal import FirebaseCoreExtension
import FirebaseSharedSwift
extension CodingUserInfoKey {
@@ -113,7 +113,7 @@ public struct DocumentID<Value: DocumentIDWrappable & Codable>:
private var value: Value? = nil
public init(wrappedValue value: Value?) {
if let value = value {
if let value {
logIgnoredValueWarning(value: value)
}
self.value = value
@@ -121,18 +121,13 @@ public struct DocumentID<Value: DocumentIDWrappable & Codable>:
public var wrappedValue: Value? {
get { value }
set {
if let someNewValue = newValue {
logIgnoredValueWarning(value: someNewValue)
}
value = newValue
}
set { value = newValue }
}
private func logIgnoredValueWarning(value: Value) {
FirebaseLogger.log(
level: .warning,
service: "[FirebaseFirestoreSwift]",
service: "[FirebaseFirestore]",
code: "I-FST000002",
message: """
Attempting to initialize or set a @DocumentID property with a non-nil \
@@ -146,7 +141,7 @@ public struct DocumentID<Value: DocumentIDWrappable & Codable>:
extension DocumentID: DocumentIDProtocol {
init(from documentReference: DocumentReference?) throws {
if let documentReference = documentReference {
if let documentReference {
value = try Value.wrap(documentReference)
} else {
value = nil

View File

@@ -33,7 +33,7 @@
private protocol CodableDocumentReference: Codable {}
/**
* DocumentReference's codable implmentation will just throw for most
* DocumentReference's codable implementation will just throw for most
* encoder/decoder however. It is only meant to be encoded by Firestore.Encoder/Firestore.Decoder.
*/
extension CodableDocumentReference {
@@ -50,4 +50,4 @@ extension CodableDocumentReference {
}
}
extension DocumentReference: CodableDocumentReference {}
extension FirebaseFirestore.DocumentReference: FirebaseFirestore.CodableDocumentReference {}

View File

@@ -93,7 +93,7 @@ public extension Firestore {
public func decode<T: Decodable>(_ t: T.Type, from data: Any,
in reference: DocumentReference?) throws -> T {
if let reference = reference {
if let reference {
userInfo[CodingUserInfoKey.documentRefUserInfoKey] = reference
}
return try decode(T.self, from: data)

View File

@@ -47,7 +47,7 @@ extension ExplicitNull: Hashable where Value: Hashable {}
extension ExplicitNull: Encodable where Value: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
if let value = value {
if let value {
try container.encode(value)
} else {
try container.encodeNil()

View File

@@ -21,7 +21,7 @@
#endif // SWIFT_PACKAGE
/** Extends FieldValue to conform to Encodable. */
extension FieldValue: Encodable {
extension FirebaseFirestore.FieldValue: Swift.Encodable {
/// Encoding a FieldValue will throw by default unless the encoder implementation
/// explicitly handles it, which is what Firestore.Encoder does.
public func encode(to encoder: Encoder) throws {

View File

@@ -63,4 +63,4 @@ extension CodableGeoPoint {
}
/** Extends GeoPoint to conform to Codable. */
extension GeoPoint: CodableGeoPoint {}
extension FirebaseFirestore.GeoPoint: FirebaseFirestore.CodableGeoPoint {}

View File

@@ -14,11 +14,7 @@
* limitations under the License.
*/
#if SWIFT_PACKAGE
@_exported import FirebaseFirestoreInternalWrapper
#else
@_exported import FirebaseFirestoreInternal
#endif // SWIFT_PACKAGE
@_exported import class FirebaseCore.Timestamp
/// A type that can initialize itself from a Firestore Timestamp, which makes
/// it suitable for use with the `@ServerTimestamp` property wrapper.
@@ -98,7 +94,7 @@ public struct ServerTimestamp<Value>: Codable
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
if let value = value {
if let value {
try container.encode(Value.unwrap(value))
} else {
try container.encode(FieldValue.serverTimestamp())
@@ -109,3 +105,5 @@ public struct ServerTimestamp<Value>: Codable
extension ServerTimestamp: Equatable where Value: Equatable {}
extension ServerTimestamp: Hashable where Value: Hashable {}
extension ServerTimestamp: Sendable where Value: Sendable {}

View File

@@ -14,11 +14,7 @@
* limitations under the License.
*/
#if SWIFT_PACKAGE
@_exported import FirebaseFirestoreInternalWrapper
#else
@_exported import FirebaseFirestoreInternal
#endif // SWIFT_PACKAGE
@_exported import class FirebaseCore.Timestamp
/**
* A protocol describing the encodable properties of a Timestamp.
@@ -63,4 +59,4 @@ extension CodableTimestamp {
}
/** Extends Timestamp to conform to Codable. */
extension Timestamp: CodableTimestamp {}
extension FirebaseCore.Timestamp: FirebaseFirestore.CodableTimestamp {}

View File

@@ -14,12 +14,8 @@
* limitations under the License.
*/
import Foundation
#if SWIFT_PACKAGE
@_exported import FirebaseFirestoreInternalWrapper
#else
@_exported import FirebaseFirestoreInternal
#endif // SWIFT_PACKAGE
@_exported import class FirebaseCore.Timestamp
import FirebaseSharedSwift
public extension FirebaseDataDecoder.DateDecodingStrategy {

View File

@@ -14,11 +14,7 @@
* limitations under the License.
*/
#if SWIFT_PACKAGE
@_exported import FirebaseFirestoreInternalWrapper
#else
@_exported import FirebaseFirestoreInternal
#endif // SWIFT_PACKAGE
@_exported import class FirebaseCore.Timestamp
import FirebaseSharedSwift
import Foundation

View File

@@ -0,0 +1,61 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if SWIFT_PACKAGE
@_exported import FirebaseFirestoreInternalWrapper
#else
@_exported import FirebaseFirestoreInternal
#endif // SWIFT_PACKAGE
/**
* A protocol describing the encodable properties of a VectorValue.
*/
private protocol CodableVectorValue: Codable {
var array: [Double] { get }
init(__array: [NSNumber])
}
/** The keys in a Timestamp. Must match the properties of CodableTimestamp. */
private enum VectorValueKeys: String, CodingKey {
case array
}
/**
* An extension of VectorValue that implements the behavior of the Codable protocol.
*
* Note: this is implemented manually here because the Swift compiler can't synthesize these methods
* when declaring an extension to conform to Codable.
*/
extension CodableVectorValue {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: VectorValueKeys.self)
let data = try container.decode([Double].self, forKey: .array)
let array = data.map { double in
NSNumber(value: double)
}
self.init(__array: array)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: VectorValueKeys.self)
try container.encode(array, forKey: .array)
}
}
/** Extends VectorValue to conform to Codable. */
extension FirebaseFirestore.VectorValue: FirebaseFirestore.CodableVectorValue {}

View File

@@ -55,7 +55,7 @@ public enum DecodingFailureStrategy {
///
/// `FirestoreQuery` also supports returning a `Result` type. The `.success` case
/// returns an array of elements, whereas the `.failure` case returns an error
/// in case mapping the Firestore docments wasn't successful:
/// in case mapping the Firestore documents wasn't successful:
///
/// struct ContentView: View {
/// @FirestoreQuery(
@@ -135,7 +135,7 @@ public struct FirestoreQuery<T>: DynamicProperty {
/// If any errors occurred, they will be exposed here as well.
public var error: Error?
/// The type of animation to apply when updating the view. If this is ommitted then no
/// The type of animation to apply when updating the view. If this is omitted then no
/// animations are fired.
public var animation: Animation?
}
@@ -143,12 +143,12 @@ public struct FirestoreQuery<T>: DynamicProperty {
/// The results of the query.
///
/// This property returns an empty collection when there are no matching results.
public var wrappedValue: T {
@MainActor @preconcurrency public var wrappedValue: T {
firestoreQueryObservable.items
}
/// A binding to the request's mutable configuration properties
public var projectedValue: Configuration {
@MainActor @preconcurrency public var projectedValue: Configuration {
get {
firestoreQueryObservable.configuration
}

View File

@@ -47,7 +47,7 @@ class FirestoreQueryObservable<T>: ObservableObject {
self.configuration = configuration
setupListener = createListener { [weak self] querySnapshot, error in
guard let self = self else { return }
if let error = error {
if let error {
self.animated {
self.items = []
self.projectError(error)
@@ -104,7 +104,7 @@ class FirestoreQueryObservable<T>: ObservableObject {
self.configuration = configuration
setupListener = createListener { [weak self] querySnapshot, error in
guard let self = self else { return }
if let error = error {
if let error {
self.animated {
self.items = .failure(error)
self.projectError(error)

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if SWIFT_PACKAGE
@_exported import FirebaseFirestoreInternalWrapper
#else
@_exported import FirebaseFirestoreInternal
#endif // SWIFT_PACKAGE
public extension FieldValue {
/// Creates a new `VectorValue` constructed with a copy of the given array of Doubles.
/// - Parameter array: An array of Doubles.
/// - Returns: A new `VectorValue` constructed with a copy of the given array of Doubles.
static func vector(_ array: [Double]) -> VectorValue {
let nsNumbers = array.map { double in
NSNumber(value: double)
}
return FieldValue.__vector(with: nsNumbers)
}
/// Creates a new `VectorValue` constructed with a copy of the given array of Floats.
/// - Parameter array: An array of Floats.
/// - Returns: A new `VectorValue` constructed with a copy of the given array of Floats.
static func vector(_ array: [Float]) -> VectorValue {
let nsNumbers = array.map { float in
NSNumber(value: float)
}
return FieldValue.__vector(with: nsNumbers)
}
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if SWIFT_PACKAGE
@_exported import FirebaseFirestoreInternalWrapper
#else
@_exported import FirebaseFirestoreInternal
#endif // SWIFT_PACKAGE
public extension VectorValue {
convenience init(_ array: [Double]) {
let nsNumbers = array.map { float in
NSNumber(value: float)
}
self.init(__array: nsNumbers)
}
/// Returns a raw number array representation of the vector.
/// - Returns: An array of Double values representing the vector.
var array: [Double] {
return __array.map { Double(truncating: $0) }
}
}

View File

@@ -86,7 +86,7 @@ For details on using Firebase from a Framework or a library, refer to [firebase_
To develop Firebase software in this repository, ensure that you have at least
the following software:
* Xcode 14.1 (or later)
* Xcode 16.2 (or later)
CocoaPods is still the canonical way to develop, but much of the repo now supports
development with Swift Package Manager.
@@ -137,7 +137,7 @@ Alternatively, disable signing in each target:
### Adding a New Firebase Pod
Refer to [AddNewPod](AddNewPod.md) Markdown file for details.
Refer to [AddNewPod](docs/AddNewPod.md) Markdown file for details.
### Managing Headers and Imports
@@ -153,7 +153,7 @@ GitHub Actions will verify that any code changes are done in a style-compliant
way. Install `clang-format` and `mint`:
```console
brew install clang-format@18
brew install clang-format@20
brew install mint
```
@@ -235,6 +235,11 @@ at **Project Settings > Cloud Messaging > [Your Firebase App]**.
The iOS Simulator cannot register for remote notifications and will not receive push notifications.
To receive push notifications, follow the steps above and run the app on a physical device.
### Vertex AI for Firebase
See the [Vertex AI for Firebase README](FirebaseVertexAI#development) for
instructions about building and testing the SDK.
## Building with Firebase on Apple platforms
Firebase provides official beta support for macOS, Catalyst, and tvOS. visionOS and watchOS