Skip to content

Commit 163cbdd

Browse files
committed
init
1 parent ffe6cf2 commit 163cbdd

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
@@ -477,7 +477,10 @@ let package = Package(
477477
dependencies: [
478478
"FirebaseFirestoreTarget",
479479
],
480-
path: "FirebaseCombineSwift/Sources/Firestore"
480+
path: "FirebaseCombineSwift/Sources/Firestore",
481+
swiftSettings: [
482+
.interoperabilityMode(.Cxx), // C++ interoperability setting
483+
]
481484
),
482485
.target(
483486
name: "FirebaseStorageCombineSwift",
@@ -1392,6 +1395,20 @@ func firestoreWrapperTarget() -> Target {
13921395
)
13931396
}
13941397

1398+
func firebaseFirestoreCppTarget() -> Target {
1399+
return .target(
1400+
name: "FirebaseFirestoreCpp",
1401+
path: "Firestore/core/swift",
1402+
sources: [
1403+
"src",
1404+
],
1405+
publicHeadersPath: "include", // Path to the public headers
1406+
cxxSettings: [
1407+
.headerSearchPath("umbrella"), // Ensure the header search path is correct
1408+
]
1409+
)
1410+
}
1411+
13951412
func firestoreTargets() -> [Target] {
13961413
if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil {
13971414
return [
@@ -1462,13 +1479,15 @@ func firestoreTargets() -> [Target] {
14621479
.linkedLibrary("c++"),
14631480
]
14641481
),
1482+
firebaseFirestoreCppTarget(),
14651483
.target(
14661484
name: "FirebaseFirestore",
14671485
dependencies: [
14681486
"FirebaseCore",
14691487
"FirebaseCoreExtension",
14701488
"FirebaseFirestoreInternalWrapper",
14711489
"FirebaseSharedSwift",
1490+
"FirebaseFirestoreCpp",
14721491
],
14731492
path: "Firestore",
14741493
exclude: [
@@ -1489,7 +1508,10 @@ func firestoreTargets() -> [Target] {
14891508
sources: [
14901509
"Swift/Source/",
14911510
],
1492-
resources: [.process("Source/Resources/PrivacyInfo.xcprivacy")]
1511+
resources: [.process("Source/Resources/PrivacyInfo.xcprivacy")],
1512+
swiftSettings: [
1513+
.interoperabilityMode(.Cxx), // C++ interoperability setting
1514+
]
14931515
),
14941516
]
14951517
}
@@ -1535,9 +1557,13 @@ func firestoreTargets() -> [Target] {
15351557
"FirebaseCoreExtension",
15361558
"leveldb",
15371559
"FirebaseSharedSwift",
1560+
"FirebaseFirestoreCpp",
15381561
],
15391562
path: "Firestore/Swift/Source",
15401563
resources: [.process("Resources/PrivacyInfo.xcprivacy")],
1564+
swiftSettings: [
1565+
.interoperabilityMode(.Cxx), // C++ interoperability setting
1566+
],
15411567
linkerSettings: [
15421568
.linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])),
15431569
.linkedFramework("UIKit", .when(platforms: [.iOS, .tvOS])),
@@ -1554,5 +1580,6 @@ func firestoreTargets() -> [Target] {
15541580
publicHeadersPath: "."
15551581
),
15561582
firestoreInternalTarget,
1583+
firebaseFirestoreCppTarget(),
15571584
]
15581585
}

0 commit comments

Comments
 (0)