Skip to content

Commit 82a242f

Browse files
authored
[Crashlytics] Adding unit test scheme to SPM (#10511)
1 parent 17cc972 commit 82a242f

16 files changed

+172
-15
lines changed

.github/workflows/crashlytics.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
- name: Initialize xcodebuild
5252
run: scripts/setup_spm_tests.sh
5353
- name: Unit Tests
54-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseCrashlytics ${{ matrix.target }} spmbuildonly
54+
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseCrashlyticsUnit ${{ matrix.target }} spm
5555

5656

5757
catalyst:

Crashlytics/Shared/FIRCLSNetworking/FIRCLSURLBuilder.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ - (NSString *)escapeString:(NSString *)string {
5151
#if TARGET_OS_WATCH
5252
// TODO: Question - Why does watchOS use a different encoding from the other platforms and the
5353
// Android SDK?
54+
// This broken the unit test on watchOS: https://github.com/firebase/firebase-ios-sdk/pull/10511
5455
return
5556
[string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet
5657
URLPathAllowedCharacterSet]];

Crashlytics/UnitTests/FABURLBuilderTests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ - (void)setUp {
3434
- (void)tearDown {
3535
[super tearDown];
3636
}
37-
37+
#if !TARGET_OS_WATCH
3838
- (void)testTheRightUrlEncodingIsUsed {
3939
NSString *actual =
4040
@"https://settings.crashlytics.com/spi/v2/platforms/ios/apps/"
@@ -52,5 +52,5 @@ - (void)testTheRightUrlEncodingIsUsed {
5252
NSString *encoded = [urlBuilder escapeString:actual];
5353
XCTAssertEqualObjects(encoded, expected);
5454
}
55-
55+
#endif
5656
@end

Crashlytics/UnitTests/FIRCLSCompactUnwindTests.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ - (void)tearDown {
4242
}
4343

4444
- (NSString*)resourcePath {
45-
return [[NSBundle bundleForClass:[self class]] resourcePath];
45+
#if SWIFT_PACKAGE
46+
NSBundle* bundle = Firebase_FirebaseCrashlyticsUnit_SWIFTPM_MODULE_BUNDLE();
47+
return [bundle.resourcePath stringByAppendingPathComponent:@"Data"];
48+
#else
49+
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
50+
return bundle.resourcePath;
51+
#endif
4652
}
4753

4854
- (NSString*)pathForResource:(NSString*)name {

Crashlytics/UnitTests/FIRCLSDwarfTests.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ - (void)tearDown {
4242
}
4343

4444
- (NSString*)resourcePath {
45-
return [[NSBundle bundleForClass:[self class]] resourcePath];
45+
#if SWIFT_PACKAGE
46+
NSBundle* bundle = Firebase_FirebaseCrashlyticsUnit_SWIFTPM_MODULE_BUNDLE();
47+
return [bundle.resourcePath stringByAppendingPathComponent:@"Data"];
48+
#else
49+
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
50+
return bundle.resourcePath;
51+
#endif
4652
}
4753

4854
- (NSString*)pathForResource:(NSString*)name {

Crashlytics/UnitTests/FIRCLSInternalReportTests.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ @interface FIRCLSInternalReportTests : XCTestCase
2323
@implementation FIRCLSInternalReportTests
2424

2525
- (NSString *)resourcePath {
26-
return [[NSBundle bundleForClass:[self class]] resourcePath];
26+
#if SWIFT_PACKAGE
27+
NSBundle *bundle = Firebase_FirebaseCrashlyticsUnit_SWIFTPM_MODULE_BUNDLE();
28+
return [bundle.resourcePath stringByAppendingPathComponent:@"Data"];
29+
#else
30+
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
31+
return bundle.resourcePath;
32+
#endif
2733
}
2834

2935
- (NSString *)pathForResource:(NSString *)name {

Crashlytics/UnitTests/FIRCLSMachO/FIRCLSMachOBinaryTests.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
@implementation FIRCLSMachOBinaryTests
2020

2121
- (NSString*)resourcePath {
22-
return [[NSBundle bundleForClass:[self class]] resourcePath];
22+
#if SWIFT_PACKAGE
23+
NSBundle* bundle = Firebase_FirebaseCrashlyticsUnit_SWIFTPM_MODULE_BUNDLE();
24+
#else
25+
NSBundle* bundle = [NSBundle bundleForClass:[self class]];
26+
#endif
27+
return bundle.resourcePath;
2328
}
2429

2530
- (NSURL*)URLForResource:(NSString*)resource {

Crashlytics/UnitTests/FIRCLSMachO/FIRCLSMachOTests.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
@implementation FIRCLSMachOTests
2424

2525
- (NSString*)resourcePath {
26-
return [[NSBundle bundleForClass:[self class]] resourcePath];
26+
#if SWIFT_PACKAGE
27+
NSBundle* bundle = Firebase_FirebaseCrashlyticsUnit_SWIFTPM_MODULE_BUNDLE();
28+
#else
29+
NSBundle* bundle = [NSBundle bundleForClass:[self class]];
30+
#endif
31+
return bundle.resourcePath;
2732
}
2833

2934
- (NSArray*)sortedArchitectures:(id)obj {

Crashlytics/UnitTests/FIRCLSMachO/FIRCLSdSYMTests.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
@implementation FIRCLSdSYMTests
2020

2121
- (NSString*)resourcePath {
22-
return [[NSBundle bundleForClass:[self class]] resourcePath];
22+
#if SWIFT_PACKAGE
23+
NSBundle* bundle = Firebase_FirebaseCrashlyticsUnit_SWIFTPM_MODULE_BUNDLE();
24+
#else
25+
NSBundle* bundle = [NSBundle bundleForClass:[self class]];
26+
#endif
27+
return bundle.resourcePath;
2328
}
2429

2530
- (void)testBundleIdAndExecutablePath {

Crashlytics/UnitTests/FIRCLSProcessReportOperationTests.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ - (void)tearDown {
4242
}
4343

4444
- (NSString *)resourcePath {
45-
return [[NSBundle bundleForClass:[self class]] resourcePath];
45+
#if SWIFT_PACKAGE
46+
NSBundle *bundle = Firebase_FirebaseCrashlyticsUnit_SWIFTPM_MODULE_BUNDLE();
47+
return [bundle.resourcePath stringByAppendingPathComponent:@"Data"];
48+
#else
49+
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
50+
return bundle.resourcePath;
51+
#endif
4652
}
4753

4854
- (NSString *)reportPath {

0 commit comments

Comments
 (0)