Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions FirebaseABTesting/Tests/Unit/Utilities/ABTTestUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@

@implementation ABTTestUtilities

+ (NSBundle *)getBundle {
#if SWIFT_PACKAGE
return Firebase_ABTestingUnit_SWIFTPM_MODULE_BUNDLE();
#else
return [NSBundle bundleForClass:[ABTTestUtilities class]];
#endif
}

+ (ABTExperimentPayload *)payloadFromTestFilename:(NSString *)filename {
NSString *testJsonDataFilePath =
[[NSBundle bundleForClass:[ABTTestUtilities class]] pathForResource:filename ofType:@"txt"];
NSBundle *abtBundle = [self getBundle];
NSString *testJsonDataFilePath = [abtBundle pathForResource:filename ofType:@"txt"];
NSError *readTextError = nil;
NSString *fileText = [[NSString alloc] initWithContentsOfFile:testJsonDataFilePath
encoding:NSUTF8StringEncoding
Expand All @@ -36,8 +44,8 @@ + (ABTExperimentPayload *)payloadFromTestFilename:(NSString *)filename {

+ (NSData *)payloadJSONDataFromFile:(NSString *)filename
modifiedStartTime:(nullable NSDate *)modifiedStartTime {
NSString *testJsonDataFilePath =
[[NSBundle bundleForClass:[ABTTestUtilities class]] pathForResource:filename ofType:@"txt"];
NSBundle *abtBundle = [self getBundle];
NSString *testJsonDataFilePath = [abtBundle pathForResource:filename ofType:@"txt"];
NSError *readTextError = nil;
NSString *fileText = [[NSString alloc] initWithContentsOfFile:testJsonDataFilePath
encoding:NSUTF8StringEncoding
Expand Down
23 changes: 9 additions & 14 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,20 +275,15 @@ let package = Package(
.define("FIRABTesting_VERSION", to: "0.0.1"), // TODO: Fix version
]
),
// Disabled. Pending resolution of accessing SPM resources from Objective C.
// See https://forums.swift.org/t/finding-swift-package-manager-resources/38058
// .testTarget(
// name: "ABTestingUnit",
// dependencies: ["FirebaseABTesting", "OCMock"],
// path: "FirebaseABTesting/Tests/Unit",
// resources: [.process("Resources")],
//// resources: [
////
//// "Resources/TestABTPayload1.txt"],
// cSettings: [
// .headerSearchPath("../../.."),
// ]
// ),
.testTarget(
name: "ABTestingUnit",
dependencies: ["FirebaseABTesting", "OCMock"],
path: "FirebaseABTesting/Tests/Unit",
resources: [.process("Resources")],
cSettings: [
.headerSearchPath("../../.."),
]
),
.target(
name: "FirebaseAuth",
dependencies: ["FirebaseCore",
Expand Down