From 4b3a9aa03bc124de15fd5699404fb61a53b4365f Mon Sep 17 00:00:00 2001 From: wu-hui Date: Mon, 20 Jan 2025 10:52:14 -0500 Subject: [PATCH 1/4] Reorg --- .../CollectionReference+AsyncAwait.swift | 2 +- Package.swift | 43 ++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Firestore/Swift/Source/AsyncAwait/CollectionReference+AsyncAwait.swift b/Firestore/Swift/Source/AsyncAwait/CollectionReference+AsyncAwait.swift index 7fb8e307e03..fc23ce7b12d 100644 --- a/Firestore/Swift/Source/AsyncAwait/CollectionReference+AsyncAwait.swift +++ b/Firestore/Swift/Source/AsyncAwait/CollectionReference+AsyncAwait.swift @@ -15,7 +15,7 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Package.swift b/Package.swift index a2c672f8f9b..c062ab83009 100644 --- a/Package.swift +++ b/Package.swift @@ -1356,7 +1356,7 @@ func abseilDependency() -> Package.Dependency { if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil { packageInfo = ( "https://github.com/firebase/abseil-cpp-SwiftPM.git", - "0.20240116.1" ..< "0.20240117.0" + "0.20240722.0" ..< "0.20240723.0" ) } else { packageInfo = ( @@ -1374,7 +1374,7 @@ func grpcDependency() -> Package.Dependency { // If building Firestore from source, abseil will need to be built as source // as the headers in the binary version of abseil are unusable. if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil { - packageInfo = ("https://github.com/grpc/grpc-ios.git", "1.65.0" ..< "1.66.0") + packageInfo = ("https://github.com/grpc/grpc-ios.git", "1.69.0" ..< "1.70.0") } else { packageInfo = ("https://github.com/google/grpc-binary.git", "1.65.1" ..< "1.66.0") } @@ -1401,24 +1401,21 @@ func firestoreWrapperTarget() -> Target { ) } -func firebaseFirestoreCppTarget() -> Target { +func firebaseFirestoreObjCppTarget() -> Target { if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil { return .target( - name: "FirebaseFirestoreCpp", + name: "FirebaseFirestoreObjCpp", dependencies: [ "FirebaseAppCheckInterop", "FirebaseCore", - "leveldb", - "FirebaseFirestoreInternalWrapper", - .product(name: "nanopb", package: "nanopb"), - .product(name: "gRPC-cpp", package: "grpc-ios"), + "FirebaseFirestoreCpp", ], - path: "Firestore/core/interfaceForSwift", - publicHeadersPath: "api", // Path to the public headers + path: "Firestore/Source", + publicHeadersPath: "Public", // Path to the public headers cxxSettings: [ - .headerSearchPath("../../../"), - .headerSearchPath("../../Protos/nanopb"), - .headerSearchPath("api"), // Ensure the header search path is correct + .headerSearchPath("../../"), + .headerSearchPath("Public/FirebaseFirestore/"), + .headerSearchPath("../Protos/nanopb"), ] ) } else { @@ -1451,7 +1448,7 @@ func firestoreTargets() -> [Target] { if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil { return [ .target( - name: "FirebaseFirestoreInternalWrapper", + name: "FirebaseFirestoreCpp", dependencies: [ "FirebaseAppCheckInterop", "FirebaseCore", @@ -1462,6 +1459,8 @@ func firestoreTargets() -> [Target] { ], path: "Firestore", exclude: [ + // Exclude legacy objc layer + "Source/", "CHANGELOG.md", "CMakeLists.txt", "Example/", @@ -1494,15 +1493,13 @@ func firestoreTargets() -> [Target] { "core/src/util/secure_random_openssl.cc", ], sources: [ - "Source/", "Protos/nanopb/", "core/include/", "core/src", ], - publicHeadersPath: "Source/Public", + publicHeadersPath: "core/src/api", cSettings: [ .headerSearchPath("../"), - .headerSearchPath("Source/Public/FirebaseFirestore"), .headerSearchPath("Protos/nanopb"), .define("PB_FIELD_32BIT", to: "1"), .define("PB_NO_PACKED_STRUCTS", to: "1"), @@ -1518,15 +1515,15 @@ func firestoreTargets() -> [Target] { .linkedLibrary("c++"), ] ), - firebaseFirestoreCppTarget(), + firebaseFirestoreObjCppTarget(), .target( name: "FirebaseFirestore", dependencies: [ "FirebaseCore", "FirebaseCoreExtension", - "FirebaseFirestoreInternalWrapper", - "FirebaseSharedSwift", "FirebaseFirestoreCpp", + "FirebaseFirestoreObjCpp", + "FirebaseSharedSwift", ], path: "Firestore", exclude: [ @@ -1548,6 +1545,10 @@ func firestoreTargets() -> [Target] { "Swift/Source/", ], resources: [.process("Source/Resources/PrivacyInfo.xcprivacy")], + cxxSettings: [ + .headerSearchPath("../"), + .headerSearchPath("Protos/nanopb"), + ], swiftSettings: [ .interoperabilityMode(.Cxx), // C++ interoperability setting ] @@ -1619,6 +1620,6 @@ func firestoreTargets() -> [Target] { publicHeadersPath: "." ), firestoreInternalTarget, - firebaseFirestoreCppTarget(), + firebaseFirestoreObjCppTarget(), ] } From 1eefcbfe8bb483164ccdb4ec441f190bd01c2caa Mon Sep 17 00:00:00 2001 From: wu-hui Date: Tue, 21 Jan 2025 10:40:25 -0500 Subject: [PATCH 2/4] restrict public api to be interfaceForSwift only --- .../AsyncAwait/Firestore+AsyncAwait.swift | 2 +- .../Codable/CodablePassThroughTypes.swift | 2 +- .../CollectionReference+WriteEncodable.swift | 2 +- .../Swift/Source/Codable/DocumentID.swift | 2 +- .../Codable/DocumentReference+Codable.swift | 2 +- .../DocumentReference+ReadDecodable.swift | 2 +- .../DocumentReference+WriteEncodable.swift | 2 +- .../DocumentSnapshot+ReadDecodable.swift | 2 +- .../Swift/Source/Codable/EncoderDecoder.swift | 2 +- .../Swift/Source/Codable/ExplicitNull.swift | 2 +- .../Source/Codable/FieldValue+Encodable.swift | 2 +- .../Source/Codable/GeoPoint+Codable.swift | 2 +- .../Codable/Transaction+WriteEncodable.swift | 2 +- .../Source/Codable/VectorValue+Codable.swift | 2 +- .../Codable/WriteBatch+WriteEncodable.swift | 2 +- .../PropertyWrapper/FirestoreQuery.swift | 2 +- .../FirestoreQueryObservable.swift | 2 +- .../PropertyWrapper/QueryPredicate.swift | 2 +- .../Source/SwiftAPI/FieldValue+Swift.swift | 2 +- .../Swift/Source/SwiftAPI/Pipeline.swift | 2 +- .../Source/SwiftAPI/VectorValue+Swift.swift | 2 +- .../Swift/Source/SwiftHeaderWorkaround.swift | 2 +- .../api/FirebaseFirestoreCpp.h | 12 ++--- .../interfaceForSwift/api/collection_stage.h | 39 +++++++++++++++ .../api/firestore_pipeline.h | 37 +++++++++++++++ .../interfaceForSwift/api/pipeline_source.h | 47 +++++++++++++++++++ Package.swift | 2 +- 27 files changed, 152 insertions(+), 29 deletions(-) create mode 100644 Firestore/core/interfaceForSwift/api/collection_stage.h create mode 100644 Firestore/core/interfaceForSwift/api/firestore_pipeline.h create mode 100644 Firestore/core/interfaceForSwift/api/pipeline_source.h diff --git a/Firestore/Swift/Source/AsyncAwait/Firestore+AsyncAwait.swift b/Firestore/Swift/Source/AsyncAwait/Firestore+AsyncAwait.swift index d08bb8867b2..9bda74e2798 100644 --- a/Firestore/Swift/Source/AsyncAwait/Firestore+AsyncAwait.swift +++ b/Firestore/Swift/Source/AsyncAwait/Firestore+AsyncAwait.swift @@ -16,7 +16,7 @@ #if SWIFT_PACKAGE import FirebaseFirestoreCpp - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/CodablePassThroughTypes.swift b/Firestore/Swift/Source/Codable/CodablePassThroughTypes.swift index 20f5a6e8b2b..f670db47b67 100644 --- a/Firestore/Swift/Source/Codable/CodablePassThroughTypes.swift +++ b/Firestore/Swift/Source/Codable/CodablePassThroughTypes.swift @@ -20,7 +20,7 @@ import FirebaseSharedSwift import Foundation #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/CollectionReference+WriteEncodable.swift b/Firestore/Swift/Source/Codable/CollectionReference+WriteEncodable.swift index c85a1fe261f..8d5ad48b5b1 100644 --- a/Firestore/Swift/Source/Codable/CollectionReference+WriteEncodable.swift +++ b/Firestore/Swift/Source/Codable/CollectionReference+WriteEncodable.swift @@ -17,7 +17,7 @@ import Foundation #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/DocumentID.swift b/Firestore/Swift/Source/Codable/DocumentID.swift index 42c12b59092..c5c959afdb6 100644 --- a/Firestore/Swift/Source/Codable/DocumentID.swift +++ b/Firestore/Swift/Source/Codable/DocumentID.swift @@ -15,7 +15,7 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/DocumentReference+Codable.swift b/Firestore/Swift/Source/Codable/DocumentReference+Codable.swift index 98bb15b8860..60f86e11e07 100644 --- a/Firestore/Swift/Source/Codable/DocumentReference+Codable.swift +++ b/Firestore/Swift/Source/Codable/DocumentReference+Codable.swift @@ -15,7 +15,7 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/DocumentReference+ReadDecodable.swift b/Firestore/Swift/Source/Codable/DocumentReference+ReadDecodable.swift index 2d3af7a9dfa..d3903ae68a4 100644 --- a/Firestore/Swift/Source/Codable/DocumentReference+ReadDecodable.swift +++ b/Firestore/Swift/Source/Codable/DocumentReference+ReadDecodable.swift @@ -16,7 +16,7 @@ import Foundation #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/DocumentReference+WriteEncodable.swift b/Firestore/Swift/Source/Codable/DocumentReference+WriteEncodable.swift index 5fb791a2ee4..09ad159ddc0 100644 --- a/Firestore/Swift/Source/Codable/DocumentReference+WriteEncodable.swift +++ b/Firestore/Swift/Source/Codable/DocumentReference+WriteEncodable.swift @@ -16,7 +16,7 @@ import Foundation #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/DocumentSnapshot+ReadDecodable.swift b/Firestore/Swift/Source/Codable/DocumentSnapshot+ReadDecodable.swift index 21c8e1ff36f..afafac22b8b 100644 --- a/Firestore/Swift/Source/Codable/DocumentSnapshot+ReadDecodable.swift +++ b/Firestore/Swift/Source/Codable/DocumentSnapshot+ReadDecodable.swift @@ -16,7 +16,7 @@ import Foundation #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/EncoderDecoder.swift b/Firestore/Swift/Source/Codable/EncoderDecoder.swift index 29b0e57caab..9760fe266d1 100644 --- a/Firestore/Swift/Source/Codable/EncoderDecoder.swift +++ b/Firestore/Swift/Source/Codable/EncoderDecoder.swift @@ -15,7 +15,7 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/ExplicitNull.swift b/Firestore/Swift/Source/Codable/ExplicitNull.swift index 615fab9698a..c45866b08ea 100644 --- a/Firestore/Swift/Source/Codable/ExplicitNull.swift +++ b/Firestore/Swift/Source/Codable/ExplicitNull.swift @@ -15,7 +15,7 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/FieldValue+Encodable.swift b/Firestore/Swift/Source/Codable/FieldValue+Encodable.swift index cfa50a0c081..bbfebdae9e4 100644 --- a/Firestore/Swift/Source/Codable/FieldValue+Encodable.swift +++ b/Firestore/Swift/Source/Codable/FieldValue+Encodable.swift @@ -15,7 +15,7 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/GeoPoint+Codable.swift b/Firestore/Swift/Source/Codable/GeoPoint+Codable.swift index a92e4baf160..69eb0273162 100644 --- a/Firestore/Swift/Source/Codable/GeoPoint+Codable.swift +++ b/Firestore/Swift/Source/Codable/GeoPoint+Codable.swift @@ -15,7 +15,7 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/Transaction+WriteEncodable.swift b/Firestore/Swift/Source/Codable/Transaction+WriteEncodable.swift index 86fec68229f..becc389b017 100644 --- a/Firestore/Swift/Source/Codable/Transaction+WriteEncodable.swift +++ b/Firestore/Swift/Source/Codable/Transaction+WriteEncodable.swift @@ -16,7 +16,7 @@ import Foundation #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/VectorValue+Codable.swift b/Firestore/Swift/Source/Codable/VectorValue+Codable.swift index 45f3176a74a..683dfc6747e 100644 --- a/Firestore/Swift/Source/Codable/VectorValue+Codable.swift +++ b/Firestore/Swift/Source/Codable/VectorValue+Codable.swift @@ -15,7 +15,7 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/Codable/WriteBatch+WriteEncodable.swift b/Firestore/Swift/Source/Codable/WriteBatch+WriteEncodable.swift index 9434a55509e..69eaf44b902 100644 --- a/Firestore/Swift/Source/Codable/WriteBatch+WriteEncodable.swift +++ b/Firestore/Swift/Source/Codable/WriteBatch+WriteEncodable.swift @@ -16,7 +16,7 @@ import Foundation #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/PropertyWrapper/FirestoreQuery.swift b/Firestore/Swift/Source/PropertyWrapper/FirestoreQuery.swift index ff78b68e509..29c8ee73ea7 100644 --- a/Firestore/Swift/Source/PropertyWrapper/FirestoreQuery.swift +++ b/Firestore/Swift/Source/PropertyWrapper/FirestoreQuery.swift @@ -17,7 +17,7 @@ import SwiftUI #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/PropertyWrapper/FirestoreQueryObservable.swift b/Firestore/Swift/Source/PropertyWrapper/FirestoreQueryObservable.swift index 8e4c9280e87..d66f5487753 100644 --- a/Firestore/Swift/Source/PropertyWrapper/FirestoreQueryObservable.swift +++ b/Firestore/Swift/Source/PropertyWrapper/FirestoreQueryObservable.swift @@ -17,7 +17,7 @@ import SwiftUI #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/PropertyWrapper/QueryPredicate.swift b/Firestore/Swift/Source/PropertyWrapper/QueryPredicate.swift index d1bd1f7b6e8..61e4250655b 100644 --- a/Firestore/Swift/Source/PropertyWrapper/QueryPredicate.swift +++ b/Firestore/Swift/Source/PropertyWrapper/QueryPredicate.swift @@ -15,7 +15,7 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/SwiftAPI/FieldValue+Swift.swift b/Firestore/Swift/Source/SwiftAPI/FieldValue+Swift.swift index ccab6238267..3b8be007791 100644 --- a/Firestore/Swift/Source/SwiftAPI/FieldValue+Swift.swift +++ b/Firestore/Swift/Source/SwiftAPI/FieldValue+Swift.swift @@ -15,7 +15,7 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/SwiftAPI/Pipeline.swift b/Firestore/Swift/Source/SwiftAPI/Pipeline.swift index 640ecdfb278..44d68b72e5d 100644 --- a/Firestore/Swift/Source/SwiftAPI/Pipeline.swift +++ b/Firestore/Swift/Source/SwiftAPI/Pipeline.swift @@ -14,7 +14,7 @@ #if SWIFT_PACKAGE import FirebaseFirestoreCpp - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/SwiftAPI/VectorValue+Swift.swift b/Firestore/Swift/Source/SwiftAPI/VectorValue+Swift.swift index dffb35eb811..fbf1734f148 100644 --- a/Firestore/Swift/Source/SwiftAPI/VectorValue+Swift.swift +++ b/Firestore/Swift/Source/SwiftAPI/VectorValue+Swift.swift @@ -15,7 +15,7 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/Swift/Source/SwiftHeaderWorkaround.swift b/Firestore/Swift/Source/SwiftHeaderWorkaround.swift index 253beeae2bf..36a0feace0a 100644 --- a/Firestore/Swift/Source/SwiftHeaderWorkaround.swift +++ b/Firestore/Swift/Source/SwiftHeaderWorkaround.swift @@ -13,7 +13,7 @@ // limitations under the License. #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreInternalWrapper + @_exported import FirebaseFirestoreObjCpp #else @_exported import FirebaseFirestoreInternal #endif // SWIFT_PACKAGE diff --git a/Firestore/core/interfaceForSwift/api/FirebaseFirestoreCpp.h b/Firestore/core/interfaceForSwift/api/FirebaseFirestoreCpp.h index ed9cc6e6622..5e390c446a9 100644 --- a/Firestore/core/interfaceForSwift/api/FirebaseFirestoreCpp.h +++ b/Firestore/core/interfaceForSwift/api/FirebaseFirestoreCpp.h @@ -17,11 +17,11 @@ #ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIREBASEFIRESTORECPP_H_ #define FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIREBASEFIRESTORECPP_H_ -#import "CollectionStage.h" -#import "FirestorePipeline.h" -#import "Pipeline.h" -#import "PipelineResult.h" -#import "PipelineSource.h" -#import "Stage.h" +#import "Firestore/core/interfaceForSwift/api/collection_stage.h" +#import "Firestore/core/interfaceForSwift/api/firestore_pipeline.h" +#import "Firestore/core/interfaceForSwift/api/pipeline.h" +#import "Firestore/core/interfaceForSwift/api/pipeline_result.h" +#import "Firestore/core/interfaceForSwift/api/pipeline_source.h" +#import "Firestore/core/interfaceForSwift/api/stage.h" #endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIREBASEFIRESTORECPP_H_ diff --git a/Firestore/core/interfaceForSwift/api/collection_stage.h b/Firestore/core/interfaceForSwift/api/collection_stage.h new file mode 100644 index 00000000000..8ef9448e830 --- /dev/null +++ b/Firestore/core/interfaceForSwift/api/collection_stage.h @@ -0,0 +1,39 @@ +// Copyright 2025 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. + +#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_COLLECTION_STAGE_H_ +#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_COLLECTION_STAGE_H_ + +#include +#include "Firestore/core/interfaceForSwift/api/stage.h" + +namespace firebase { +namespace firestore { + +namespace api { + +class Collection : public Stage { + public: + explicit Collection(std::string collection_path); + + private: + std::string collection_path_; +}; + +} // namespace api + +} // namespace firestore +} // namespace firebase + +#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_COLLECTION_STAGE_H_ diff --git a/Firestore/core/interfaceForSwift/api/firestore_pipeline.h b/Firestore/core/interfaceForSwift/api/firestore_pipeline.h new file mode 100644 index 00000000000..4561bac7c94 --- /dev/null +++ b/Firestore/core/interfaceForSwift/api/firestore_pipeline.h @@ -0,0 +1,37 @@ +// Copyright 2025 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. + +#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTORE_PIPELINE_H_ +#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTORE_PIPELINE_H_ + +#include + +#include "Firestore/core/interfaceForSwift/api/pipeline_source.h" + +namespace firebase { +namespace firestore { + +namespace api { +class Firestore; + +class FirestorePipeline { + public: + static PipelineSource pipeline(std::shared_ptr firestore); +}; + +} // namespace api +} // namespace firestore +} // namespace firebase + +#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTORE_PIPELINE_H_ diff --git a/Firestore/core/interfaceForSwift/api/pipeline_source.h b/Firestore/core/interfaceForSwift/api/pipeline_source.h new file mode 100644 index 00000000000..d235592d14d --- /dev/null +++ b/Firestore/core/interfaceForSwift/api/pipeline_source.h @@ -0,0 +1,47 @@ +// Copyright 2025 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. + +#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_SOURCE_H_ +#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_SOURCE_H_ + +#include +#include +#include + +#include "Firestore/core/interfaceForSwift/api/pipeline.h" + +namespace firebase { +namespace firestore { + +namespace api { + +class Firestore; +class DocumentReference; + +class PipelineSource { + public: + explicit PipelineSource(std::shared_ptr firestore); + + Pipeline GetCollection(std::string collection_path) const; + + private: + std::shared_ptr firestore_; +}; + +} // namespace api + +} // namespace firestore +} // namespace firebase + +#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_SOURCE_H_ diff --git a/Package.swift b/Package.swift index c062ab83009..526e1e5f86f 100644 --- a/Package.swift +++ b/Package.swift @@ -1497,7 +1497,7 @@ func firestoreTargets() -> [Target] { "core/include/", "core/src", ], - publicHeadersPath: "core/src/api", + publicHeadersPath: "core/interfaceForSwift", cSettings: [ .headerSearchPath("../"), .headerSearchPath("Protos/nanopb"), From 31ba446d346c84403573601369b492be7c8bc672 Mon Sep 17 00:00:00 2001 From: wu-hui Date: Wed, 22 Jan 2025 10:49:52 -0500 Subject: [PATCH 3/4] Hack to use local absl and remove gtest.h headers --- Package.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 526e1e5f86f..461572329a1 100644 --- a/Package.swift +++ b/Package.swift @@ -1358,14 +1358,17 @@ func abseilDependency() -> Package.Dependency { "https://github.com/firebase/abseil-cpp-SwiftPM.git", "0.20240722.0" ..< "0.20240723.0" ) + // return .package(url: packageInfo.url, packageInfo.range) + return .package(name: "abseil-cpp-SwiftPM", + path: "/Users/wuandy/projects/abseil-cpp-SwiftPM") } else { packageInfo = ( "https://github.com/google/abseil-cpp-binary.git", "1.2024011602.0" ..< "1.2024011700.0" ) + return .package(url: packageInfo.url, packageInfo.range) } - return .package(url: packageInfo.url, packageInfo.range) } func grpcDependency() -> Package.Dependency { From d25aca4d43fbc598794f034bfb2f7871a33a4a3a Mon Sep 17 00:00:00 2001 From: wu-hui Date: Wed, 22 Jan 2025 12:18:34 -0500 Subject: [PATCH 4/4] consolidate public headers into one place --- FirebaseFirestore.podspec | 1 + FirebaseFirestoreInternal.podspec | 5 +- .../Firestore_IntegrationTests_macOS.xcscheme | 22 ++++----- .../FirebaseFirestore/FirebaseFirestore.h | 1 - .../interfaceForSwift/api/CollectionStage.h | 39 --------------- .../interfaceForSwift/api/FirestorePipeline.h | 37 --------------- .../interfaceForSwift/api/PipelineSource.h | 47 ------------------- .../src/api}/FIRCallbackWrapper.h | 28 ++++++----- .../src/api}/FIRCallbackWrapper.mm | 28 ++++++----- .../api/FirebaseFirestoreCpp.h | 19 ++++---- .../api/collection_stage.cc} | 2 +- .../api/collection_stage.h | 8 ++-- Firestore/core/src/api/firestore.h | 2 +- .../api/firestore_pipeline.cc} | 2 +- .../api/firestore_pipeline.h | 8 ++-- .../api/Pipeline.cc => src/api/pipeline.cc} | 7 +-- .../api/Pipeline.h => src/api/pipeline.h} | 10 ++-- .../api/pipeline_result.cc} | 4 +- .../api/pipeline_result.h} | 6 +-- .../api/pipeline_source.cc} | 4 +- .../api/pipeline_source.h | 8 ++-- .../api/Stage.cc => src/api/stage.cc} | 2 +- .../api/Stage.h => src/api/stage.h} | 6 +-- Package.swift | 10 ++-- scripts/sync_project.rb | 3 ++ 25 files changed, 94 insertions(+), 215 deletions(-) delete mode 100644 Firestore/core/interfaceForSwift/api/CollectionStage.h delete mode 100644 Firestore/core/interfaceForSwift/api/FirestorePipeline.h delete mode 100644 Firestore/core/interfaceForSwift/api/PipelineSource.h rename Firestore/{Source/Public/FirebaseFirestore => core/src/api}/FIRCallbackWrapper.h (64%) rename Firestore/{Source/API => core/src/api}/FIRCallbackWrapper.mm (66%) rename Firestore/core/{interfaceForSwift => src}/api/FirebaseFirestoreCpp.h (50%) rename Firestore/core/{interfaceForSwift/api/CollectionStage.cc => src/api/collection_stage.cc} (93%) rename Firestore/core/{interfaceForSwift => src}/api/collection_stage.h (77%) rename Firestore/core/{interfaceForSwift/api/FirestorePipeline.cc => src/api/firestore_pipeline.cc} (93%) rename Firestore/core/{interfaceForSwift => src}/api/firestore_pipeline.h (76%) rename Firestore/core/{interfaceForSwift/api/Pipeline.cc => src/api/pipeline.cc} (95%) rename Firestore/core/{interfaceForSwift/api/Pipeline.h => src/api/pipeline.h} (85%) rename Firestore/core/{interfaceForSwift/api/PipelineResult.cc => src/api/pipeline_result.cc} (94%) rename Firestore/core/{interfaceForSwift/api/PipelineResult.h => src/api/pipeline_result.h} (87%) rename Firestore/core/{interfaceForSwift/api/PipelineSource.cc => src/api/pipeline_source.cc} (89%) rename Firestore/core/{interfaceForSwift => src}/api/pipeline_source.h (80%) rename Firestore/core/{interfaceForSwift/api/Stage.cc => src/api/stage.cc} (92%) rename Firestore/core/{interfaceForSwift/api/Stage.h => src/api/stage.h} (82%) diff --git a/FirebaseFirestore.podspec b/FirebaseFirestore.podspec index 9f9efbb0fe1..baafa371488 100644 --- a/FirebaseFirestore.podspec +++ b/FirebaseFirestore.podspec @@ -35,6 +35,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, s.pod_target_xcconfig = { # Enables C++ <-> Swift interop (by default it's only C) "SWIFT_OBJC_INTEROP_MODE" => "objcxx", + 'HEADER_SEARCH_PATHS' => '${PODS_TARGET_SRCROOT} "${PODS_TARGET_SRCROOT}/Firestore/core/src/api"' } s.resource_bundles = { diff --git a/FirebaseFirestoreInternal.podspec b/FirebaseFirestoreInternal.podspec index fa8de69cdd1..a3e0c6062da 100644 --- a/FirebaseFirestoreInternal.podspec +++ b/FirebaseFirestoreInternal.podspec @@ -30,7 +30,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, # framework. s.public_header_files = [ 'Firestore/Source/Public/FirebaseFirestore/*.h', - 'Firestore/core/interfaceForSwift/api/*.h' + 'Firestore/core/src/api/FirebaseFirestoreCpp.h' ] # source_files contains most of the header and source files for the project. @@ -54,8 +54,8 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, 'Firestore/Protos/nanopb/**/*.cc', 'Firestore/core/include/**/*.{cc,mm}', 'Firestore/core/src/**/*.{cc,mm}', + 'Firestore/core/src/api/*.{cc,mm}', 'FirebaseAuth/Interop/**/*.h', - 'Firestore/core/interfaceForSwift/**/*.{cc,h}', ] # Internal headers that aren't necessarily globally unique. Most C++ internal @@ -132,6 +132,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, 'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}" ' + '"${PODS_TARGET_SRCROOT}/Firestore/Source/Public" ' + + '"${PODS_TARGET_SRCROOT}/Firestore/core/src/api" ' + '"${PODS_ROOT}/nanopb" ' + '"${PODS_TARGET_SRCROOT}/Firestore/Protos/nanopb"' } diff --git a/Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_IntegrationTests_macOS.xcscheme b/Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_IntegrationTests_macOS.xcscheme index 809a72983a5..b6e7d07944b 100644 --- a/Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_IntegrationTests_macOS.xcscheme +++ b/Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_IntegrationTests_macOS.xcscheme @@ -27,6 +27,15 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + @@ -39,17 +48,6 @@ - - - - - - - - -#include "Stage.h" - -namespace firebase { -namespace firestore { - -namespace api { - -class Collection : public Stage { - public: - explicit Collection(std::string collection_path); - - private: - std::string collection_path_; -}; - -} // namespace api - -} // namespace firestore -} // namespace firebase - -#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_COLLECTIONSTAGE_H_ diff --git a/Firestore/core/interfaceForSwift/api/FirestorePipeline.h b/Firestore/core/interfaceForSwift/api/FirestorePipeline.h deleted file mode 100644 index 86bec3cf952..00000000000 --- a/Firestore/core/interfaceForSwift/api/FirestorePipeline.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2025 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. - -#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTOREPIPELINE_H_ -#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTOREPIPELINE_H_ - -#include - -#include "PipelineSource.h" - -namespace firebase { -namespace firestore { - -namespace api { -class Firestore; - -class FirestorePipeline { - public: - static PipelineSource pipeline(std::shared_ptr firestore); -}; - -} // namespace api -} // namespace firestore -} // namespace firebase - -#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTOREPIPELINE_H_ diff --git a/Firestore/core/interfaceForSwift/api/PipelineSource.h b/Firestore/core/interfaceForSwift/api/PipelineSource.h deleted file mode 100644 index c4d072230bf..00000000000 --- a/Firestore/core/interfaceForSwift/api/PipelineSource.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2025 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. - -#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINESOURCE_H_ -#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINESOURCE_H_ - -#include -#include -#include - -#include "Pipeline.h" - -namespace firebase { -namespace firestore { - -namespace api { - -class Firestore; -class DocumentReference; - -class PipelineSource { - public: - explicit PipelineSource(std::shared_ptr firestore); - - Pipeline GetCollection(std::string collection_path) const; - - private: - std::shared_ptr firestore_; -}; - -} // namespace api - -} // namespace firestore -} // namespace firebase - -#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINESOURCE_H_ diff --git a/Firestore/Source/Public/FirebaseFirestore/FIRCallbackWrapper.h b/Firestore/core/src/api/FIRCallbackWrapper.h similarity index 64% rename from Firestore/Source/Public/FirebaseFirestore/FIRCallbackWrapper.h rename to Firestore/core/src/api/FIRCallbackWrapper.h index 97c4646e4e1..11bee7b585b 100644 --- a/Firestore/Source/Public/FirebaseFirestore/FIRCallbackWrapper.h +++ b/Firestore/core/src/api/FIRCallbackWrapper.h @@ -14,6 +14,9 @@ * limitations under the License. */ +#ifndef FIRESTORE_CORE_SRC_API_FIRCALLBACKWRAPPER_H_ +#define FIRESTORE_CORE_SRC_API_FIRCALLBACKWRAPPER_H_ + #import #if defined(__cplusplus) @@ -26,15 +29,12 @@ namespace api { class Firestore; class PipelineResult; } // namespace api - namespace core { template class EventListener; } // namespace core - } // namespace firestore } // namespace firebase - namespace api = firebase::firestore::api; namespace core = firebase::firestore::core; @@ -42,24 +42,30 @@ NS_ASSUME_NONNULL_BEGIN typedef api::PipelineResult CppPipelineResult; -typedef void (^PipelineBlock)(CppPipelineResult *_Nullable result, NSError *_Nullable error) +typedef void (^PipelineBlock)(CppPipelineResult* _Nullable result, + NSError* _Nullable error) NS_SWIFT_UNAVAILABLE("Use Swift's closure syntax instead."); NS_SWIFT_SENDABLE NS_SWIFT_NAME(CallbackWrapper) @interface FIRCallbackWrapper : NSObject -// Note: Marking callbacks in callback-based APIs as `Sendable` can help prevent crashes when they -// are invoked on a different thread than the one they were originally defined in. If this callback -// is expected to be called on a different thread, it should be marked as `Sendable` to ensure -// thread safety. +// Note: Marking callbacks in callback-based APIs as `Sendable` can help prevent +// crashes when they are invoked on a different thread than the one they were +// originally defined in. If this callback is expected to be called on a +// different thread, it should be marked as `Sendable` to ensure thread safety. + (std::shared_ptr>) + // NOLINTNEXTLINE(whitespace/parens) wrapPipelineCallback:(std::shared_ptr)firestore - completion:(void (^NS_SWIFT_SENDABLE)(CppPipelineResult *_Nullable result, - NSError *_Nullable error))completion + // NOLINTNEXTLINE(whitespace/parens) + completion:(void (^NS_SWIFT_SENDABLE)( + CppPipelineResult* _Nullable result, + NSError* _Nullable error))completion NS_SWIFT_NAME(wrapPipelineCallback(firestore:completion:)); @end NS_ASSUME_NONNULL_END -#endif +#endif // defined(__cplusplus) + +#endif // FIRESTORE_CORE_SRC_API_FIRCALLBACKWRAPPER_H_ diff --git a/Firestore/Source/API/FIRCallbackWrapper.mm b/Firestore/core/src/api/FIRCallbackWrapper.mm similarity index 66% rename from Firestore/Source/API/FIRCallbackWrapper.mm rename to Firestore/core/src/api/FIRCallbackWrapper.mm index cf6a8aa0c8b..f0ad0571af8 100644 --- a/Firestore/Source/API/FIRCallbackWrapper.mm +++ b/Firestore/core/src/api/FIRCallbackWrapper.mm @@ -20,8 +20,8 @@ #include #include -#include "Firestore/core/interfaceForSwift/api/Pipeline.h" -#include "Firestore/core/interfaceForSwift/api/PipelineResult.h" +#include "Firestore/core/src/api/pipeline.h" +#include "Firestore/core/src/api/pipeline_result.h" #include "Firestore/core/src/core/event_listener.h" #include "Firestore/core/src/util/error_apple.h" #include "Firestore/core/src/util/statusor.h" @@ -34,18 +34,22 @@ @implementation FIRCallbackWrapper -// In public Swift documentation for integrating Swift and C++, using raw pointers in C++ is -// generally considered unsafe. However, during an experiment where the result was passed as a value -// instead of a pointer, a double free error occurred. This issue could not be traced effectively -// because the implementation resides within the Swift-C++ transition layer. In this specific use -// case, the C++ OnEvent() scope is destroyed after the Swift callback has been destroyed. Due to -// this ordering, using a raw pointer is a safe workaround for now. -+ (PipelineSnapshotListener)wrapPipelineCallback:(std::shared_ptr)firestore - completion:(void (^)(CppPipelineResult *_Nullable result, - NSError *_Nullable error))completion { +// In public Swift documentation for integrating Swift and C++, using raw +// pointers in C++ is generally considered unsafe. However, during an experiment +// where the result was passed as a value instead of a pointer, a double free +// error occurred. This issue could not be traced effectively because the +// implementation resides within the Swift-C++ transition layer. In this +// specific use case, the C++ OnEvent() scope is destroyed after the Swift +// callback has been destroyed. Due to this ordering, using a raw pointer is a +// safe workaround for now. ++ (PipelineSnapshotListener) + wrapPipelineCallback:(std::shared_ptr)firestore + completion:(void (^)(CppPipelineResult* _Nullable result, + NSError* _Nullable error))completion { class Converter : public EventListener { public: - explicit Converter(std::shared_ptr firestore, PipelineBlock completion) + explicit Converter(std::shared_ptr firestore, + PipelineBlock completion) : firestore_(firestore), completion_(completion) { } diff --git a/Firestore/core/interfaceForSwift/api/FirebaseFirestoreCpp.h b/Firestore/core/src/api/FirebaseFirestoreCpp.h similarity index 50% rename from Firestore/core/interfaceForSwift/api/FirebaseFirestoreCpp.h rename to Firestore/core/src/api/FirebaseFirestoreCpp.h index 5e390c446a9..a3d46715a68 100644 --- a/Firestore/core/interfaceForSwift/api/FirebaseFirestoreCpp.h +++ b/Firestore/core/src/api/FirebaseFirestoreCpp.h @@ -14,14 +14,15 @@ * limitations under the License. */ -#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIREBASEFIRESTORECPP_H_ -#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIREBASEFIRESTORECPP_H_ +#ifndef FIRESTORE_CORE_SRC_API_FIREBASEFIRESTORECPP_H_ +#define FIRESTORE_CORE_SRC_API_FIREBASEFIRESTORECPP_H_ -#import "Firestore/core/interfaceForSwift/api/collection_stage.h" -#import "Firestore/core/interfaceForSwift/api/firestore_pipeline.h" -#import "Firestore/core/interfaceForSwift/api/pipeline.h" -#import "Firestore/core/interfaceForSwift/api/pipeline_result.h" -#import "Firestore/core/interfaceForSwift/api/pipeline_source.h" -#import "Firestore/core/interfaceForSwift/api/stage.h" +#import "Firestore/core/src/api/FIRCallbackWrapper.h" +#import "Firestore/core/src/api/collection_stage.h" +#import "Firestore/core/src/api/firestore_pipeline.h" +#import "Firestore/core/src/api/pipeline.h" +#import "Firestore/core/src/api/pipeline_result.h" +#import "Firestore/core/src/api/pipeline_source.h" +#import "Firestore/core/src/api/stage.h" -#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIREBASEFIRESTORECPP_H_ +#endif // FIRESTORE_CORE_SRC_API_FIREBASEFIRESTORECPP_H_ diff --git a/Firestore/core/interfaceForSwift/api/CollectionStage.cc b/Firestore/core/src/api/collection_stage.cc similarity index 93% rename from Firestore/core/interfaceForSwift/api/CollectionStage.cc rename to Firestore/core/src/api/collection_stage.cc index f8e5976a62e..60f95ecc4e6 100644 --- a/Firestore/core/interfaceForSwift/api/CollectionStage.cc +++ b/Firestore/core/src/api/collection_stage.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "Firestore/core/interfaceForSwift/api/CollectionStage.h" +#include "Firestore/core/src/api/collection_stage.h" #include namespace firebase { diff --git a/Firestore/core/interfaceForSwift/api/collection_stage.h b/Firestore/core/src/api/collection_stage.h similarity index 77% rename from Firestore/core/interfaceForSwift/api/collection_stage.h rename to Firestore/core/src/api/collection_stage.h index 8ef9448e830..02331926d50 100644 --- a/Firestore/core/interfaceForSwift/api/collection_stage.h +++ b/Firestore/core/src/api/collection_stage.h @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_COLLECTION_STAGE_H_ -#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_COLLECTION_STAGE_H_ +#ifndef FIRESTORE_CORE_SRC_API_COLLECTION_STAGE_H_ +#define FIRESTORE_CORE_SRC_API_COLLECTION_STAGE_H_ #include -#include "Firestore/core/interfaceForSwift/api/stage.h" +#include "Firestore/core/src/api/stage.h" namespace firebase { namespace firestore { @@ -36,4 +36,4 @@ class Collection : public Stage { } // namespace firestore } // namespace firebase -#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_COLLECTION_STAGE_H_ +#endif // FIRESTORE_CORE_SRC_API_COLLECTION_STAGE_H_ diff --git a/Firestore/core/src/api/firestore.h b/Firestore/core/src/api/firestore.h index aca18075ce5..0547c88c728 100644 --- a/Firestore/core/src/api/firestore.h +++ b/Firestore/core/src/api/firestore.h @@ -21,9 +21,9 @@ #include #include -#include "Firestore/core/interfaceForSwift/api/PipelineSource.h" #include "Firestore/core/src/api/api_fwd.h" #include "Firestore/core/src/api/load_bundle_task.h" +#include "Firestore/core/src/api/pipeline_source.h" #include "Firestore/core/src/api/settings.h" #include "Firestore/core/src/core/core_fwd.h" #include "Firestore/core/src/credentials/credentials_fwd.h" diff --git a/Firestore/core/interfaceForSwift/api/FirestorePipeline.cc b/Firestore/core/src/api/firestore_pipeline.cc similarity index 93% rename from Firestore/core/interfaceForSwift/api/FirestorePipeline.cc rename to Firestore/core/src/api/firestore_pipeline.cc index 3d06f049eef..13c7d8063d1 100644 --- a/Firestore/core/interfaceForSwift/api/FirestorePipeline.cc +++ b/Firestore/core/src/api/firestore_pipeline.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "Firestore/core/interfaceForSwift/api/FirestorePipeline.h" +#include "Firestore/core/src/api/firestore_pipeline.h" #include diff --git a/Firestore/core/interfaceForSwift/api/firestore_pipeline.h b/Firestore/core/src/api/firestore_pipeline.h similarity index 76% rename from Firestore/core/interfaceForSwift/api/firestore_pipeline.h rename to Firestore/core/src/api/firestore_pipeline.h index 4561bac7c94..b6d91960cd3 100644 --- a/Firestore/core/interfaceForSwift/api/firestore_pipeline.h +++ b/Firestore/core/src/api/firestore_pipeline.h @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTORE_PIPELINE_H_ -#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTORE_PIPELINE_H_ +#ifndef FIRESTORE_CORE_SRC_API_FIRESTORE_PIPELINE_H_ +#define FIRESTORE_CORE_SRC_API_FIRESTORE_PIPELINE_H_ #include -#include "Firestore/core/interfaceForSwift/api/pipeline_source.h" +#include "Firestore/core/src/api/pipeline_source.h" namespace firebase { namespace firestore { @@ -34,4 +34,4 @@ class FirestorePipeline { } // namespace firestore } // namespace firebase -#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_FIRESTORE_PIPELINE_H_ +#endif // FIRESTORE_CORE_SRC_API_FIRESTORE_PIPELINE_H_ diff --git a/Firestore/core/interfaceForSwift/api/Pipeline.cc b/Firestore/core/src/api/pipeline.cc similarity index 95% rename from Firestore/core/interfaceForSwift/api/Pipeline.cc rename to Firestore/core/src/api/pipeline.cc index 63193ecdbb0..d423680be37 100644 --- a/Firestore/core/interfaceForSwift/api/Pipeline.cc +++ b/Firestore/core/src/api/pipeline.cc @@ -12,15 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "Firestore/core/interfaceForSwift/api/Pipeline.h" - -#include -#include +#include "Firestore/core/src/api/pipeline.h" #include "Firestore/core/include/firebase/firestore/timestamp.h" -#include "Firestore/core/interfaceForSwift/api/PipelineResult.h" #include "Firestore/core/src/api/firestore.h" #include "Firestore/core/src/api/listener_registration.h" +#include "Firestore/core/src/api/pipeline_result.h" #include "Firestore/core/src/api/source.h" #include "Firestore/core/src/core/event_listener.h" #include "Firestore/core/src/core/listen_options.h" diff --git a/Firestore/core/interfaceForSwift/api/Pipeline.h b/Firestore/core/src/api/pipeline.h similarity index 85% rename from Firestore/core/interfaceForSwift/api/Pipeline.h rename to Firestore/core/src/api/pipeline.h index cd718545b4a..5f26df400ef 100644 --- a/Firestore/core/interfaceForSwift/api/Pipeline.h +++ b/Firestore/core/src/api/pipeline.h @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_H_ -#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_H_ +#ifndef FIRESTORE_CORE_SRC_API_PIPELINE_H_ +#define FIRESTORE_CORE_SRC_API_PIPELINE_H_ #include #include #include -#include "PipelineResult.h" -#include "Stage.h" +#include "Firestore/core/src/api/pipeline_result.h" +#include "Firestore/core/src/api/stage.h" namespace firebase { namespace firestore { @@ -57,4 +57,4 @@ class Pipeline { } // namespace firestore } // namespace firebase -#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_H_ +#endif // FIRESTORE_CORE_SRC_API_PIPELINE_H_ diff --git a/Firestore/core/interfaceForSwift/api/PipelineResult.cc b/Firestore/core/src/api/pipeline_result.cc similarity index 94% rename from Firestore/core/interfaceForSwift/api/PipelineResult.cc rename to Firestore/core/src/api/pipeline_result.cc index d8f8323645a..2b83b03e1dd 100644 --- a/Firestore/core/interfaceForSwift/api/PipelineResult.cc +++ b/Firestore/core/src/api/pipeline_result.cc @@ -12,10 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - +#include "Firestore/core/src/api/pipeline_result.h" #include "Firestore/core/include/firebase/firestore/timestamp.h" -#include "Firestore/core/interfaceForSwift/api/PipelineResult.h" namespace firebase { namespace firestore { diff --git a/Firestore/core/interfaceForSwift/api/PipelineResult.h b/Firestore/core/src/api/pipeline_result.h similarity index 87% rename from Firestore/core/interfaceForSwift/api/PipelineResult.h rename to Firestore/core/src/api/pipeline_result.h index 830566d0375..edd365b4218 100644 --- a/Firestore/core/interfaceForSwift/api/PipelineResult.h +++ b/Firestore/core/src/api/pipeline_result.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINERESULT_H_ -#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINERESULT_H_ +#ifndef FIRESTORE_CORE_SRC_API_PIPELINE_RESULT_H_ +#define FIRESTORE_CORE_SRC_API_PIPELINE_RESULT_H_ #include @@ -48,4 +48,4 @@ class PipelineResult { } // namespace firestore } // namespace firebase -#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINERESULT_H_ +#endif // FIRESTORE_CORE_SRC_API_PIPELINE_RESULT_H_ diff --git a/Firestore/core/interfaceForSwift/api/PipelineSource.cc b/Firestore/core/src/api/pipeline_source.cc similarity index 89% rename from Firestore/core/interfaceForSwift/api/PipelineSource.cc rename to Firestore/core/src/api/pipeline_source.cc index f744a2cb15d..51aa16c47ab 100644 --- a/Firestore/core/interfaceForSwift/api/PipelineSource.cc +++ b/Firestore/core/src/api/pipeline_source.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "Firestore/core/interfaceForSwift/api/PipelineSource.h" +#include "Firestore/core/src/api/pipeline_source.h" #include -#include "Firestore/core/interfaceForSwift/api/CollectionStage.h" +#include "Firestore/core/src/api/collection_stage.h" #include "Firestore/core/src/api/document_reference.h" #include "Firestore/core/src/api/firestore.h" diff --git a/Firestore/core/interfaceForSwift/api/pipeline_source.h b/Firestore/core/src/api/pipeline_source.h similarity index 80% rename from Firestore/core/interfaceForSwift/api/pipeline_source.h rename to Firestore/core/src/api/pipeline_source.h index d235592d14d..a3fc008d6ec 100644 --- a/Firestore/core/interfaceForSwift/api/pipeline_source.h +++ b/Firestore/core/src/api/pipeline_source.h @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_SOURCE_H_ -#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_SOURCE_H_ +#ifndef FIRESTORE_CORE_SRC_API_PIPELINE_SOURCE_H_ +#define FIRESTORE_CORE_SRC_API_PIPELINE_SOURCE_H_ #include #include #include -#include "Firestore/core/interfaceForSwift/api/pipeline.h" +#include "Firestore/core/src/api/pipeline.h" namespace firebase { namespace firestore { @@ -44,4 +44,4 @@ class PipelineSource { } // namespace firestore } // namespace firebase -#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_PIPELINE_SOURCE_H_ +#endif // FIRESTORE_CORE_SRC_API_PIPELINE_SOURCE_H_ diff --git a/Firestore/core/interfaceForSwift/api/Stage.cc b/Firestore/core/src/api/stage.cc similarity index 92% rename from Firestore/core/interfaceForSwift/api/Stage.cc rename to Firestore/core/src/api/stage.cc index 15a51380a50..551ca8f2fa5 100644 --- a/Firestore/core/interfaceForSwift/api/Stage.cc +++ b/Firestore/core/src/api/stage.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "Firestore/core/interfaceForSwift/api/Stage.h" +#include "Firestore/core/src/api/stage.h" namespace firebase { namespace firestore { diff --git a/Firestore/core/interfaceForSwift/api/Stage.h b/Firestore/core/src/api/stage.h similarity index 82% rename from Firestore/core/interfaceForSwift/api/Stage.h rename to Firestore/core/src/api/stage.h index b9a8e83e112..53711a82166 100644 --- a/Firestore/core/interfaceForSwift/api/Stage.h +++ b/Firestore/core/src/api/stage.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef FIRESTORE_CORE_INTERFACEFORSWIFT_API_STAGE_H_ -#define FIRESTORE_CORE_INTERFACEFORSWIFT_API_STAGE_H_ +#ifndef FIRESTORE_CORE_SRC_API_STAGE_H_ +#define FIRESTORE_CORE_SRC_API_STAGE_H_ namespace firebase { namespace firestore { @@ -30,4 +30,4 @@ class Stage { } // namespace firestore } // namespace firebase -#endif // FIRESTORE_CORE_INTERFACEFORSWIFT_API_STAGE_H_ +#endif // FIRESTORE_CORE_SRC_API_STAGE_H_ diff --git a/Package.swift b/Package.swift index 461572329a1..559ac912cea 100644 --- a/Package.swift +++ b/Package.swift @@ -1356,19 +1356,16 @@ func abseilDependency() -> Package.Dependency { if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil { packageInfo = ( "https://github.com/firebase/abseil-cpp-SwiftPM.git", - "0.20240722.0" ..< "0.20240723.0" + "0.20240722.2" ..< "0.20240723.0" ) - // return .package(url: packageInfo.url, packageInfo.range) - return .package(name: "abseil-cpp-SwiftPM", - path: "/Users/wuandy/projects/abseil-cpp-SwiftPM") } else { packageInfo = ( "https://github.com/google/abseil-cpp-binary.git", "1.2024011602.0" ..< "1.2024011700.0" ) - return .package(url: packageInfo.url, packageInfo.range) } + return .package(url: packageInfo.url, packageInfo.range) } func grpcDependency() -> Package.Dependency { @@ -1482,7 +1479,6 @@ func firestoreTargets() -> [Target] { "core/CMakeLists.txt", "core/src/util/config_detected.h.in", "core/test/", - "core/interfaceForSwift/", "fuzzing/", "test.sh", // Swift PM doesn't recognize hpp files, so we're relying on search paths @@ -1500,7 +1496,7 @@ func firestoreTargets() -> [Target] { "core/include/", "core/src", ], - publicHeadersPath: "core/interfaceForSwift", + publicHeadersPath: "core/src/api", cSettings: [ .headerSearchPath("../"), .headerSearchPath("Protos/nanopb"), diff --git a/scripts/sync_project.rb b/scripts/sync_project.rb index fdf03f8d33f..ecc47709274 100755 --- a/scripts/sync_project.rb +++ b/scripts/sync_project.rb @@ -111,6 +111,9 @@ def sync_firestore(test_only) # Make public headers available as "FIRQuery.h" '"${PODS_ROOT}/../../../Firestore/Source/Public/FirebaseFirestore"', + # Make public headers available as "FirebaseFirestoreCpp.h" + '"${PODS_ROOT}/../../../Firestore/core/src/api"', + # Generated protobuf and nanopb output expects to search relative to the # output path. '"${PODS_ROOT}/../../../Firestore/Protos/cpp"',