Skip to content

Commit 6b29df7

Browse files
committed
init
1 parent 9c423fb commit 6b29df7

File tree

6 files changed

+81
-2
lines changed

6 files changed

+81
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// SwiftCppAPI.swift
3+
// Firebase
4+
//
5+
// Created by Cheryl Lin on 2024-10-22.
6+
//
7+
8+
import FirebaseFirestoreCpp
9+
10+
public class SwiftCppWrapper {
11+
init(_ value : String ){
12+
_ = UsedBySwift(std.string(value))
13+
}
14+
}

Firestore/core/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ firebase_ios_glob(
218218
src/objc/*.h
219219
src/remote/*.cc
220220
src/remote/*.h
221+
swift/include/*.h
222+
swift/src/*.cc
223+
swift/umbrella/*.h
221224
EXCLUDE ${nanopb_sources}
222225
)
223226

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Created by Cheryl Lin on 2024-10-22.
3+
//
4+
5+
#ifndef FIREBASE_USED_BY_SWIFT_H
6+
#define FIREBASE_USED_BY_SWIFT_H
7+
8+
#include <string>
9+
10+
class UsedBySwift {
11+
public:
12+
explicit UsedBySwift(std::string content);
13+
};
14+
15+
#endif // FIREBASE_USED_BY_SWIFT_H
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// Created by Cheryl Lin on 2024-10-22.
3+
//
4+
5+
#include "Firestore/core/swift/include/used_by_swift.h"
6+
#include <iostream>
7+
8+
UsedBySwift::UsedBySwift(std::string content) {
9+
std::cout << "ctor runs with value: " << content << std::endl;
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// Created by Cheryl Lin on 2024-10-22.
3+
//
4+
5+
#ifndef FIREBASE_FIREBASEFIRESTORECPP_H
6+
#define FIREBASE_FIREBASEFIRESTORECPP_H
7+
8+
#import "../include/used_by_swift.h"
9+
10+
#endif // FIREBASE_FIREBASEFIRESTORECPP_H

Package.swift

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,10 @@ let package = Package(
476476
dependencies: [
477477
"FirebaseFirestoreTarget",
478478
],
479-
path: "FirebaseCombineSwift/Sources/Firestore"
479+
path: "FirebaseCombineSwift/Sources/Firestore",
480+
swiftSettings: [
481+
.interoperabilityMode(.Cxx), // C++ interoperability setting
482+
]
480483
),
481484
.target(
482485
name: "FirebaseStorageCombineSwift",
@@ -1399,6 +1402,20 @@ func firestoreWrapperTarget() -> Target {
13991402
)
14001403
}
14011404

1405+
func firebaseFirestoreCppTarget() -> Target {
1406+
return .target(
1407+
name: "FirebaseFirestoreCpp",
1408+
path: "Firestore/core/swift",
1409+
sources: [
1410+
"src",
1411+
],
1412+
publicHeadersPath: "include", // Path to the public headers
1413+
cxxSettings: [
1414+
.headerSearchPath("umbrella"), // Ensure the header search path is correct
1415+
]
1416+
)
1417+
}
1418+
14021419
func firestoreTargets() -> [Target] {
14031420
if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil {
14041421
return [
@@ -1469,13 +1486,15 @@ func firestoreTargets() -> [Target] {
14691486
.linkedLibrary("c++"),
14701487
]
14711488
),
1489+
firebaseFirestoreCppTarget(),
14721490
.target(
14731491
name: "FirebaseFirestore",
14741492
dependencies: [
14751493
"FirebaseCore",
14761494
"FirebaseCoreExtension",
14771495
"FirebaseFirestoreInternalWrapper",
14781496
"FirebaseSharedSwift",
1497+
"FirebaseFirestoreCpp",
14791498
],
14801499
path: "Firestore",
14811500
exclude: [
@@ -1496,7 +1515,10 @@ func firestoreTargets() -> [Target] {
14961515
sources: [
14971516
"Swift/Source/",
14981517
],
1499-
resources: [.process("Source/Resources/PrivacyInfo.xcprivacy")]
1518+
resources: [.process("Source/Resources/PrivacyInfo.xcprivacy")],
1519+
swiftSettings: [
1520+
.interoperabilityMode(.Cxx), // C++ interoperability setting
1521+
]
15001522
),
15011523
]
15021524
}
@@ -1542,9 +1564,13 @@ func firestoreTargets() -> [Target] {
15421564
"FirebaseCoreExtension",
15431565
"leveldb",
15441566
"FirebaseSharedSwift",
1567+
"FirebaseFirestoreCpp",
15451568
],
15461569
path: "Firestore/Swift/Source",
15471570
resources: [.process("Resources/PrivacyInfo.xcprivacy")],
1571+
swiftSettings: [
1572+
.interoperabilityMode(.Cxx), // C++ interoperability setting
1573+
],
15481574
linkerSettings: [
15491575
.linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])),
15501576
.linkedFramework("UIKit", .when(platforms: [.iOS, .tvOS])),
@@ -1561,5 +1587,6 @@ func firestoreTargets() -> [Target] {
15611587
publicHeadersPath: "."
15621588
),
15631589
firestoreInternalTarget,
1590+
firebaseFirestoreCppTarget(),
15641591
]
15651592
}

0 commit comments

Comments
 (0)