From a7e3720e9e2a03724346ccdc289af639e374c0d9 Mon Sep 17 00:00:00 2001 From: Nick Cooke <36927374+ncooke3@users.noreply.github.com> Date: Fri, 13 Oct 2023 14:52:29 -0400 Subject: [PATCH] [Firestore] Consolidate Firestore and FirestoreSwift (#11806) --- FirebaseFirestore.podspec | 4 + FirebaseFirestoreSwift.podspec | 7 +- .../Sources/FirebaseFirestoreSwift.swift | 30 +++ Firestore/CHANGELOG.md | 6 + Firestore/Swift/CHANGELOG.md | 7 + .../CollectionReference+AsyncAwait.swift | 4 +- .../AsyncAwait/Firestore+AsyncAwait.swift | 4 +- .../Codable/CodablePassThroughTypes.swift | 4 +- .../CollectionReference+WriteEncodable.swift | 4 +- .../Swift/Source/Codable/DocumentID.swift | 4 +- .../Codable/DocumentReference+Codable.swift | 4 +- .../DocumentReference+ReadDecodable.swift | 4 +- .../DocumentReference+WriteEncodable.swift | 4 +- .../DocumentSnapshot+ReadDecodable.swift | 4 +- .../Swift/Source/Codable/EncoderDecoder.swift | 4 +- .../Swift/Source/Codable/ExplicitNull.swift | 4 +- .../Source/Codable/FieldValue+Encodable.swift | 4 +- .../Source/Codable/GeoPoint+Codable.swift | 4 +- .../Source/Codable/ServerTimestamp.swift | 4 +- .../Source/Codable/Timestamp+Codable.swift | 4 +- .../Codable/TimestampDecodingStrategy.swift | 4 +- .../Codable/TimestampEncodingStrategy.swift | 4 +- .../Codable/Transaction+WriteEncodable.swift | 4 +- .../Codable/WriteBatch+WriteEncodable.swift | 4 +- .../PropertyWrapper/FirestoreQuery.swift | 4 +- .../FirestoreQueryObservable.swift | 4 +- .../PropertyWrapper/QueryPredicate.swift | 4 +- .../Source/SPMSwiftHeaderWorkaround.swift | 29 +++ Package.swift | 227 +++++++++--------- .../FirebaseManifest/FirebaseManifest.swift | 2 +- 30 files changed, 264 insertions(+), 136 deletions(-) create mode 100644 FirebaseFirestoreSwift/Sources/FirebaseFirestoreSwift.swift create mode 100644 Firestore/Swift/Source/SPMSwiftHeaderWorkaround.swift diff --git a/FirebaseFirestore.podspec b/FirebaseFirestore.podspec index d846ca519bb..4caef19254b 100644 --- a/FirebaseFirestore.podspec +++ b/FirebaseFirestore.podspec @@ -51,6 +51,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, 'Firestore/core/include/**/*.{cc,mm}', 'Firestore/core/src/**/*.{cc,mm}', 'FirebaseAuth/Interop/*.h', + 'Firestore/Swift/Source/**/*.swift', ] # Internal headers that aren't necessarily globally unique. Most C++ internal @@ -89,6 +90,8 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, s.dependency 'FirebaseAppCheckInterop', '~> 10.17' s.dependency 'FirebaseCore', '~> 10.0' + s.dependency 'FirebaseCoreExtension', '~> 10.0' + s.dependency 'FirebaseSharedSwift', '~> 10.0' abseil_version = '~> 1.20220623.0' s.dependency 'abseil/algorithm', abseil_version @@ -111,6 +114,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, s.library = 'c++' s.pod_target_xcconfig = { 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++14', + 'CLANG_CXX_LIBRARY' => 'libc++', 'GCC_C_LANGUAGE_STANDARD' => 'c99', 'GCC_PREPROCESSOR_DEFINITIONS' => "FIRFirestore_VERSION=#{s.version} " + diff --git a/FirebaseFirestoreSwift.podspec b/FirebaseFirestoreSwift.podspec index d1c43768369..7920a59fbd3 100644 --- a/FirebaseFirestoreSwift.podspec +++ b/FirebaseFirestoreSwift.podspec @@ -31,12 +31,9 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, s.requires_arc = true s.source_files = [ - 'Firestore/Swift/Source/**/*.swift', + 'FirebaseFirestoreSwift/Sources/FirebaseFirestoreSwift.swift' ] - s.dependency 'FirebaseCore', '~> 10.0' - s.dependency 'FirebaseCoreExtension', '~> 10.0' - s.dependency 'FirebaseFirestore', '~> 10.0' - s.dependency 'FirebaseSharedSwift', '~> 10.0' + s.dependency 'FirebaseFirestore', '~> 10.17' end diff --git a/FirebaseFirestoreSwift/Sources/FirebaseFirestoreSwift.swift b/FirebaseFirestoreSwift/Sources/FirebaseFirestoreSwift.swift new file mode 100644 index 00000000000..9918633f67b --- /dev/null +++ b/FirebaseFirestoreSwift/Sources/FirebaseFirestoreSwift.swift @@ -0,0 +1,30 @@ +// Copyright 2023 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. + +#warning( + "All of the public API from `FirebaseFirestoreSwift` can now be accessed through the `FirebaseFirestore` module. Therefore, the `FirebaseFirestoreSwift` module is deprecated and will be removed in the future. See https://firebase.google.com/docs/ios/swift-migration for migration instructions." +) + +// The `@_exported` is needed to prevent breaking clients that are using +// types prefixed with the `FirebaseFirestoreSwift` namespace. +@_exported import enum FirebaseFirestore.DecodingFailureStrategy +@_exported import struct FirebaseFirestore.DocumentID +@_exported import protocol FirebaseFirestore.DocumentIDWrappable +@_exported import struct FirebaseFirestore.ExplicitNull +@_exported import enum FirebaseFirestore.FirestoreDecodingError +@_exported import enum FirebaseFirestore.FirestoreEncodingError +@_exported import struct FirebaseFirestore.FirestoreQuery +@_exported import enum FirebaseFirestore.QueryPredicate +@_exported import struct FirebaseFirestore.ServerTimestamp +@_exported import protocol FirebaseFirestore.ServerTimestampWrappable diff --git a/Firestore/CHANGELOG.md b/Firestore/CHANGELOG.md index 44dafdecb09..b0f68196083 100644 --- a/Firestore/CHANGELOG.md +++ b/Firestore/CHANGELOG.md @@ -1,3 +1,9 @@ +# Unreleased +- [feature] The `FirebaseFirestore` module now contains Firebase Firestore's + Swift-only APIs that were previously only available via the + `FirebaseFirestoreSwift` extension SDK. See the + `FirebaseFirestoreSwift` release note from this release for more details. + # 10.16.0 - [fixed] Fixed an issue where Firestore's binary SwiftPM distribution would not link properly when building a target for testing. This issue affected diff --git a/Firestore/Swift/CHANGELOG.md b/Firestore/Swift/CHANGELOG.md index a176d7c4e11..3ffebb7bb27 100644 --- a/Firestore/Swift/CHANGELOG.md +++ b/Firestore/Swift/CHANGELOG.md @@ -1,3 +1,10 @@ +# Unreleased +- [deprecated] All of the public API from `FirebaseFirestoreSwift` can now + be accessed through the `FirebaseFirestore` module. Therefore, + `FirebaseFirestoreSwift` has been deprecated, and will be removed in a + future release. See https://firebase.google.com/docs/ios/swift-migration for + migration instructions. + # 10.12.0 - [added] Added support animations on the `@FirestoreQuery` property wrapper. diff --git a/Firestore/Swift/Source/AsyncAwait/CollectionReference+AsyncAwait.swift b/Firestore/Swift/Source/AsyncAwait/CollectionReference+AsyncAwait.swift index 3fcb340da63..bb7cac18090 100644 --- a/Firestore/Swift/Source/AsyncAwait/CollectionReference+AsyncAwait.swift +++ b/Firestore/Swift/Source/AsyncAwait/CollectionReference+AsyncAwait.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE import Foundation #if compiler(>=5.5.2) && canImport(_Concurrency) diff --git a/Firestore/Swift/Source/AsyncAwait/Firestore+AsyncAwait.swift b/Firestore/Swift/Source/AsyncAwait/Firestore+AsyncAwait.swift index 2a09c08efab..d9cf549a15c 100644 --- a/Firestore/Swift/Source/AsyncAwait/Firestore+AsyncAwait.swift +++ b/Firestore/Swift/Source/AsyncAwait/Firestore+AsyncAwait.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE import Foundation #if compiler(>=5.5.2) && canImport(_Concurrency) diff --git a/Firestore/Swift/Source/Codable/CodablePassThroughTypes.swift b/Firestore/Swift/Source/Codable/CodablePassThroughTypes.swift index 0b6371745ac..56fceebfd4d 100644 --- a/Firestore/Swift/Source/Codable/CodablePassThroughTypes.swift +++ b/Firestore/Swift/Source/Codable/CodablePassThroughTypes.swift @@ -16,7 +16,9 @@ import Foundation import FirebaseSharedSwift -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE internal struct FirestorePassthroughTypes: StructureCodingPassthroughTypeResolver { static func isPassthroughType(_ t: T) -> Bool { diff --git a/Firestore/Swift/Source/Codable/CollectionReference+WriteEncodable.swift b/Firestore/Swift/Source/Codable/CollectionReference+WriteEncodable.swift index fe3ee5167b9..21d4d8dfc32 100644 --- a/Firestore/Swift/Source/Codable/CollectionReference+WriteEncodable.swift +++ b/Firestore/Swift/Source/Codable/CollectionReference+WriteEncodable.swift @@ -15,7 +15,9 @@ */ import Foundation -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE public extension CollectionReference { /// Encodes an instance of `Encodable` and adds a new document to this collection diff --git a/Firestore/Swift/Source/Codable/DocumentID.swift b/Firestore/Swift/Source/Codable/DocumentID.swift index fca5f8de0d8..d9abce5907b 100644 --- a/Firestore/Swift/Source/Codable/DocumentID.swift +++ b/Firestore/Swift/Source/Codable/DocumentID.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE import FirebaseSharedSwift @_implementationOnly import FirebaseCoreExtension diff --git a/Firestore/Swift/Source/Codable/DocumentReference+Codable.swift b/Firestore/Swift/Source/Codable/DocumentReference+Codable.swift index ca52fac5e63..76f6b2ceec7 100644 --- a/Firestore/Swift/Source/Codable/DocumentReference+Codable.swift +++ b/Firestore/Swift/Source/Codable/DocumentReference+Codable.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE /** Mark DocumentReference to conform to Codable. */ diff --git a/Firestore/Swift/Source/Codable/DocumentReference+ReadDecodable.swift b/Firestore/Swift/Source/Codable/DocumentReference+ReadDecodable.swift index 28e76010055..673be200d07 100644 --- a/Firestore/Swift/Source/Codable/DocumentReference+ReadDecodable.swift +++ b/Firestore/Swift/Source/Codable/DocumentReference+ReadDecodable.swift @@ -15,7 +15,9 @@ */ import Foundation -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE public extension DocumentReference { /// Fetches and decodes the document referenced by this `DocumentReference`. diff --git a/Firestore/Swift/Source/Codable/DocumentReference+WriteEncodable.swift b/Firestore/Swift/Source/Codable/DocumentReference+WriteEncodable.swift index 11fbfa18330..c9345a3867b 100644 --- a/Firestore/Swift/Source/Codable/DocumentReference+WriteEncodable.swift +++ b/Firestore/Swift/Source/Codable/DocumentReference+WriteEncodable.swift @@ -15,7 +15,9 @@ */ import Foundation -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE public extension DocumentReference { /// Encodes an instance of `Encodable` and overwrites the encoded data diff --git a/Firestore/Swift/Source/Codable/DocumentSnapshot+ReadDecodable.swift b/Firestore/Swift/Source/Codable/DocumentSnapshot+ReadDecodable.swift index ad9a10bd92a..90a637d2a9b 100644 --- a/Firestore/Swift/Source/Codable/DocumentSnapshot+ReadDecodable.swift +++ b/Firestore/Swift/Source/Codable/DocumentSnapshot+ReadDecodable.swift @@ -15,7 +15,9 @@ */ import Foundation -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE public extension DocumentSnapshot { /// Retrieves all fields in a document and converts them to an instance of diff --git a/Firestore/Swift/Source/Codable/EncoderDecoder.swift b/Firestore/Swift/Source/Codable/EncoderDecoder.swift index 3c35117222c..1e503999a39 100644 --- a/Firestore/Swift/Source/Codable/EncoderDecoder.swift +++ b/Firestore/Swift/Source/Codable/EncoderDecoder.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE import FirebaseSharedSwift import Foundation diff --git a/Firestore/Swift/Source/Codable/ExplicitNull.swift b/Firestore/Swift/Source/Codable/ExplicitNull.swift index 980093dbf0c..428c9755890 100644 --- a/Firestore/Swift/Source/Codable/ExplicitNull.swift +++ b/Firestore/Swift/Source/Codable/ExplicitNull.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE /// Wraps an `Optional` field in a `Codable` object such that when the field /// has a `nil` value it will encode to a null value in Firestore. Normally, diff --git a/Firestore/Swift/Source/Codable/FieldValue+Encodable.swift b/Firestore/Swift/Source/Codable/FieldValue+Encodable.swift index ef52b09f30f..554d86d505b 100644 --- a/Firestore/Swift/Source/Codable/FieldValue+Encodable.swift +++ b/Firestore/Swift/Source/Codable/FieldValue+Encodable.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE /** Extends FieldValue to conform to Encodable. */ extension FieldValue: Encodable { diff --git a/Firestore/Swift/Source/Codable/GeoPoint+Codable.swift b/Firestore/Swift/Source/Codable/GeoPoint+Codable.swift index 60acc2db661..befcd1235c3 100644 --- a/Firestore/Swift/Source/Codable/GeoPoint+Codable.swift +++ b/Firestore/Swift/Source/Codable/GeoPoint+Codable.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE /** * A protocol describing the encodable properties of a GeoPoint. diff --git a/Firestore/Swift/Source/Codable/ServerTimestamp.swift b/Firestore/Swift/Source/Codable/ServerTimestamp.swift index bd211a9c442..1be29446b73 100644 --- a/Firestore/Swift/Source/Codable/ServerTimestamp.swift +++ b/Firestore/Swift/Source/Codable/ServerTimestamp.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE /// A type that can initialize itself from a Firestore Timestamp, which makes /// it suitable for use with the `@ServerTimestamp` property wrapper. diff --git a/Firestore/Swift/Source/Codable/Timestamp+Codable.swift b/Firestore/Swift/Source/Codable/Timestamp+Codable.swift index 9bed88200ad..15281e6e67b 100644 --- a/Firestore/Swift/Source/Codable/Timestamp+Codable.swift +++ b/Firestore/Swift/Source/Codable/Timestamp+Codable.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE /** * A protocol describing the encodable properties of a Timestamp. diff --git a/Firestore/Swift/Source/Codable/TimestampDecodingStrategy.swift b/Firestore/Swift/Source/Codable/TimestampDecodingStrategy.swift index d72c941ac77..57d69dc4d80 100644 --- a/Firestore/Swift/Source/Codable/TimestampDecodingStrategy.swift +++ b/Firestore/Swift/Source/Codable/TimestampDecodingStrategy.swift @@ -15,7 +15,9 @@ */ import Foundation -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE import FirebaseSharedSwift public extension FirebaseDataDecoder.DateDecodingStrategy { diff --git a/Firestore/Swift/Source/Codable/TimestampEncodingStrategy.swift b/Firestore/Swift/Source/Codable/TimestampEncodingStrategy.swift index 7d1f47dc9fb..7b9bf45098c 100644 --- a/Firestore/Swift/Source/Codable/TimestampEncodingStrategy.swift +++ b/Firestore/Swift/Source/Codable/TimestampEncodingStrategy.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE import FirebaseSharedSwift import Foundation diff --git a/Firestore/Swift/Source/Codable/Transaction+WriteEncodable.swift b/Firestore/Swift/Source/Codable/Transaction+WriteEncodable.swift index 196cee6c94b..dc8d0ea9531 100644 --- a/Firestore/Swift/Source/Codable/Transaction+WriteEncodable.swift +++ b/Firestore/Swift/Source/Codable/Transaction+WriteEncodable.swift @@ -15,7 +15,9 @@ */ import Foundation -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE public extension Transaction { /// Encodes an instance of `Encodable` and overwrites the encoded data diff --git a/Firestore/Swift/Source/Codable/WriteBatch+WriteEncodable.swift b/Firestore/Swift/Source/Codable/WriteBatch+WriteEncodable.swift index 8232325d1fd..7afda568be5 100644 --- a/Firestore/Swift/Source/Codable/WriteBatch+WriteEncodable.swift +++ b/Firestore/Swift/Source/Codable/WriteBatch+WriteEncodable.swift @@ -15,7 +15,9 @@ */ import Foundation -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE public extension WriteBatch { /// Encodes an instance of `Encodable` and overwrites the encoded data diff --git a/Firestore/Swift/Source/PropertyWrapper/FirestoreQuery.swift b/Firestore/Swift/Source/PropertyWrapper/FirestoreQuery.swift index 16ca88baa27..d0663c71801 100644 --- a/Firestore/Swift/Source/PropertyWrapper/FirestoreQuery.swift +++ b/Firestore/Swift/Source/PropertyWrapper/FirestoreQuery.swift @@ -15,7 +15,9 @@ */ import SwiftUI -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE /// The strategy to use when an error occurs during mapping Firestore documents /// to the target type of `FirestoreQuery`. diff --git a/Firestore/Swift/Source/PropertyWrapper/FirestoreQueryObservable.swift b/Firestore/Swift/Source/PropertyWrapper/FirestoreQueryObservable.swift index ba1db479c9c..c1c9d35b66f 100644 --- a/Firestore/Swift/Source/PropertyWrapper/FirestoreQueryObservable.swift +++ b/Firestore/Swift/Source/PropertyWrapper/FirestoreQueryObservable.swift @@ -15,7 +15,9 @@ */ import SwiftUI -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE @available(iOS 14.0, macOS 11.0, macCatalyst 14.0, tvOS 14.0, watchOS 7.0, *) internal class FirestoreQueryObservable: ObservableObject { diff --git a/Firestore/Swift/Source/PropertyWrapper/QueryPredicate.swift b/Firestore/Swift/Source/PropertyWrapper/QueryPredicate.swift index 54779049d10..e40e10f59cc 100644 --- a/Firestore/Swift/Source/PropertyWrapper/QueryPredicate.swift +++ b/Firestore/Swift/Source/PropertyWrapper/QueryPredicate.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestore +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreInternal +#endif // SWIFT_PACKAGE /// Query predicates that can be used to filter results fetched by `FirestoreQuery`. /// diff --git a/Firestore/Swift/Source/SPMSwiftHeaderWorkaround.swift b/Firestore/Swift/Source/SPMSwiftHeaderWorkaround.swift new file mode 100644 index 00000000000..986d54e697f --- /dev/null +++ b/Firestore/Swift/Source/SPMSwiftHeaderWorkaround.swift @@ -0,0 +1,29 @@ +// Copyright 2023 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 FirebaseFirestoreInternal + + // This is a trick to force generate a `FirebaseFirestore-Swift.h` + // header that re-exports `FirebaseFirestoreInternal` for Objective-C + // clients. It is important for the below code to reference a Remote + // Config symbol defined in Objective-C as that will import the symbol's + // module (`FirebaseFirestoreInternal`) in the generated header. This + // allows Objective-C clients to import Remote Config's Objective-C API + // using `@import FirebaseFirestore;`. This API is not needed for Swift + // clients and is therefore unavailable in a Swift context. + @available(*, unavailable) + @objc public extension Firestore { + static var __no_op: () -> Void { {} } + } +#endif // SWIFT_PACKAGE diff --git a/Package.swift b/Package.swift index d3ee82b1d46..2e3ff8df4ba 100644 --- a/Package.swift +++ b/Package.swift @@ -616,13 +616,10 @@ let package = Package( dependencies: ["FirebaseDatabase", "FirebaseDatabaseSwift"], path: "FirebaseDatabaseSwift/Tests/" ), - .target( + .binaryTarget( name: "FirebaseSharedSwift", - path: "FirebaseSharedSwift/Sources", - exclude: [ - "third_party/FirebaseDataEncoder/LICENSE", - "third_party/FirebaseDataEncoder/METADATA", - ] + url: "https://dl.google.com/firebase/ios/experimental/bin/sharedswift/10.16.0/FirebaseSharedSwift.zip", + checksum: "cfa32eb16ba8fafa7a443ab8f48e019794470bb358066d6c571df1531df02fe6" ), .testTarget( name: "FirebaseSharedSwiftTests", @@ -651,7 +648,6 @@ let package = Package( ] ), firestoreWrapperTarget(), - firestoreTarget(), .target( name: "FirebaseFirestoreSwiftTarget", dependencies: [.target(name: "FirebaseFirestoreSwift", @@ -663,30 +659,9 @@ let package = Package( .target( name: "FirebaseFirestoreSwift", dependencies: [ - "FirebaseCore", - "FirebaseCoreExtension", "FirebaseFirestoreTarget", - "FirebaseSharedSwift", - ], - path: "Firestore", - exclude: [ - "CHANGELOG.md", - "CMakeLists.txt", - "Example/", - "LICENSE", - "Protos/", - "README.md", - "Source/", - "core/", - "fuzzing/", - "test.sh", - "Swift/CHANGELOG.md", - "Swift/Tests/", - "third_party/nlohmann_json", ], - sources: [ - "Swift/Source/", - ] + path: "FirebaseFirestoreSwift/Sources" ), // MARK: - Firebase Functions @@ -1304,8 +1279,7 @@ let package = Package( .headerSearchPath("../../.."), ] ), - - ], + ] + firestoreTargets(), cLanguageStandard: .c99, cxxLanguageStandard: CXXLanguageStandard.gnucxx14 ) @@ -1379,7 +1353,10 @@ func firestoreWrapperTarget() -> Target { .product(name: "abseil", package: "abseil-cpp-binary"), .product(name: "gRPC-C++", package: "grpc-binary"), .product(name: "nanopb", package: "nanopb"), + "FirebaseAppCheckInterop", "FirebaseCore", + "FirebaseCoreExtension", + "FirebaseSharedSwift", "leveldb", ], path: "SwiftPM-PlatformExclude/FirebaseFirestoreWrap", @@ -1391,89 +1368,123 @@ func firestoreWrapperTarget() -> Target { ) } -func firestoreTarget() -> Target { +func firestoreTargets() -> [Target] { if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil { - return .target( - name: "FirebaseFirestore", - dependencies: [ - "FirebaseAppCheckInterop", - "FirebaseCore", - "leveldb", - .product(name: "nanopb", package: "nanopb"), - .product(name: "abseil", package: "abseil-cpp-SwiftPM"), - .product(name: "gRPC-cpp", package: "grpc-ios"), - ], - path: "Firestore", - exclude: [ - "CHANGELOG.md", - "CMakeLists.txt", - "Example/", - "LICENSE", - "Protos/CMakeLists.txt", - "Protos/Podfile", - "Protos/README.md", - "Protos/build_protos.py", - "Protos/cpp/", - "Protos/lib/", - "Protos/nanopb_cpp_generator.py", - "Protos/protos/", - "README.md", - "Source/CMakeLists.txt", - "Swift/", - "core/CMakeLists.txt", - "core/src/util/config_detected.h.in", - "core/test/", - "fuzzing/", - "test.sh", - // Swift PM doesn't recognize hpp files, so we're relying on search paths - // to find third_party/nlohmann_json/json.hpp. - "third_party/", + return [ + .target( + name: "FirebaseFirestoreInternal", + dependencies: [ + "FirebaseAppCheckInterop", + "FirebaseCore", + "leveldb", + .product(name: "nanopb", package: "nanopb"), + .product(name: "abseil", package: "abseil-cpp-SwiftPM"), + .product(name: "gRPC-cpp", package: "grpc-ios"), + ], + path: "Firestore", + exclude: [ + "CHANGELOG.md", + "CMakeLists.txt", + "Example/", + "LICENSE", + "Protos/CMakeLists.txt", + "Protos/Podfile", + "Protos/README.md", + "Protos/build_protos.py", + "Protos/cpp/", + "Protos/lib/", + "Protos/nanopb_cpp_generator.py", + "Protos/protos/", + "README.md", + "Source/CMakeLists.txt", + "Swift/", + "core/CMakeLists.txt", + "core/src/util/config_detected.h.in", + "core/test/", + "fuzzing/", + "test.sh", + // Swift PM doesn't recognize hpp files, so we're relying on search paths + // to find third_party/nlohmann_json/json.hpp. + "third_party/", - // Exclude alternate implementations for other platforms - "core/src/remote/connectivity_monitor_noop.cc", - "core/src/util/filesystem_win.cc", - "core/src/util/log_stdio.cc", - "core/src/util/secure_random_openssl.cc", - ], - sources: [ - "Source/", - "Protos/nanopb/", - "core/include/", - "core/src", - ], - publicHeadersPath: "Source/Public", - cSettings: [ - .headerSearchPath("../"), - .headerSearchPath("Source/Public/FirebaseFirestore"), - .headerSearchPath("Protos/nanopb"), - .define("PB_FIELD_32BIT", to: "1"), - .define("PB_NO_PACKED_STRUCTS", to: "1"), - .define("PB_ENABLE_MALLOC", to: "1"), - .define("FIRFirestore_VERSION", to: firebaseVersion), - ], - linkerSettings: [ - .linkedFramework( - "SystemConfiguration", - .when(platforms: [.iOS, .macOS, .tvOS, .firebaseVisionOS]) - ), - .linkedFramework("UIKit", .when(platforms: [.iOS, .tvOS, .firebaseVisionOS])), - .linkedLibrary("c++"), - ] - ) + // Exclude alternate implementations for other platforms + "core/src/remote/connectivity_monitor_noop.cc", + "core/src/util/filesystem_win.cc", + "core/src/util/log_stdio.cc", + "core/src/util/secure_random_openssl.cc", + ], + sources: [ + "Source/", + "Protos/nanopb/", + "core/include/", + "core/src", + ], + publicHeadersPath: "Source/Public", + cSettings: [ + .headerSearchPath("../"), + .headerSearchPath("Source/Public/FirebaseFirestore"), + .headerSearchPath("Protos/nanopb"), + .define("PB_FIELD_32BIT", to: "1"), + .define("PB_NO_PACKED_STRUCTS", to: "1"), + .define("PB_ENABLE_MALLOC", to: "1"), + .define("FIRFirestore_VERSION", to: firebaseVersion), + ], + linkerSettings: [ + .linkedFramework( + "SystemConfiguration", + .when(platforms: [.iOS, .macOS, .tvOS, .firebaseVisionOS]) + ), + .linkedFramework("UIKit", .when(platforms: [.iOS, .tvOS, .firebaseVisionOS])), + .linkedLibrary("c++"), + ] + ), + .target( + name: "FirebaseFirestore", + dependencies: [ + "FirebaseCore", + "FirebaseCoreExtension", + "FirebaseFirestoreInternal", + "FirebaseSharedSwift", + ], + path: "Firestore", + exclude: [ + "CHANGELOG.md", + "CMakeLists.txt", + "Example/", + "LICENSE", + "Protos/", + "README.md", + "Source/", + "core/", + "fuzzing/", + "test.sh", + "Swift/CHANGELOG.md", + "Swift/Tests/", + "third_party/nlohmann_json", + ], + sources: [ + "Swift/Source/", + ] + ), + ] } else if ProcessInfo.processInfo.environment["FIREBASECI_USE_LOCAL_FIRESTORE_ZIP"] != nil { // This is set when running `scripts/check_firestore_symbols.sh`. - return .binaryTarget( - name: "FirebaseFirestore", - // The `xcframework` should be moved to the root of the repo. - path: "FirebaseFirestore.xcframework" - ) + return [ + .binaryTarget( + name: "FirebaseFirestore", + // The `xcframework` should be moved to the root of the repo. + path: "FirebaseFirestore.xcframework" + ), + ] } - return .binaryTarget( - name: "FirebaseFirestore", - url: "https://dl.google.com/firebase/ios/bin/firestore/10.16.0/FirebaseFirestore.zip", - checksum: "0a6616a4bbf1adb2f0a502e9ad8e5ab144a8c4993a15bb4b795bae86b66ecab8" - ) + return [ + .binaryTarget( + name: "FirebaseFirestore", + url: "https://dl.google.com/firebase/ios/experimental/bin/firestore/10.16.0/FirebaseFirestore.zip", + checksum: "62f1ce3478de5ff9672644cd545e10ac0c39ed7c411661d0136ded28489b2c12" + ), + ] } extension Platform { diff --git a/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift b/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift index 49a0a376353..3f3ffeb0cad 100755 --- a/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift +++ b/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift @@ -48,7 +48,7 @@ public let shared = Manifest( Pod("FirebaseDatabaseSwift", zip: true), Pod("FirebaseDynamicLinks", platforms: ["ios"], zip: true), Pod("FirebaseFirestore", allowWarnings: true), - Pod("FirebaseFirestoreSwift", zip: true), + Pod("FirebaseFirestoreSwift", allowWarnings: true, zip: true), Pod("FirebaseFunctions", zip: true), Pod("FirebaseInAppMessaging", isBeta: true, platforms: ["ios"]), Pod(