Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore Swift Cpp Experiment #13956

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
163cbdd
init
cherylEnkidu Oct 23, 2024
6350734
bug fix
cherylEnkidu Oct 23, 2024
19cdc82
add extern c
cherylEnkidu Oct 24, 2024
be5efcf
public init
cherylEnkidu Oct 28, 2024
d89a70b
Add cocoapods support (broken)
cherylEnkidu Oct 29, 2024
f2326f7
Remove swift file in public header
cherylEnkidu Oct 29, 2024
a980df3
Fix cocoapods
cherylEnkidu Nov 1, 2024
2dfbe50
Fix style
cherylEnkidu Nov 1, 2024
7887fe5
simplify cocoapods
cherylEnkidu Nov 5, 2024
2e504e5
Add Objective-C version
cherylEnkidu Nov 5, 2024
50e52e0
use @_implementationOnly
cherylEnkidu Nov 11, 2024
72ae07d
Revert "use @_implementationOnly"
cherylEnkidu Nov 12, 2024
53b0471
implement pipeline files in C++ side
cherylEnkidu Dec 12, 2024
2b647b8
add pipeline interface in cocoapods support
cherylEnkidu Dec 13, 2024
6608bb8
add pipeline result
cherylEnkidu Dec 17, 2024
9ced414
Add Pipeline Result
cherylEnkidu Jan 2, 2025
e6785f5
Add getResult Callback
cherylEnkidu Jan 2, 2025
e880583
invoke callback
cherylEnkidu Jan 3, 2025
9d9b7c2
refactor part of code
cherylEnkidu Jan 6, 2025
5462e69
move callback wrapper
cherylEnkidu Jan 7, 2025
7d2362b
fixing format
cherylEnkidu Jan 7, 2025
5dc9783
change class to struct
cherylEnkidu Jan 7, 2025
da80692
address part of feedbacks
cherylEnkidu Jan 8, 2025
dbf10d8
Address more feedbacks
cherylEnkidu Jan 8, 2025
0e652a7
fix some syntaxs
cherylEnkidu Jan 9, 2025
5bde275
Add tests, bug: double free
cherylEnkidu Jan 16, 2025
3fc8a15
shared_ptr instead of unique_ptr (#14353)
wu-hui Jan 16, 2025
182b237
Merge branch 'main' into cheryllin/firestoreSwiftCpp
cherylEnkidu Jan 20, 2025
7a9aa72
Merge branch 'main' into cheryllin/firestoreSwiftCpp
cherylEnkidu Jan 20, 2025
499bcb4
Use workaround to fix double free error
cherylEnkidu Jan 22, 2025
757d524
Rename cpp public header
cherylEnkidu Jan 23, 2025
ef10b6f
Fix style
cherylEnkidu Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ FirebaseAppCheck/Apps/AppCheckCustomProvideApp/AppCheckCustomProvideApp/GoogleSe
/Example/FirestoreSample/firebase-debug.log

# generated Terraform docs
Firestore/.terraform/*
Firestore/.terraform.lock.hcl
.terraform/*
.terraform.lock.hcl
*.tfstate
Expand Down
4 changes: 3 additions & 1 deletion FirebaseCombineSwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ for internal testing only. It should not be published.

s.pod_target_xcconfig = {
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"',
'SWIFT_OBJC_INTEROP_MODE' => 'objcxx',
}

s.test_spec 'unit' do |unit_tests|
Expand All @@ -81,7 +82,8 @@ for internal testing only. It should not be published.
unit_tests.exclude_files = 'FirebaseCombineSwift/Tests/Unit/**/*Template.swift'
unit_tests.requires_app_host = true
unit_tests.pod_target_xcconfig = {
'SWIFT_OBJC_BRIDGING_HEADER' => '$(PODS_TARGET_SRCROOT)/FirebaseCombineSwift/Tests/Unit/FirebaseCombine-unit-Bridging-Header.h'
'SWIFT_OBJC_BRIDGING_HEADER' => '$(PODS_TARGET_SRCROOT)/FirebaseCombineSwift/Tests/Unit/FirebaseCombine-unit-Bridging-Header.h',
'SWIFT_OBJC_INTEROP_MODE' => 'objcxx',
}
unit_tests.dependency 'OCMock'
unit_tests.dependency 'FirebaseAuthTestingSupport'
Expand Down
9 changes: 9 additions & 0 deletions FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@
NS_ASSUME_NONNULL_BEGIN

/** Returns the current version of Firebase. */

#ifdef __cplusplus
extern "C" {
#endif

NS_SWIFT_NAME(FirebaseVersion())
NSString* FIRFirebaseVersion(void);

#ifdef __cplusplus
}
#endif

NS_ASSUME_NONNULL_END
6 changes: 6 additions & 0 deletions FirebaseFirestore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling,
'FirebaseFirestoreInternal/**/*.[mh]',
'Firestore/Swift/Source/**/*.swift',
]

s.pod_target_xcconfig = {
# Enables C++ <-> Swift interop (by default it's only C)
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
}

s.resource_bundles = {
"#{s.module_name}_Privacy" => 'Firestore/Swift/Source/Resources/PrivacyInfo.xcprivacy'
}
Expand Down
6 changes: 5 additions & 1 deletion FirebaseFirestoreInternal.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling,
# Header files that constitute the interface to this module. Only Objective-C
# headers belong here, since FirebaseFirestore is primarily an Objective-C
# framework.
s.public_header_files = 'Firestore/Source/Public/FirebaseFirestore/*.h'
s.public_header_files = [
'Firestore/Source/Public/FirebaseFirestore/*.h',
'Firestore/core/interfaceForSwift/api/*.h'
]

