From bf1f63040cbf423ae476070b416bb61b377830ba Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 22 Oct 2024 22:19:15 -0400 Subject: [PATCH 01/14] init --- .../Swift/Source/SwiftAPI/SwiftCppAPI.swift | 14 +++++++++ Firestore/core/CMakeLists.txt | 3 ++ Firestore/core/swift/include/used_by_swift.h | 15 +++++++++ Firestore/core/swift/src/used_by_swift.cc | 10 ++++++ .../swift/umbrella/FirebaseFirestoreCpp.h | 10 ++++++ Package.swift | 31 +++++++++++++++++-- 6 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift create mode 100644 Firestore/core/swift/include/used_by_swift.h create mode 100644 Firestore/core/swift/src/used_by_swift.cc create mode 100644 Firestore/core/swift/umbrella/FirebaseFirestoreCpp.h diff --git a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift new file mode 100644 index 00000000000..159f2bcdd46 --- /dev/null +++ b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift @@ -0,0 +1,14 @@ +// +// SwiftCppAPI.swift +// Firebase +// +// Created by Cheryl Lin on 2024-10-22. +// + +import FirebaseFirestoreCpp + +public class SwiftCppWrapper { + init(_ value : String ){ + _ = UsedBySwift(std.string(value)) + } +} diff --git a/Firestore/core/CMakeLists.txt b/Firestore/core/CMakeLists.txt index 65238165549..79ce44ec4c5 100644 --- a/Firestore/core/CMakeLists.txt +++ b/Firestore/core/CMakeLists.txt @@ -218,6 +218,9 @@ firebase_ios_glob( src/objc/*.h src/remote/*.cc src/remote/*.h + swift/include/*.h + swift/src/*.cc + swift/umbrella/*.h EXCLUDE ${nanopb_sources} ) diff --git a/Firestore/core/swift/include/used_by_swift.h b/Firestore/core/swift/include/used_by_swift.h new file mode 100644 index 00000000000..d06b8effbe4 --- /dev/null +++ b/Firestore/core/swift/include/used_by_swift.h @@ -0,0 +1,15 @@ +// +// Created by Cheryl Lin on 2024-10-22. +// + +#ifndef FIREBASE_USED_BY_SWIFT_H +#define FIREBASE_USED_BY_SWIFT_H + +#include + +class UsedBySwift { + public: + explicit UsedBySwift(std::string content); +}; + +#endif // FIREBASE_USED_BY_SWIFT_H diff --git a/Firestore/core/swift/src/used_by_swift.cc b/Firestore/core/swift/src/used_by_swift.cc new file mode 100644 index 00000000000..b6cc5ee11c4 --- /dev/null +++ b/Firestore/core/swift/src/used_by_swift.cc @@ -0,0 +1,10 @@ +// +// Created by Cheryl Lin on 2024-10-22. +// + +#include "Firestore/core/swift/include/used_by_swift.h" +#include + +UsedBySwift::UsedBySwift(std::string content) { + std::cout << "ctor runs with value: " << content << std::endl; +} diff --git a/Firestore/core/swift/umbrella/FirebaseFirestoreCpp.h b/Firestore/core/swift/umbrella/FirebaseFirestoreCpp.h new file mode 100644 index 00000000000..7ea07015a0d --- /dev/null +++ b/Firestore/core/swift/umbrella/FirebaseFirestoreCpp.h @@ -0,0 +1,10 @@ +// +// Created by Cheryl Lin on 2024-10-22. +// + +#ifndef FIREBASE_FIREBASEFIRESTORECPP_H +#define FIREBASE_FIREBASEFIRESTORECPP_H + +#import "../include/used_by_swift.h" + +#endif // FIREBASE_FIREBASEFIRESTORECPP_H diff --git a/Package.swift b/Package.swift index 55dfbba46e0..f1ea1ea901c 100644 --- a/Package.swift +++ b/Package.swift @@ -476,7 +476,10 @@ let package = Package( dependencies: [ "FirebaseFirestoreTarget", ], - path: "FirebaseCombineSwift/Sources/Firestore" + path: "FirebaseCombineSwift/Sources/Firestore", + swiftSettings: [ + .interoperabilityMode(.Cxx), // C++ interoperability setting + ] ), .target( name: "FirebaseStorageCombineSwift", @@ -1399,6 +1402,20 @@ func firestoreWrapperTarget() -> Target { ) } +func firebaseFirestoreCppTarget() -> Target { + return .target( + name: "FirebaseFirestoreCpp", + path: "Firestore/core/swift", + sources: [ + "src", + ], + publicHeadersPath: "include", // Path to the public headers + cxxSettings: [ + .headerSearchPath("umbrella"), // Ensure the header search path is correct + ] + ) +} + func firestoreTargets() -> [Target] { if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil { return [ @@ -1469,6 +1486,7 @@ func firestoreTargets() -> [Target] { .linkedLibrary("c++"), ] ), + firebaseFirestoreCppTarget(), .target( name: "FirebaseFirestore", dependencies: [ @@ -1476,6 +1494,7 @@ func firestoreTargets() -> [Target] { "FirebaseCoreExtension", "FirebaseFirestoreInternalWrapper", "FirebaseSharedSwift", + "FirebaseFirestoreCpp", ], path: "Firestore", exclude: [ @@ -1496,7 +1515,10 @@ func firestoreTargets() -> [Target] { sources: [ "Swift/Source/", ], - resources: [.process("Source/Resources/PrivacyInfo.xcprivacy")] + resources: [.process("Source/Resources/PrivacyInfo.xcprivacy")], + swiftSettings: [ + .interoperabilityMode(.Cxx), // C++ interoperability setting + ] ), ] } @@ -1542,9 +1564,13 @@ func firestoreTargets() -> [Target] { "FirebaseCoreExtension", "leveldb", "FirebaseSharedSwift", + "FirebaseFirestoreCpp", ], path: "Firestore/Swift/Source", resources: [.process("Resources/PrivacyInfo.xcprivacy")], + swiftSettings: [ + .interoperabilityMode(.Cxx), // C++ interoperability setting + ], linkerSettings: [ .linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])), .linkedFramework("UIKit", .when(platforms: [.iOS, .tvOS])), @@ -1561,5 +1587,6 @@ func firestoreTargets() -> [Target] { publicHeadersPath: "." ), firestoreInternalTarget, + firebaseFirestoreCppTarget(), ] } From b84f3ec2f011c505609dd4b321cc9c2d03931de9 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 22 Oct 2024 22:56:41 -0400 Subject: [PATCH 02/14] bug fix --- Firestore/core/swift/src/used_by_swift.cc | 2 +- Package.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Firestore/core/swift/src/used_by_swift.cc b/Firestore/core/swift/src/used_by_swift.cc index b6cc5ee11c4..c497d8ee1b1 100644 --- a/Firestore/core/swift/src/used_by_swift.cc +++ b/Firestore/core/swift/src/used_by_swift.cc @@ -2,7 +2,7 @@ // Created by Cheryl Lin on 2024-10-22. // -#include "Firestore/core/swift/include/used_by_swift.h" +#include "../include/used_by_swift.h" #include UsedBySwift::UsedBySwift(std::string content) { diff --git a/Package.swift b/Package.swift index f1ea1ea901c..cfa9a273a05 100644 --- a/Package.swift +++ b/Package.swift @@ -1174,7 +1174,10 @@ let package = Package( "FirebaseStorage", .product(name: "nanopb", package: "nanopb"), ], - path: "SwiftPMTests/swift-test" + path: "SwiftPMTests/swift-test", + swiftSettings: [ + .interoperabilityMode(.Cxx), // C++ interoperability setting + ] ), .testTarget( name: "analytics-import-test", @@ -1406,9 +1409,6 @@ func firebaseFirestoreCppTarget() -> Target { return .target( name: "FirebaseFirestoreCpp", path: "Firestore/core/swift", - sources: [ - "src", - ], publicHeadersPath: "include", // Path to the public headers cxxSettings: [ .headerSearchPath("umbrella"), // Ensure the header search path is correct From 7c7ac2ed8b3ad101a6beee10a04e5dcb91196e40 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Thu, 24 Oct 2024 14:07:56 -0400 Subject: [PATCH 03/14] add extern c --- .../Sources/Public/FirebaseCore/FIRVersion.h | 9 ++++++++ Package.swift | 22 +++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h b/FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h index 651edaf5c8b..65a3e764822 100644 --- a/FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h +++ b/FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h @@ -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 diff --git a/Package.swift b/Package.swift index cfa9a273a05..ce99a14093a 100644 --- a/Package.swift +++ b/Package.swift @@ -478,7 +478,7 @@ let package = Package( ], path: "FirebaseCombineSwift/Sources/Firestore", swiftSettings: [ - .interoperabilityMode(.Cxx), // C++ interoperability setting + .interoperabilityMode(.Cxx), // C++ interoperability setting ] ), .target( @@ -1176,7 +1176,7 @@ let package = Package( ], path: "SwiftPMTests/swift-test", swiftSettings: [ - .interoperabilityMode(.Cxx), // C++ interoperability setting + .interoperabilityMode(.Cxx), // C++ interoperability setting ] ), .testTarget( @@ -1406,14 +1406,14 @@ func firestoreWrapperTarget() -> Target { } func firebaseFirestoreCppTarget() -> Target { - return .target( - name: "FirebaseFirestoreCpp", - path: "Firestore/core/swift", - publicHeadersPath: "include", // Path to the public headers - cxxSettings: [ - .headerSearchPath("umbrella"), // Ensure the header search path is correct - ] - ) + return .target( + name: "FirebaseFirestoreCpp", + path: "Firestore/core/swift", + publicHeadersPath: "include", // Path to the public headers + cxxSettings: [ + .headerSearchPath("umbrella"), // Ensure the header search path is correct + ] + ) } func firestoreTargets() -> [Target] { @@ -1569,7 +1569,7 @@ func firestoreTargets() -> [Target] { path: "Firestore/Swift/Source", resources: [.process("Resources/PrivacyInfo.xcprivacy")], swiftSettings: [ - .interoperabilityMode(.Cxx), // C++ interoperability setting + .interoperabilityMode(.Cxx), // C++ interoperability setting ], linkerSettings: [ .linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])), From 65931e726ae63eb17f754e9343de795adeb5904c Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Mon, 28 Oct 2024 14:23:14 -0400 Subject: [PATCH 04/14] public init --- Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift index 159f2bcdd46..debf38adc2e 100644 --- a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift +++ b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift @@ -8,7 +8,7 @@ import FirebaseFirestoreCpp public class SwiftCppWrapper { - init(_ value : String ){ + public init(_ value : String ){ _ = UsedBySwift(std.string(value)) } } From b7f7ebc06cba2f17bebc9b8fc215535c2af6b9b4 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 29 Oct 2024 13:33:15 -0400 Subject: [PATCH 05/14] Add cocoapods support (broken) --- FirebaseFirestore.podspec | 12 ++++++- FirebaseFirestoreCpp.podspec | 65 ++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 FirebaseFirestoreCpp.podspec diff --git a/FirebaseFirestore.podspec b/FirebaseFirestore.podspec index ff55ec358f1..a68f7f5baf4 100644 --- a/FirebaseFirestore.podspec +++ b/FirebaseFirestore.podspec @@ -24,13 +24,22 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, s.cocoapods_version = '>= 1.12.0' s.prefix_header_file = false - s.public_header_files = 'FirebaseFirestoreInternal/**/*.h' + s.public_header_files = [ + 'FirebaseFirestoreInternal/**/*.h', + 'Firestore/Swift/Source/SwiftAPI/*.swift', + ] s.requires_arc = true s.source_files = [ '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' } @@ -38,6 +47,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, s.dependency 'FirebaseCore', '11.5' s.dependency 'FirebaseCoreExtension', '11.5' s.dependency 'FirebaseFirestoreInternal', '11.5.0' + s.dependency 'FirebaseFirestoreCpp', '11.5.0' s.dependency 'FirebaseSharedSwift', '~> 11.0' end diff --git a/FirebaseFirestoreCpp.podspec b/FirebaseFirestoreCpp.podspec new file mode 100644 index 00000000000..68bd2be887a --- /dev/null +++ b/FirebaseFirestoreCpp.podspec @@ -0,0 +1,65 @@ +Pod::Spec.new do |s| + s.name = 'FirebaseFirestoreCpp' + s.version = '11.5.0' + s.summary = 'Google Cloud Firestore' + + s.description = <<-DESC +Google Cloud Firestore is a NoSQL document database built for automatic scaling, high performance, and ease of application development. + DESC + + s.homepage = 'https://developers.google.com/' + s.license = { :type => 'Apache-2.0', :file => 'Firestore/LICENSE' } + s.authors = 'Google, Inc.' + + s.source = { + :git => 'https://github.com/firebase/firebase-ios-sdk.git', + :tag => 'CocoaPods-' + s.version.to_s + } + + s.ios.deployment_target = '13.0' + s.osx.deployment_target = '10.15' + s.tvos.deployment_target = '13.0' + + s.swift_version = '5.9' + + s.cocoapods_version = '>= 1.12.0' + s.prefix_header_file = false + + s.public_header_files = 'Firestore/core/swift/umbrella/*.h' + + s.source_files = [ + 'Firestore/core/swift/**/*.{cc,h}' + ] + + abseil_version = '~> 1.20240116.1' + s.dependency 'abseil/algorithm', abseil_version + s.dependency 'abseil/base', abseil_version + s.dependency 'abseil/container/flat_hash_map', abseil_version + s.dependency 'abseil/memory', abseil_version + s.dependency 'abseil/meta', abseil_version + s.dependency 'abseil/strings/strings', abseil_version + s.dependency 'abseil/time', abseil_version + s.dependency 'abseil/types', abseil_version + + s.ios.frameworks = 'SystemConfiguration', 'UIKit' + s.osx.frameworks = 'SystemConfiguration' + s.tvos.frameworks = 'SystemConfiguration', 'UIKit' + + 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} " + + # The nanopb pod sets these defs, so we must too. (We *do* require 16bit + # (or larger) fields, so we'd have to set at least PB_FIELD_16BIT + # anyways.) + 'PB_FIELD_32BIT=1 PB_NO_PACKED_STRUCTS=1 PB_ENABLE_MALLOC=1', + 'HEADER_SEARCH_PATHS' => + '"${PODS_TARGET_SRCROOT}" ' + + '"${PODS_TARGET_SRCROOT}/Firestore/core/swift/include" ' + } + + s.compiler_flags = '$(inherited) -Wreorder -Werror=reorder -Wno-comma' +end From 8f13adeb84092af755e3cf5e5d85193b7c8a5cf7 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 29 Oct 2024 14:29:15 -0400 Subject: [PATCH 06/14] Remove swift file in public header --- FirebaseFirestore.podspec | 5 +---- FirebaseFirestoreCpp.podspec | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/FirebaseFirestore.podspec b/FirebaseFirestore.podspec index a68f7f5baf4..1f0d3f9da6e 100644 --- a/FirebaseFirestore.podspec +++ b/FirebaseFirestore.podspec @@ -24,10 +24,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, s.cocoapods_version = '>= 1.12.0' s.prefix_header_file = false - s.public_header_files = [ - 'FirebaseFirestoreInternal/**/*.h', - 'Firestore/Swift/Source/SwiftAPI/*.swift', - ] + s.public_header_files = 'FirebaseFirestoreInternal/**/*.h' s.requires_arc = true s.source_files = [ diff --git a/FirebaseFirestoreCpp.podspec b/FirebaseFirestoreCpp.podspec index 68bd2be887a..5127e077602 100644 --- a/FirebaseFirestoreCpp.podspec +++ b/FirebaseFirestoreCpp.podspec @@ -58,7 +58,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, 'PB_FIELD_32BIT=1 PB_NO_PACKED_STRUCTS=1 PB_ENABLE_MALLOC=1', 'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}" ' + - '"${PODS_TARGET_SRCROOT}/Firestore/core/swift/include" ' + '"${PODS_TARGET_SRCROOT}/Firestore/core/swift" ' } s.compiler_flags = '$(inherited) -Wreorder -Werror=reorder -Wno-comma' From 456ed8256140f31ecb41b66299a0fe54bc2d524e Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Fri, 1 Nov 2024 16:01:54 -0400 Subject: [PATCH 07/14] Fix cocoapods --- FirebaseFirestoreCpp.podspec | 2 +- Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift | 4 ++-- .../core/swift/{umbrella => include}/FirebaseFirestoreCpp.h | 2 +- Package.swift | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename Firestore/core/swift/{umbrella => include}/FirebaseFirestoreCpp.h (82%) diff --git a/FirebaseFirestoreCpp.podspec b/FirebaseFirestoreCpp.podspec index 5127e077602..97fd1b5c9cd 100644 --- a/FirebaseFirestoreCpp.podspec +++ b/FirebaseFirestoreCpp.podspec @@ -25,7 +25,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, s.cocoapods_version = '>= 1.12.0' s.prefix_header_file = false - s.public_header_files = 'Firestore/core/swift/umbrella/*.h' + s.public_header_files = 'Firestore/core/swift/include/*.h' s.source_files = [ 'Firestore/core/swift/**/*.{cc,h}' diff --git a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift index debf38adc2e..1c83eb92de5 100644 --- a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift +++ b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift @@ -8,7 +8,7 @@ import FirebaseFirestoreCpp public class SwiftCppWrapper { - public init(_ value : String ){ + public init(_ value: String) { _ = UsedBySwift(std.string(value)) - } + } } diff --git a/Firestore/core/swift/umbrella/FirebaseFirestoreCpp.h b/Firestore/core/swift/include/FirebaseFirestoreCpp.h similarity index 82% rename from Firestore/core/swift/umbrella/FirebaseFirestoreCpp.h rename to Firestore/core/swift/include/FirebaseFirestoreCpp.h index 7ea07015a0d..029e364a6fc 100644 --- a/Firestore/core/swift/umbrella/FirebaseFirestoreCpp.h +++ b/Firestore/core/swift/include/FirebaseFirestoreCpp.h @@ -5,6 +5,6 @@ #ifndef FIREBASE_FIREBASEFIRESTORECPP_H #define FIREBASE_FIREBASEFIRESTORECPP_H -#import "../include/used_by_swift.h" +#import "used_by_swift.h" #endif // FIREBASE_FIREBASEFIRESTORECPP_H diff --git a/Package.swift b/Package.swift index ce99a14093a..5a2b73deccf 100644 --- a/Package.swift +++ b/Package.swift @@ -1411,7 +1411,7 @@ func firebaseFirestoreCppTarget() -> Target { path: "Firestore/core/swift", publicHeadersPath: "include", // Path to the public headers cxxSettings: [ - .headerSearchPath("umbrella"), // Ensure the header search path is correct + .headerSearchPath("include"), // Ensure the header search path is correct ] ) } From 497cbf8021995cc247ba4ce75924a971a2d7da37 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Fri, 1 Nov 2024 16:06:39 -0400 Subject: [PATCH 08/14] Fix style --- FirebaseFirestore.podspec | 4 ++-- .../Swift/Source/SwiftAPI/SwiftCppAPI.swift | 21 +++++++++++++------ Firestore/core/CMakeLists.txt | 1 - .../core/swift/include/FirebaseFirestoreCpp.h | 18 +++++++++++++--- Firestore/core/swift/include/used_by_swift.h | 18 +++++++++++++--- Firestore/core/swift/src/used_by_swift.cc | 18 +++++++++++++--- 6 files changed, 62 insertions(+), 18 deletions(-) diff --git a/FirebaseFirestore.podspec b/FirebaseFirestore.podspec index 1f0d3f9da6e..8ea3479bdc1 100644 --- a/FirebaseFirestore.podspec +++ b/FirebaseFirestore.podspec @@ -31,12 +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' } diff --git a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift index 1c83eb92de5..4b2db92536c 100644 --- a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift +++ b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift @@ -1,9 +1,18 @@ -// -// SwiftCppAPI.swift -// Firebase -// -// Created by Cheryl Lin on 2024-10-22. -// +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import FirebaseFirestoreCpp diff --git a/Firestore/core/CMakeLists.txt b/Firestore/core/CMakeLists.txt index 79ce44ec4c5..4da90c896ee 100644 --- a/Firestore/core/CMakeLists.txt +++ b/Firestore/core/CMakeLists.txt @@ -220,7 +220,6 @@ firebase_ios_glob( src/remote/*.h swift/include/*.h swift/src/*.cc - swift/umbrella/*.h EXCLUDE ${nanopb_sources} ) diff --git a/Firestore/core/swift/include/FirebaseFirestoreCpp.h b/Firestore/core/swift/include/FirebaseFirestoreCpp.h index 029e364a6fc..dd769230b8f 100644 --- a/Firestore/core/swift/include/FirebaseFirestoreCpp.h +++ b/Firestore/core/swift/include/FirebaseFirestoreCpp.h @@ -1,6 +1,18 @@ -// -// Created by Cheryl Lin on 2024-10-22. -// +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef FIREBASE_FIREBASEFIRESTORECPP_H #define FIREBASE_FIREBASEFIRESTORECPP_H diff --git a/Firestore/core/swift/include/used_by_swift.h b/Firestore/core/swift/include/used_by_swift.h index d06b8effbe4..c5d5c516fc4 100644 --- a/Firestore/core/swift/include/used_by_swift.h +++ b/Firestore/core/swift/include/used_by_swift.h @@ -1,6 +1,18 @@ -// -// Created by Cheryl Lin on 2024-10-22. -// +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef FIREBASE_USED_BY_SWIFT_H #define FIREBASE_USED_BY_SWIFT_H diff --git a/Firestore/core/swift/src/used_by_swift.cc b/Firestore/core/swift/src/used_by_swift.cc index c497d8ee1b1..87981e2c4c7 100644 --- a/Firestore/core/swift/src/used_by_swift.cc +++ b/Firestore/core/swift/src/used_by_swift.cc @@ -1,6 +1,18 @@ -// -// Created by Cheryl Lin on 2024-10-22. -// +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "../include/used_by_swift.h" #include From 299de31714f88c29e8124e9c19090085c41ed575 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 5 Nov 2024 12:26:40 -0500 Subject: [PATCH 09/14] simplify cocoapods --- FirebaseCombineSwift.podspec | 4 +- FirebaseFirestore.podspec | 1 - FirebaseFirestoreCpp.podspec | 65 ------------------- FirebaseFirestoreInternal.podspec | 6 +- .../Swift/Source/SwiftAPI/SwiftCppAPI.swift | 4 +- 5 files changed, 11 insertions(+), 69 deletions(-) delete mode 100644 FirebaseFirestoreCpp.podspec diff --git a/FirebaseCombineSwift.podspec b/FirebaseCombineSwift.podspec index a181b9b1a42..18b73a4dc7e 100644 --- a/FirebaseCombineSwift.podspec +++ b/FirebaseCombineSwift.podspec @@ -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| @@ -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' diff --git a/FirebaseFirestore.podspec b/FirebaseFirestore.podspec index 8ea3479bdc1..2934bda631a 100644 --- a/FirebaseFirestore.podspec +++ b/FirebaseFirestore.podspec @@ -44,7 +44,6 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, s.dependency 'FirebaseCore', '11.5' s.dependency 'FirebaseCoreExtension', '11.5' s.dependency 'FirebaseFirestoreInternal', '11.5.0' - s.dependency 'FirebaseFirestoreCpp', '11.5.0' s.dependency 'FirebaseSharedSwift', '~> 11.0' end diff --git a/FirebaseFirestoreCpp.podspec b/FirebaseFirestoreCpp.podspec deleted file mode 100644 index 97fd1b5c9cd..00000000000 --- a/FirebaseFirestoreCpp.podspec +++ /dev/null @@ -1,65 +0,0 @@ -Pod::Spec.new do |s| - s.name = 'FirebaseFirestoreCpp' - s.version = '11.5.0' - s.summary = 'Google Cloud Firestore' - - s.description = <<-DESC -Google Cloud Firestore is a NoSQL document database built for automatic scaling, high performance, and ease of application development. - DESC - - s.homepage = 'https://developers.google.com/' - s.license = { :type => 'Apache-2.0', :file => 'Firestore/LICENSE' } - s.authors = 'Google, Inc.' - - s.source = { - :git => 'https://github.com/firebase/firebase-ios-sdk.git', - :tag => 'CocoaPods-' + s.version.to_s - } - - s.ios.deployment_target = '13.0' - s.osx.deployment_target = '10.15' - s.tvos.deployment_target = '13.0' - - s.swift_version = '5.9' - - s.cocoapods_version = '>= 1.12.0' - s.prefix_header_file = false - - s.public_header_files = 'Firestore/core/swift/include/*.h' - - s.source_files = [ - 'Firestore/core/swift/**/*.{cc,h}' - ] - - abseil_version = '~> 1.20240116.1' - s.dependency 'abseil/algorithm', abseil_version - s.dependency 'abseil/base', abseil_version - s.dependency 'abseil/container/flat_hash_map', abseil_version - s.dependency 'abseil/memory', abseil_version - s.dependency 'abseil/meta', abseil_version - s.dependency 'abseil/strings/strings', abseil_version - s.dependency 'abseil/time', abseil_version - s.dependency 'abseil/types', abseil_version - - s.ios.frameworks = 'SystemConfiguration', 'UIKit' - s.osx.frameworks = 'SystemConfiguration' - s.tvos.frameworks = 'SystemConfiguration', 'UIKit' - - 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} " + - # The nanopb pod sets these defs, so we must too. (We *do* require 16bit - # (or larger) fields, so we'd have to set at least PB_FIELD_16BIT - # anyways.) - 'PB_FIELD_32BIT=1 PB_NO_PACKED_STRUCTS=1 PB_ENABLE_MALLOC=1', - 'HEADER_SEARCH_PATHS' => - '"${PODS_TARGET_SRCROOT}" ' + - '"${PODS_TARGET_SRCROOT}/Firestore/core/swift" ' - } - - s.compiler_flags = '$(inherited) -Wreorder -Werror=reorder -Wno-comma' -end diff --git a/FirebaseFirestoreInternal.podspec b/FirebaseFirestoreInternal.podspec index 33a61dbca85..aee3a95f308 100644 --- a/FirebaseFirestoreInternal.podspec +++ b/FirebaseFirestoreInternal.podspec @@ -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/swift/include/*.h' + ] # source_files contains most of the header and source files for the project. # This includes files named in `public_header_files`. @@ -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/swift/**/*.{cc,h}', ] # Internal headers that aren't necessarily globally unique. Most C++ internal diff --git a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift index 4b2db92536c..aaafb30ef3d 100644 --- a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift +++ b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseFirestoreCpp +#if SWIFT_PACKAGE + @_exported import FirebaseFirestoreCpp +#endif // SWIFT_PACKAGE public class SwiftCppWrapper { public init(_ value: String) { From ec7848e18595e987790968b364a6a2e887b4ee04 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 5 Nov 2024 17:51:54 -0500 Subject: [PATCH 10/14] Add Objective-C version --- Firestore/Source/API/FIRInterface.mm | 36 +++++++++++++++++++ .../Public/FirebaseFirestore/FIRInterface.h | 29 +++++++++++++++ .../Swift/Source/SwiftAPI/SwiftCppAPI.swift | 4 +-- Firestore/core/src/api/used_by_objective_c.cc | 22 ++++++++++++ Firestore/core/src/api/used_by_objective_c.h | 27 ++++++++++++++ Firestore/core/swift/include/used_by_swift.h | 4 +-- Firestore/core/swift/src/used_by_swift.cc | 4 +-- 7 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 Firestore/Source/API/FIRInterface.mm create mode 100644 Firestore/Source/Public/FirebaseFirestore/FIRInterface.h create mode 100644 Firestore/core/src/api/used_by_objective_c.cc create mode 100644 Firestore/core/src/api/used_by_objective_c.h diff --git a/Firestore/Source/API/FIRInterface.mm b/Firestore/Source/API/FIRInterface.mm new file mode 100644 index 00000000000..5dc0e5bac1c --- /dev/null +++ b/Firestore/Source/API/FIRInterface.mm @@ -0,0 +1,36 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +#import "Firestore/Source/Public/FirebaseFirestore/FIRInterface.h" + +#import "Firestore/core/src/api/used_by_objective_c.h" +#include "Firestore/core/src/util/string_apple.h" + +using firebase::firestore::util::MakeString; + +NS_ASSUME_NONNULL_BEGIN + +@implementation FIRInterface + ++ (void)print:(NSString *)content { + CppInterfaceCalledByObjectiveC::print(MakeString(content)); +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/Firestore/Source/Public/FirebaseFirestore/FIRInterface.h b/Firestore/Source/Public/FirebaseFirestore/FIRInterface.h new file mode 100644 index 00000000000..222b7024e91 --- /dev/null +++ b/Firestore/Source/Public/FirebaseFirestore/FIRInterface.h @@ -0,0 +1,29 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface FIRInterface : NSObject + +#pragma mark - Create Filter + ++ (void)print:(NSString *)content; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift index aaafb30ef3d..fafeec43e98 100644 --- a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift +++ b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift @@ -18,8 +18,8 @@ @_exported import FirebaseFirestoreCpp #endif // SWIFT_PACKAGE -public class SwiftCppWrapper { +public class SwiftCallingCpp { public init(_ value: String) { - _ = UsedBySwift(std.string(value)) + CppInterfaceCalledBySwift.print(std.string(value)) } } diff --git a/Firestore/core/src/api/used_by_objective_c.cc b/Firestore/core/src/api/used_by_objective_c.cc new file mode 100644 index 00000000000..1333cecfe1f --- /dev/null +++ b/Firestore/core/src/api/used_by_objective_c.cc @@ -0,0 +1,22 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "used_by_objective_c.h" +#include + +void CppInterfaceCalledByObjectiveC::print(std::string content) { + std::cout << "C++ function runs with value: " << content << std::endl; +} diff --git a/Firestore/core/src/api/used_by_objective_c.h b/Firestore/core/src/api/used_by_objective_c.h new file mode 100644 index 00000000000..06360f441ba --- /dev/null +++ b/Firestore/core/src/api/used_by_objective_c.h @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FIREBASE_USED_BY_SWIFT_H +#define FIREBASE_USED_BY_SWIFT_H + +#include + +class CppInterfaceCalledByObjectiveC { + public: + static void print(std::string content); +}; + +#endif // FIREBASE_USED_BY_SWIFT_H diff --git a/Firestore/core/swift/include/used_by_swift.h b/Firestore/core/swift/include/used_by_swift.h index c5d5c516fc4..e4016b3c6a7 100644 --- a/Firestore/core/swift/include/used_by_swift.h +++ b/Firestore/core/swift/include/used_by_swift.h @@ -19,9 +19,9 @@ #include -class UsedBySwift { +class CppInterfaceCalledBySwift { public: - explicit UsedBySwift(std::string content); + static void print(std::string content); }; #endif // FIREBASE_USED_BY_SWIFT_H diff --git a/Firestore/core/swift/src/used_by_swift.cc b/Firestore/core/swift/src/used_by_swift.cc index 87981e2c4c7..d5261294e62 100644 --- a/Firestore/core/swift/src/used_by_swift.cc +++ b/Firestore/core/swift/src/used_by_swift.cc @@ -17,6 +17,6 @@ #include "../include/used_by_swift.h" #include -UsedBySwift::UsedBySwift(std::string content) { - std::cout << "ctor runs with value: " << content << std::endl; +void CppInterfaceCalledBySwift::print(std::string content) { + std::cout << "C++ function runs with value: " << content << std::endl; } From 4164fb9b01e17889e1d95757b3d11ee38ac94e0c Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Mon, 11 Nov 2024 09:55:47 -0800 Subject: [PATCH 11/14] use @_implementationOnly --- Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift | 4 ++-- Package.swift | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift index fafeec43e98..8797915cc68 100644 --- a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift +++ b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift @@ -15,11 +15,11 @@ */ #if SWIFT_PACKAGE - @_exported import FirebaseFirestoreCpp + @_implementationOnly import FirebaseFirestoreCpp #endif // SWIFT_PACKAGE public class SwiftCallingCpp { - public init(_ value: String) { + public static func print(_ value: String) { CppInterfaceCalledBySwift.print(std.string(value)) } } diff --git a/Package.swift b/Package.swift index 5a2b73deccf..a4a1071802c 100644 --- a/Package.swift +++ b/Package.swift @@ -476,10 +476,7 @@ let package = Package( dependencies: [ "FirebaseFirestoreTarget", ], - path: "FirebaseCombineSwift/Sources/Firestore", - swiftSettings: [ - .interoperabilityMode(.Cxx), // C++ interoperability setting - ] + path: "FirebaseCombineSwift/Sources/Firestore" ), .target( name: "FirebaseStorageCombineSwift", @@ -1174,10 +1171,7 @@ let package = Package( "FirebaseStorage", .product(name: "nanopb", package: "nanopb"), ], - path: "SwiftPMTests/swift-test", - swiftSettings: [ - .interoperabilityMode(.Cxx), // C++ interoperability setting - ] + path: "SwiftPMTests/swift-test" ), .testTarget( name: "analytics-import-test", From e31679f23bc0dce1ea253f64da2542d08db1646e Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 12 Nov 2024 15:38:40 -0800 Subject: [PATCH 12/14] Revert "use @_implementationOnly" This reverts commit 4164fb9b01e17889e1d95757b3d11ee38ac94e0c. --- Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift | 4 ++-- Package.swift | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift index 8797915cc68..fafeec43e98 100644 --- a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift +++ b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift @@ -15,11 +15,11 @@ */ #if SWIFT_PACKAGE - @_implementationOnly import FirebaseFirestoreCpp + @_exported import FirebaseFirestoreCpp #endif // SWIFT_PACKAGE public class SwiftCallingCpp { - public static func print(_ value: String) { + public init(_ value: String) { CppInterfaceCalledBySwift.print(std.string(value)) } } diff --git a/Package.swift b/Package.swift index a4a1071802c..5a2b73deccf 100644 --- a/Package.swift +++ b/Package.swift @@ -476,7 +476,10 @@ let package = Package( dependencies: [ "FirebaseFirestoreTarget", ], - path: "FirebaseCombineSwift/Sources/Firestore" + path: "FirebaseCombineSwift/Sources/Firestore", + swiftSettings: [ + .interoperabilityMode(.Cxx), // C++ interoperability setting + ] ), .target( name: "FirebaseStorageCombineSwift", @@ -1171,7 +1174,10 @@ let package = Package( "FirebaseStorage", .product(name: "nanopb", package: "nanopb"), ], - path: "SwiftPMTests/swift-test" + path: "SwiftPMTests/swift-test", + swiftSettings: [ + .interoperabilityMode(.Cxx), // C++ interoperability setting + ] ), .testTarget( name: "analytics-import-test", From a71739a38fe5006860f22d6a7769069d0b82348c Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Wed, 4 Dec 2024 17:50:51 -0500 Subject: [PATCH 13/14] replace relative path --- Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift | 3 ++- Firestore/core/swift/include/used_by_swift.h | 4 ++++ Firestore/core/swift/src/used_by_swift.cc | 6 +++++- Package.swift | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift index fafeec43e98..4390e09e2c4 100644 --- a/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift +++ b/Firestore/Swift/Source/SwiftAPI/SwiftCppAPI.swift @@ -20,6 +20,7 @@ public class SwiftCallingCpp { public init(_ value: String) { - CppInterfaceCalledBySwift.print(std.string(value)) + firebase.CppInterfaceCalledBySwift.print(std.string(value)) + firebase.CppInterfaceCalledBySwift.printTime(firebase.Timestamp(56, 32)) } } diff --git a/Firestore/core/swift/include/used_by_swift.h b/Firestore/core/swift/include/used_by_swift.h index e4016b3c6a7..fb734407214 100644 --- a/Firestore/core/swift/include/used_by_swift.h +++ b/Firestore/core/swift/include/used_by_swift.h @@ -18,10 +18,14 @@ #define FIREBASE_USED_BY_SWIFT_H #include +#include "Firestore/core/include/firebase/firestore/timestamp.h" +namespace firebase { class CppInterfaceCalledBySwift { public: static void print(std::string content); + static void printTime(Timestamp time); }; +} // namespace firebase #endif // FIREBASE_USED_BY_SWIFT_H diff --git a/Firestore/core/swift/src/used_by_swift.cc b/Firestore/core/swift/src/used_by_swift.cc index d5261294e62..11efc2c07dd 100644 --- a/Firestore/core/swift/src/used_by_swift.cc +++ b/Firestore/core/swift/src/used_by_swift.cc @@ -17,6 +17,10 @@ #include "../include/used_by_swift.h" #include -void CppInterfaceCalledBySwift::print(std::string content) { +void firebase::CppInterfaceCalledBySwift::print(std::string content) { std::cout << "C++ function runs with value: " << content << std::endl; } + +void firebase::CppInterfaceCalledBySwift::printTime(firebase::Timestamp time) { + std::cout << "C++ function runs with value: " << time.ToString() << std::endl; +} diff --git a/Package.swift b/Package.swift index 5a2b73deccf..2cbcf526028 100644 --- a/Package.swift +++ b/Package.swift @@ -1411,6 +1411,7 @@ func firebaseFirestoreCppTarget() -> Target { path: "Firestore/core/swift", publicHeadersPath: "include", // Path to the public headers cxxSettings: [ + .headerSearchPath("../../../"), .headerSearchPath("include"), // Ensure the header search path is correct ] ) From a540383781fecad62cca3185ebcc6e8b20b1a1be Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Tue, 10 Dec 2024 16:29:52 -0500 Subject: [PATCH 14/14] add include full path in implementation file --- Firestore/core/swift/include/used_by_swift.h | 2 +- Firestore/core/swift/src/used_by_swift.cc | 1 + Package.swift | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Firestore/core/swift/include/used_by_swift.h b/Firestore/core/swift/include/used_by_swift.h index fb734407214..8a81f1db216 100644 --- a/Firestore/core/swift/include/used_by_swift.h +++ b/Firestore/core/swift/include/used_by_swift.h @@ -18,7 +18,7 @@ #define FIREBASE_USED_BY_SWIFT_H #include -#include "Firestore/core/include/firebase/firestore/timestamp.h" +#include "../../include/firebase/firestore/timestamp.h" namespace firebase { class CppInterfaceCalledBySwift { diff --git a/Firestore/core/swift/src/used_by_swift.cc b/Firestore/core/swift/src/used_by_swift.cc index 11efc2c07dd..e1506be1d55 100644 --- a/Firestore/core/swift/src/used_by_swift.cc +++ b/Firestore/core/swift/src/used_by_swift.cc @@ -16,6 +16,7 @@ #include "../include/used_by_swift.h" #include +#include "Firestore/core/include/firebase/firestore/timestamp.h" void firebase::CppInterfaceCalledBySwift::print(std::string content) { std::cout << "C++ function runs with value: " << content << std::endl; diff --git a/Package.swift b/Package.swift index 2cbcf526028..fbea917350d 100644 --- a/Package.swift +++ b/Package.swift @@ -1408,6 +1408,9 @@ func firestoreWrapperTarget() -> Target { func firebaseFirestoreCppTarget() -> Target { return .target( name: "FirebaseFirestoreCpp", + dependencies: [ + "FirebaseFirestoreInternalWrapper", + ], path: "Firestore/core/swift", publicHeadersPath: "include", // Path to the public headers cxxSettings: [