Skip to content

Commit e69c701

Browse files
authored
Firestore and Swift Package Manager (#6072)
1 parent 9508dc4 commit e69c701

File tree

2 files changed

+114
-8
lines changed

2 files changed

+114
-8
lines changed

Package.swift

Lines changed: 112 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ let package = Package(
2525
name: "Firebase",
2626
platforms: [.iOS(.v9), .macOS(.v10_11), .tvOS(.v10)],
2727
products: [
28-
// Products define the executables and libraries produced by a package, and make them visible to
29-
// other packages.
3028
.library(
3129
name: "Firebase",
3230
targets: ["Firebase"]
@@ -47,6 +45,14 @@ let package = Package(
4745
name: "FirebaseDatabase",
4846
targets: ["FirebaseDatabase"]
4947
),
48+
.library(
49+
name: "FirebaseFirestore",
50+
targets: ["FirebaseFirestore"]
51+
),
52+
.library(
53+
name: "FirebaseFirestoreSwift",
54+
targets: ["FirebaseFirestoreSwift"]
55+
),
5056
.library(
5157
name: "FirebaseFunctions",
5258
targets: ["FirebaseFunctions"]
@@ -71,6 +77,12 @@ let package = Package(
7177
name: "FirebaseStorageSwift",
7278
targets: ["FirebaseStorageSwift"]
7379
),
80+
81+
// Not intended for public consumption, but needed for FirebaseUI.
82+
.library(
83+
name: "GoogleUtilities_UserDefaults",
84+
targets: ["GoogleUtilities_UserDefaults"]
85+
),
7486
],
7587
dependencies: [
7688
.package(name: "Promises", url: "https://github.com/google/promises.git", "1.2.8" ..< "1.3.0"),
@@ -84,14 +96,18 @@ let package = Package(
8496
url: "https://github.com/paulb777/nanopb.git",
8597
.revision("82230e9998a35a3d2144884204db64f045c880c4")
8698
),
99+
.package(
100+
name: "abseil",
101+
url: "https://github.com/paulb777/abseil-cpp.git",
102+
.revision("7790dc1")
103+
),
104+
.package(name: "gRPC", url: "https://github.com/paulb777/grpc.git", .revision("37a9e06cd8")),
87105
.package(name: "OCMock", url: "https://github.com/paulb777/ocmock.git", .revision("7291762")),
88106
.package(name: "leveldb", url: "https://github.com/paulb777/leveldb.git", .revision("3f04697")),
89107
// Branches need a force update with a run with the revision set like below.
90108
// .package(url: "https://github.com/paulb777/nanopb.git", .revision("564392bd87bd093c308a3aaed3997466efb95f74"))
91109
],
92110
targets: [
93-
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
94-
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
95111
.testTarget(
96112
name: "firebase-test",
97113
dependencies: [
@@ -102,6 +118,8 @@ let package = Package(
102118
"FirebaseCrashlytics",
103119
"FirebaseCore",
104120
"FirebaseDatabase",
121+
"FirebaseFirestore",
122+
"FirebaseFirestoreSwift",
105123
"FirebaseInstallations",
106124
// "FirebaseInstanceID",
107125
"FirebaseRemoteConfig",
@@ -117,7 +135,7 @@ let package = Package(
117135
"GoogleUtilities_NSData",
118136
"GoogleUtilities_Reachability",
119137
"GoogleUtilities_UserDefaults",
120-
"nanopb",
138+
.product(name: "nanopb", package: "nanopb"),
121139
]
122140
),
123141
.target(
@@ -323,9 +341,9 @@ let package = Package(
323341
),
324342
.target(
325343
name: "FirebaseCrashlytics",
326-
dependencies: ["FirebaseCore", "FirebaseInstallations",
344+
dependencies: ["FirebaseCore", "FirebaseInstallations", "GoogleDataTransport",
327345
.product(name: "FBLPromises", package: "Promises"),
328-
"GoogleDataTransport", "nanopb"],
346+
.product(name: "nanopb", package: "nanopb")],
329347
path: "Crashlytics",
330348
exclude: [
331349
"run",
@@ -390,6 +408,90 @@ let package = Package(
390408
]
391409
),
392410

411+
.target(
412+
name: "FirebaseFirestore",
413+
dependencies: [
414+
"FirebaseCore",
415+
"leveldb",
416+
.product(name: "nanopb", package: "nanopb"),
417+
.product(name: "abseil", package: "abseil"),
418+
.product(name: "gRPC-cpp", package: "gRPC"),
419+
],
420+
path: "Firestore",
421+
exclude: [
422+
"CHANGELOG.md",
423+
"CMakeLists.txt",
424+
"Example/",
425+
"Protos/CMakeLists.txt",
426+
"Protos/Podfile",
427+
"Protos/README.md",
428+
"Protos/build_protos.py",
429+
"Protos/cpp/",
430+
"Protos/lib/",
431+
"Protos/nanopb_cpp_generator.py",
432+
"Protos/protos/",
433+
"README.md",
434+
"Source/CMakeLists.txt",
435+
"Swift/",
436+
"core/CMakeLists.txt",
437+
"core/src/util/config_detected.h.in",
438+
"core/test/",
439+
"fuzzing/",
440+
"test.sh",
441+
"third_party/",
442+
443+
// Exclude alternate implementations for other platforms
444+
"core/src/api/input_validation_std.cc",
445+
"core/src/remote/connectivity_monitor_noop.cc",
446+
"core/src/util/filesystem_win.cc",
447+
"core/src/util/hard_assert_stdio.cc",
448+
"core/src/util/log_stdio.cc",
449+
"core/src/util/secure_random_openssl.cc",
450+
],
451+
sources: [
452+
"Source/",
453+
"Protos/nanopb/",
454+
"core/include/",
455+
"core/src",
456+
],
457+
publicHeadersPath: "Source/Public",
458+
cSettings: [
459+
.headerSearchPath("../"),
460+
.headerSearchPath("Source/Public"),
461+
.headerSearchPath("Protos/nanopb"),
462+
463+
.define("PB_FIELD_32BIT", to: "1"),
464+
.define("PB_NO_PACKED_STRUCTS", to: "1"),
465+
.define("PB_ENABLE_MALLOC", to: "1"),
466+
.define("FIRFirestore_VERSION", to: "0.0.1"), // TODO: Fix version
467+
]
468+
),
469+
.target(
470+
name: "FirebaseFirestoreSwift",
471+
dependencies: ["FirebaseFirestore"],
472+
path: "Firestore",
473+
exclude: [
474+
"CHANGELOG.md",
475+
"CMakeLists.txt",
476+
"Example/",
477+
"Protos/",
478+
"README.md",
479+
"Source/",
480+
"core/",
481+
"fuzzing/",
482+
"test.sh",
483+
"Swift/CHANGELOG.md",
484+
"Swift/README.md",
485+
"Swift/Tests/",
486+
"third_party/FirestoreEncoder/LICENSE",
487+
"third_party/FirestoreEncoder/METADATA",
488+
],
489+
sources: [
490+
"Swift/Source/",
491+
"third_party/FirestoreEncoder/",
492+
]
493+
),
494+
393495
.target(
394496
name: "FirebaseFunctions",
395497
dependencies: [
@@ -497,7 +599,9 @@ let package = Package(
497599
),
498600
.target(
499601
name: "GoogleDataTransport",
500-
dependencies: ["nanopb"],
602+
dependencies: [
603+
.product(name: "nanopb", package: "nanopb"),
604+
],
501605
path: "GoogleDataTransport",
502606
exclude: [
503607
"CHANGELOG.md",

Tests/firebase-test/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import FirebaseCore
1818
import FirebaseAuth
1919
import FirebaseABTesting
2020
import FirebaseCrashlytics
21+
import FirebaseFirestore
22+
import FirebaseFirestoreSwift
2123
import FirebaseFunctions
2224
import FirebaseInstallations
2325
// import FirebaseInstanceID

0 commit comments

Comments
 (0)