Skip to content

Commit d7ddd5b

Browse files
authored
SPM: Build and unit test RTDB (#6022)
1 parent f76c0dc commit d7ddd5b

File tree

7 files changed

+46
-48
lines changed

7 files changed

+46
-48
lines changed

FirebaseDatabase/Sources/Firebase-Prefix.pch

Lines changed: 0 additions & 7 deletions
This file was deleted.

FirebaseDatabase/Sources/Info.plist

Lines changed: 0 additions & 26 deletions
This file was deleted.

FirebaseDatabase/Sources/third_party/FImmutableSortedDictionary/FImmutableSortedDictionary/FImmutableSortedDictionary-Prefix.pch

Lines changed: 0 additions & 7 deletions
This file was deleted.

FirebaseDatabase/Tests/Helpers/FTestBase.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ @implementation FTestBase
2626
+ (void)setUp {
2727
static dispatch_once_t once;
2828
dispatch_once(&once, ^{
29+
#if !SWIFT_PACKAGE
30+
// Disabled for now with SPM. configure is not needed for the unit tests.
2931
[FIRApp configure];
32+
#endif
3033
});
3134
}
3235

FirebaseDatabase/Tests/Unit/FSyncPointTests.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,13 @@ - (void)runTest:(NSDictionary *)testSpec atBasePath:(NSString *)basePath {
464464

465465
- (NSArray *)loadSpecs {
466466
static NSArray *json;
467+
#if SWIFT_PACKAGE
468+
NSBundle *bundle = Firebase_DatabaseUnit_SWIFTPM_MODULE_BUNDLE();
469+
#else
470+
NSBundle *bundle = [NSBundle bundleForClass:[FSyncPointTests class]];
471+
#endif
467472
if (json == nil) {
468-
NSString *syncPointSpec =
469-
[[NSBundle bundleForClass:[FSyncPointTests class]] pathForResource:@"syncPointSpec"
470-
ofType:@"json"];
473+
NSString *syncPointSpec = [bundle pathForResource:@"syncPointSpec" ofType:@"json"];
471474
NSLog(@"%@", syncPointSpec);
472475
NSData *specData = [NSData dataWithContentsOfFile:syncPointSpec];
473476
NSError *error = nil;

FirebaseDatabase/Tests/en.lproj/InfoPlist.strings

Lines changed: 0 additions & 2 deletions
This file was deleted.

Package.swift

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ let package = Package(
7676
url: "https://github.com/paulb777/nanopb.git",
7777
.branch("swift-package-manager")
7878
),
79-
.package(name: "OCMock", url: "https://github.com/paulb777/ocmock.git",
80-
.revision("7291762")),
79+
.package(name: "OCMock", url: "https://github.com/paulb777/ocmock.git", .revision("7291762")),
80+
.package(name: "leveldb", url: "https://github.com/paulb777/leveldb.git", .revision("3f04697")),
8181
// Branches need a force update with a run with the revision set like below.
8282
// .package(url: "https://github.com/paulb777/nanopb.git", .revision("564392bd87bd093c308a3aaed3997466efb95f74"))
8383
],
@@ -93,6 +93,7 @@ let package = Package(
9393
"Firebase",
9494
"FirebaseCrashlytics",
9595
"FirebaseCore",
96+
"FirebaseDatabase",
9697
"FirebaseInstallations",
9798
// "FirebaseInstanceID",
9899
"FirebaseRemoteConfig",
@@ -349,6 +350,38 @@ let package = Package(
349350
.define("PB_ENABLE_MALLOC", to: "1"),
350351
]
351352
),
353+
.target(
354+
name: "FirebaseDatabase",
355+
dependencies: [
356+
"FirebaseCore",
357+
"leveldb",
358+
],
359+
path: "FirebaseDatabase/Sources",
360+
exclude: [
361+
"third_party/Wrap-leveldb/LICENSE",
362+
"third_party/SocketRocket/LICENSE",
363+
"third_party/FImmutableSortedDictionary/LICENSE",
364+
"third_party/SocketRocket/aa2297808c225710e267afece4439c256f6efdb3",
365+
],
366+
publicHeadersPath: "Public",
367+
cSettings: [
368+
.headerSearchPath("../../"),
369+
.define("FIRDatabase_VERSION", to: "0.0.1"), // TODO: Fix version
370+
]
371+
),
372+
.testTarget(
373+
name: "DatabaseUnit",
374+
dependencies: ["FirebaseDatabase", "OCMock", "SharedTestUtilities"],
375+
path: "FirebaseDatabase/Tests/",
376+
exclude: [
377+
"Integration/",
378+
],
379+
resources: [.process("Resources")],
380+
cSettings: [
381+
.headerSearchPath("../.."),
382+
]
383+
),
384+
352385
.target(
353386
name: "FirebaseFunctions",
354387
dependencies: [
@@ -484,5 +517,6 @@ let package = Package(
484517
]
485518
),
486519
],
487-
cLanguageStandard: .c99
520+
cLanguageStandard: .c99,
521+
cxxLanguageStandard: CXXLanguageStandard.gnucxx14
488522
)

0 commit comments

Comments
 (0)