# source_files contains most of the header and source files for the project.
# This includes files named in `public_header_files`.
Expand All @@ -52,6 +55,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/core/interfaceForSwift/**/*.{cc,h}',
]

# Internal headers that aren't necessarily globally unique. Most C++ internal
Expand Down
496 changes: 262 additions & 234 deletions Firestore/Example/Firestore.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
enableAddressSanitizer = "YES"
enableASanStackUseAfterReturn = "YES">
<MacroExpansion>
<BuildableReference
Expand All @@ -37,6 +38,13 @@
ReferencedContainer = "container:Firestore.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -54,6 +62,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableAddressSanitizer = "YES"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Example/Tests/API/FIRAggregateQueryUnitTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ @interface FIRAggregateQueryUnitTests : XCTestCase
@implementation FIRAggregateQueryUnitTests

- (void)testEquals {
std::shared_ptr<api::Firestore> firestore = FSTTestFirestore().wrapped;
std::shared_ptr<api::Firestore> firestore = FSTTestFirestore().cppFirestorePtr;
FIRAggregateQuery *queryFoo =
[[FIRQuery alloc] initWithQuery:Query("foo") firestore:firestore].count;
FIRAggregateQuery *queryFooDup =
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ - (void)testIncludeMetadataChanges {
DocumentViewChange(doc2New, DocumentViewChange::Type::Modified),
};

std::shared_ptr<Firestore> firestore = FSTTestFirestore().wrapped;
std::shared_ptr<Firestore> firestore = FSTTestFirestore().cppFirestorePtr;
core::Query query = Query("foo");
ViewSnapshot viewSnapshot(query, newDocuments, oldDocuments, std::move(documentChanges),
/*mutated_keys=*/DocumentKeySet(),
Expand Down
4 changes: 2 additions & 2 deletions Firestore/Example/Tests/API/FIRQueryUnitTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ @interface FIRQueryUnitTests : XCTestCase
@implementation FIRQueryUnitTests

- (void)testEquals {
std::shared_ptr<api::Firestore> firestore = FSTTestFirestore().wrapped;
std::shared_ptr<api::Firestore> firestore = FSTTestFirestore().cppFirestorePtr;
FIRQuery *queryFoo = [[FIRQuery alloc] initWithQuery:Query("foo") firestore:firestore];
FIRQuery *queryFooDup = [[FIRQuery alloc] initWithQuery:Query("foo") firestore:firestore];
FIRQuery *queryBar = [[FIRQuery alloc] initWithQuery:Query("bar") firestore:firestore];
Expand All @@ -58,7 +58,7 @@ - (void)testEquals {
}

- (void)testFilteringWithPredicate {
std::shared_ptr<api::Firestore> firestore = FSTTestFirestore().wrapped;
std::shared_ptr<api::Firestore> firestore = FSTTestFirestore().cppFirestorePtr;
FIRQuery *query = [[FIRQuery alloc] initWithQuery:Query("foo") firestore:firestore];
FIRQuery *query1 = [query queryWhereField:@"f" isLessThanOrEqualTo:@1];
FIRQuery *query2 = [query queryFilteredUsingPredicate:[NSPredicate predicateWithFormat:@"f<=1"]];
Expand Down
6 changes: 3 additions & 3 deletions Firestore/Example/Tests/API/FSTAPIHelpers.mm
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@

FIRCollectionReference *FSTTestCollectionRef(const char *path) {
return [[FIRCollectionReference alloc] initWithPath:Resource(path)
firestore:FSTTestFirestore().wrapped];
firestore:FSTTestFirestore().cppFirestorePtr];
}

FIRDocumentReference *FSTTestDocRef(const char *path) {
return [[FIRDocumentReference alloc] initWithPath:Resource(path)
firestore:FSTTestFirestore().wrapped];
firestore:FSTTestFirestore().cppFirestorePtr];
}

/** A convenience method for creating a query snapshots for tests. */
Expand Down Expand Up @@ -157,7 +157,7 @@
/*sync_state_changed=*/true,
/*excludes_metadata_changes=*/false,
static_cast<bool>(hasCachedResults)};
return [[FIRQuerySnapshot alloc] initWithFirestore:FSTTestFirestore().wrapped
return [[FIRQuerySnapshot alloc] initWithFirestore:FSTTestFirestore().cppFirestorePtr
originalQuery:Query(path)
snapshot:std::move(viewSnapshot)
metadata:std::move(metadata)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ - (void)testAppDeleteLeadsToFirestoreTermination {

[self deleteApp:app];

XCTAssertTrue(firestore.wrapped->client()->is_terminated());
XCTAssertTrue(firestore.cppFirestorePtr->client()->is_terminated());
}

// Ensures b/172958106 doesn't regress.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/firestore/bundle.nanopb.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/firestore/bundle.nanopb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/firestore/local/mutation.nanopb.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/firestore/local/mutation.nanopb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/firestore/local/target.nanopb.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/firestore/local/target.nanopb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/google/api/annotations.nanopb.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/google/api/annotations.nanopb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/google/api/http.nanopb.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/google/api/http.nanopb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/google/api/resource.nanopb.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/google/api/resource.nanopb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/google/firestore/v1/query.nanopb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/google/firestore/v1/write.nanopb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/google/protobuf/any.nanopb.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Protos/nanopb/google/protobuf/any.nanopb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC
* 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.
Expand Down
Loading
Loading