Skip to content

Commit

Permalink
iOS Integration Validator 2.0 (#1439)
Browse files Browse the repository at this point in the history
* integration-validator-2.0

* Removed file logger from tvOS

* Added tvOS conditional headers

* Change header to public to fix test failure

* Fixed testbed

* fix: PR changes

* fix: testbed file visibility

* SDK-2533 Integration validator crash fix (#1467)

* Fixed function compareUriSchemes to handle empty strings
* Added wrapper function for compareUriSchemes to make it testable.
* Added unit test

---------

Co-authored-by: ndixit-branch <[email protected]>
  • Loading branch information
sharath-branch and NidhiDixit09 authored Jan 21, 2025
1 parent 8d38849 commit 03b17b6
Show file tree
Hide file tree
Showing 11 changed files with 417 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions Branch-TestBed/Branch-SDK-Tests/BNCSystemObserverTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#import <XCTest/XCTest.h>
#import "BNCSystemObserver.h"

@interface BNCSystemObserver ()
+ (BOOL)compareUriSchemes:(NSString *)serverUriScheme With:(NSArray *)urlTypes;
@end

@interface BNCSystemObserverTests : XCTestCase

@end
Expand Down Expand Up @@ -100,4 +104,35 @@ - (void)testIsAppClip {
XCTAssert(![BNCSystemObserver isAppClip]);
}

- (void)testCompareURIScemes {

NSString *serverUriScheme = @"bnctest://";
NSArray *urlTypes = @[@{@"CFBundleURLSchemes" : @[@""]}, @{@"CFBundleURLSchemes" : @[@"bnctest", @"xyzs"]}];

XCTAssertTrue([BNCSystemObserver compareUriSchemes:serverUriScheme With:urlTypes]);

XCTAssertFalse([BNCSystemObserver compareUriSchemes:serverUriScheme With:nil]);

XCTAssertFalse([BNCSystemObserver compareUriSchemes:nil With:nil]);

XCTAssertFalse([BNCSystemObserver compareUriSchemes:nil With:urlTypes]);

serverUriScheme = @":/";
XCTAssertFalse([BNCSystemObserver compareUriSchemes:serverUriScheme With:urlTypes]);

serverUriScheme = @"bnctest";
XCTAssertTrue([BNCSystemObserver compareUriSchemes:serverUriScheme With:urlTypes]);

serverUriScheme = @"bnctest://";
urlTypes = @[ @{@"CFBundleURLSchemes" : @[@"bnctestX", @"xyzs"]}];
XCTAssertFalse([BNCSystemObserver compareUriSchemes:serverUriScheme With:urlTypes]);

serverUriScheme = @"://";
XCTAssertFalse([BNCSystemObserver compareUriSchemes:serverUriScheme With:urlTypes]);

XCTAssertFalse([BNCSystemObserver compareUriSchemes:@"" With:urlTypes]);

XCTAssertFalse([BNCSystemObserver compareUriSchemes:@"" With:@[@{}]]);
}

@end
8 changes: 8 additions & 0 deletions Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@
C1614D56285BC8A00098946B /* LinkPresentation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1614D55285BC8A00098946B /* LinkPresentation.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
C17DAF7B2AC20C2000B16B1A /* BranchClassTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C17DAF7A2AC20C2000B16B1A /* BranchClassTests.m */; };
C1CC888229BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C1CC888129BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m */; };
E51F642A2CF46899000858D2 /* BranchFileLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = E51F64292CF46899000858D2 /* BranchFileLogger.h */; };
E56394312CC7AC9F00E18E65 /* BranchFileLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = E563942F2CC7AC9500E18E65 /* BranchFileLogger.m */; };
E72489D228E40D0200DCD8FD /* PasteControlViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E72489D128E40D0200DCD8FD /* PasteControlViewController.m */; };
E7A728BD2AA9A112009343B7 /* BNCAPIServerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A728BC2AA9A112009343B7 /* BNCAPIServerTest.m */; };
F1CF14111F4CC79F00BB2694 /* CoreSpotlight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 67F270881BA9FCFF002546A7 /* CoreSpotlight.framework */; settings = {ATTRIBUTES = (Required, ); }; };
Expand Down Expand Up @@ -536,6 +538,8 @@
C1614D55285BC8A00098946B /* LinkPresentation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LinkPresentation.framework; path = System/Library/Frameworks/LinkPresentation.framework; sourceTree = SDKROOT; };
C17DAF7A2AC20C2000B16B1A /* BranchClassTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BranchClassTests.m; sourceTree = "<group>"; };
C1CC888129BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCReferringURLUtilityTests.m; sourceTree = "<group>"; };
E51F64292CF46899000858D2 /* BranchFileLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BranchFileLogger.h; sourceTree = "<group>"; };
E563942F2CC7AC9500E18E65 /* BranchFileLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchFileLogger.m; sourceTree = "<group>"; };
E72489D028E40D0200DCD8FD /* PasteControlViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteControlViewController.h; sourceTree = "<group>"; };
E72489D128E40D0200DCD8FD /* PasteControlViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PasteControlViewController.m; sourceTree = "<group>"; };
E7A728BC2AA9A112009343B7 /* BNCAPIServerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCAPIServerTest.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -672,6 +676,7 @@
5F644B252B7AA810000DCD78 /* BranchSDK */ = {
isa = PBXGroup;
children = (
E563942F2CC7AC9500E18E65 /* BranchFileLogger.m */,
5F644BB02B7AA811000DCD78 /* BNCAppGroupsData.m */,
5F644BA82B7AA811000DCD78 /* BNCAppleReceipt.m */,
5F644B2B2B7AA810000DCD78 /* BNCApplication.m */,
Expand Down Expand Up @@ -830,6 +835,7 @@
5F644B862B7AA811000DCD78 /* NSError+Branch.h */,
5F644B822B7AA811000DCD78 /* NSMutableDictionary+Branch.h */,
5F644B8B2B7AA811000DCD78 /* NSString+Branch.h */,
E51F64292CF46899000858D2 /* BranchFileLogger.h */,
5F644B752B7AA810000DCD78 /* UIViewController+Branch.h */,
);
path = Private;
Expand Down Expand Up @@ -954,6 +960,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
E51F642A2CF46899000858D2 /* BranchFileLogger.h in Headers */,
5F644BE52B7AA811000DCD78 /* BNCLinkData.h in Headers */,
5F644BE62B7AA811000DCD78 /* BranchDelegate.h in Headers */,
5F644BE72B7AA811000DCD78 /* BranchQRCode.h in Headers */,
Expand Down Expand Up @@ -1313,6 +1320,7 @@
5F644BD72B7AA811000DCD78 /* BNCNetworkService.m in Sources */,
5F644C402B7AA811000DCD78 /* UIViewController+Branch.m in Sources */,
5F644BC12B7AA811000DCD78 /* BNCServerRequestQueue.m in Sources */,
E56394312CC7AC9F00E18E65 /* BranchFileLogger.m in Sources */,
5F644C452B7AA811000DCD78 /* BranchOpenRequest.m in Sources */,
5F644C312B7AA811000DCD78 /* BNCLinkData.m in Sources */,
5F644BD22B7AA811000DCD78 /* BranchContentDiscoveryManifest.m in Sources */,
Expand Down
14 changes: 14 additions & 0 deletions BranchSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,11 @@
5FCDD5B22B7AC89100EAF29F /* BranchSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FF2AFDF28E7C22100393216 /* BranchSDK.h */; settings = {ATTRIBUTES = (Public, ); }; };
5FCDD5B32B7AC89200EAF29F /* BranchSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FF2AFDF28E7C22100393216 /* BranchSDK.h */; settings = {ATTRIBUTES = (Public, ); }; };
5FCDD5B42B7AC89200EAF29F /* BranchSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FF2AFDF28E7C22100393216 /* BranchSDK.h */; settings = {ATTRIBUTES = (Public, ); }; };
E52E5B062CC79E4E00F553EE /* BranchFileLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = E52E5B052CC79E4E00F553EE /* BranchFileLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
E52E5B072CC79E4E00F553EE /* BranchFileLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = E52E5B052CC79E4E00F553EE /* BranchFileLogger.h */; };
E52E5B0A2CC79E5C00F553EE /* BranchFileLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = E52E5B092CC79E5C00F553EE /* BranchFileLogger.m */; };
E52E5B0B2CC79E5C00F553EE /* BranchFileLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = E52E5B092CC79E5C00F553EE /* BranchFileLogger.m */; };
E563942E2CC7A8E600E18E65 /* BranchFileLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = E52E5B052CC79E4E00F553EE /* BranchFileLogger.h */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -698,6 +703,8 @@
5FF2AFDC28E7BF8A00393216 /* build_xcframework.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = build_xcframework.sh; sourceTree = "<group>"; };
5FF2AFDE28E7C22100393216 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
5FF2AFDF28E7C22100393216 /* BranchSDK.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BranchSDK.h; sourceTree = "<group>"; };
E52E5B052CC79E4E00F553EE /* BranchFileLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BranchFileLogger.h; sourceTree = "<group>"; };
E52E5B092CC79E5C00F553EE /* BranchFileLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchFileLogger.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -811,6 +818,7 @@
5FCDD36B2B7AC6A100EAF29F /* BranchSDK */ = {
isa = PBXGroup;
children = (
E52E5B092CC79E5C00F553EE /* BranchFileLogger.m */,
5FCDD3F62B7AC6A100EAF29F /* BNCAppGroupsData.m */,
5FCDD3EE2B7AC6A100EAF29F /* BNCAppleReceipt.m */,
5FCDD3712B7AC6A100EAF29F /* BNCApplication.m */,
Expand Down Expand Up @@ -969,6 +977,7 @@
5FCDD3CC2B7AC6A100EAF29F /* NSError+Branch.h */,
5FCDD3C82B7AC6A100EAF29F /* NSMutableDictionary+Branch.h */,
5FCDD3D12B7AC6A100EAF29F /* NSString+Branch.h */,
E52E5B052CC79E4E00F553EE /* BranchFileLogger.h */,
5FCDD3BB2B7AC6A100EAF29F /* UIViewController+Branch.h */,
);
path = Private;
Expand Down Expand Up @@ -1029,6 +1038,7 @@
5FCDD4A12B7AC6A200EAF29F /* BNCServerResponse.h in Headers */,
5FCDD4C22B7AC6A200EAF29F /* BranchDeepLinkingController.h in Headers */,
5FCDD4B92B7AC6A200EAF29F /* BranchPasteControl.h in Headers */,
E52E5B062CC79E4E00F553EE /* BranchFileLogger.h in Headers */,
5FCDD5072B7AC6A300EAF29F /* BNCUrlQueryParameter.h in Headers */,
5FCDD5462B7AC6A300EAF29F /* BNCConfig.h in Headers */,
5FCDD4E62B7AC6A200EAF29F /* UIViewController+Branch.h in Headers */,
Expand Down Expand Up @@ -1110,6 +1120,7 @@
5FCDD4C32B7AC6A200EAF29F /* BranchDeepLinkingController.h in Headers */,
5FCDD4BA2B7AC6A200EAF29F /* BranchPasteControl.h in Headers */,
5FCDD49F2B7AC6A200EAF29F /* Branch.h in Headers */,
E52E5B072CC79E4E00F553EE /* BranchFileLogger.h in Headers */,
5FCDD5082B7AC6A300EAF29F /* BNCUrlQueryParameter.h in Headers */,
5FCDD5472B7AC6A300EAF29F /* BNCConfig.h in Headers */,
5F5FDA1B2B7DE31E00F14A43 /* BranchLogger.h in Headers */,
Expand Down Expand Up @@ -1190,6 +1201,7 @@
5FCDD4A02B7AC6A200EAF29F /* Branch.h in Headers */,
5FCDD5092B7AC6A300EAF29F /* BNCUrlQueryParameter.h in Headers */,
5FCDD5482B7AC6A300EAF29F /* BNCConfig.h in Headers */,
E563942E2CC7A8E600E18E65 /* BranchFileLogger.h in Headers */,
5FCDD4E82B7AC6A200EAF29F /* UIViewController+Branch.h in Headers */,
5FCDD54B2B7AC6A300EAF29F /* BranchConstants.h in Headers */,
5F5FDA1C2B7DE31E00F14A43 /* BranchLogger.h in Headers */,
Expand Down Expand Up @@ -1608,6 +1620,7 @@
5FCDD4592B7AC6A100EAF29F /* BNCNetworkService.m in Sources */,
5FCDD5942B7AC6A400EAF29F /* UIViewController+Branch.m in Sources */,
5FCDD4172B7AC6A100EAF29F /* BNCServerRequestQueue.m in Sources */,
E52E5B0A2CC79E5C00F553EE /* BranchFileLogger.m in Sources */,
5FCDD5A32B7AC6A400EAF29F /* BranchOpenRequest.m in Sources */,
5FCDD5672B7AC6A300EAF29F /* BNCLinkData.m in Sources */,
5FCDD44A2B7AC6A100EAF29F /* BranchContentDiscoveryManifest.m in Sources */,
Expand Down Expand Up @@ -1712,6 +1725,7 @@
5FCDD45A2B7AC6A100EAF29F /* BNCNetworkService.m in Sources */,
5FCDD5952B7AC6A400EAF29F /* UIViewController+Branch.m in Sources */,
5FCDD4182B7AC6A100EAF29F /* BNCServerRequestQueue.m in Sources */,
E52E5B0B2CC79E5C00F553EE /* BranchFileLogger.m in Sources */,
5FCDD5A42B7AC6A400EAF29F /* BranchOpenRequest.m in Sources */,
5FCDD5682B7AC6A400EAF29F /* BNCLinkData.m in Sources */,
5FCDD44B2B7AC6A100EAF29F /* BranchContentDiscoveryManifest.m in Sources */,
Expand Down
28 changes: 24 additions & 4 deletions Sources/BranchSDK/BNCSystemObserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,37 @@ + (NSString *)defaultURIScheme {

+ (BOOL)compareUriSchemes : (NSString *) serverUriScheme {
NSArray *urlTypes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];
return [self compareUriSchemes:serverUriScheme With:urlTypes];
}

+ (BOOL)compareUriSchemes:(NSString *)serverUriScheme With:(NSArray *)urlTypes {
NSString * serverUriSchemeWithoutSuffix ;

if ([serverUriScheme hasSuffix:@"://"]) {
serverUriSchemeWithoutSuffix = [serverUriScheme substringToIndex:[serverUriScheme length] - 3];
} else {
serverUriSchemeWithoutSuffix = serverUriScheme;
}

for (NSDictionary *urlType in urlTypes) {

NSArray *urlSchemes = [urlType objectForKey:@"CFBundleURLSchemes"];
for (NSString *uriScheme in urlSchemes) {
NSString * serverUriSchemeWithoutSuffix = [serverUriScheme substringToIndex:[serverUriScheme length] - 3];
if ([uriScheme isEqualToString:serverUriSchemeWithoutSuffix]) {
return true; }
return true;
}
}
}
return false;
}

+ (BOOL)compareLinkDomain:(NSString *)serverLinkDomain {
NSArray *linkDomains = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"branch_universal_link_domains"];

for (NSString *domain in linkDomains) {
if ([domain isEqualToString:serverLinkDomain]) {
return true;
}
// If no Uri schemes match the one set on the dashboard
return false;
}
return false;
}
Expand Down
Loading

0 comments on commit 03b17b6

Please sign in to comment.