diff --git a/.github/workflows/receive-mobileboost-results.yml b/.github/workflows/receive-mobileboost-results.yml new file mode 100644 index 000000000..448af8ef3 --- /dev/null +++ b/.github/workflows/receive-mobileboost-results.yml @@ -0,0 +1,88 @@ +name: Receive MobileBoost Results + +on: + repository_dispatch: + types: [mobileboost-results] + +jobs: + process-results: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Process results + id: process_results + run: | + import json + import os + + # Get the JSON payload from the webhook + payload = ${{ toJson(github.event.client_payload) }} + + # Process the results + total_tests = payload['totalTests'] + failed_tests = payload['failedTests'] + app_info = payload['appInfo'] + app_version = f"{payload['appVersionName']} ({payload['appVersionCode']})" + platform = payload['platform'] + + # Create the Slack message blocks + blocks = [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": f"MobileBoost Test Results for {app_info}", + "emoji": True + } + }, + { + "type": "section", + "fields": [ + {"type": "mrkdwn", "text": f"*Platform:* {platform.capitalize()}"}, + {"type": "mrkdwn", "text": f"*Version:* {app_version}"}, + {"type": "mrkdwn", "text": f"*Total Tests:* {total_tests}"}, + {"type": "mrkdwn", "text": f"*Failed Tests:* {len(failed_tests)}"} + ] + } + ] + + if failed_tests: + blocks.append({"type": "divider"}) + blocks.append({ + "type": "section", + "text": {"type": "mrkdwn", "text": "*Failed Tests:*"} + }) + for test in failed_tests: + blocks.append({ + "type": "section", + "text": { + "type": "mrkdwn", + "text": f"• <{test['recording']}|{test['title']}>\n" + f" Device: {test['device']} ({test['os']})\n" + f" Error: {test['statusMessage']}" + } + }) + else: + blocks.append({ + "type": "section", + "text": {"type": "mrkdwn", "text": "All tests passed successfully! 🎉"} + }) + + # Set output for the next step + print(f"::set-output name=slack_payload::{json.dumps({'blocks': blocks})}") + shell: python + + - name: Send message to Slack + uses: slackapi/slack-github-action@v1.24.0 + with: + channel-id: "C07JDKLFU8N" + payload: ${{ steps.process_results.outputs.slack_payload }} + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.github/workflows/run-mobileboost-tests.yml b/.github/workflows/run-mobileboost-tests.yml new file mode 100644 index 000000000..9c9b89a59 --- /dev/null +++ b/.github/workflows/run-mobileboost-tests.yml @@ -0,0 +1,89 @@ +name: Run MobileBoost Tests on PR +on: + pull_request: + types: [opened, reopened] + workflow_dispatch: + push: + +jobs: + build-and-test: + runs-on: macos-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Build Main Branch-TestBed + run: | + xcodebuild -project Branch-TestBed/Branch-TestBed.xcodeproj \ + -scheme Branch-TestBed \ + -sdk iphonesimulator \ + -configuration Debug \ + -derivedDataPath $PWD/build \ + clean build + + - name: Build DelayedInitTest + run: | + ls + xcodebuild -project Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/ \ + -scheme DelayedInitTest \ + -sdk iphonesimulator \ + -configuration Debug \ + -derivedDataPath $PWD/build_delayed \ + clean build + + - name: Build ScenesTest + run: | + xcodebuild -project Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj \ + -scheme ScenesTest \ + -sdk iphonesimulator \ + -configuration Debug \ + -derivedDataPath $PWD/build_scenes \ + clean build + + - name: Build SwiftUITest + run: | + xcodebuild -project Linking-TestBeds/SwiftUITest/SwiftUITest.xcodeproj \ + -scheme SwiftUITest \ + -sdk iphonesimulator \ + -configuration Debug \ + -derivedDataPath $PWD/build_swiftui \ + clean build + + - name: Compress Main Branch-TestBed + run: | + cd $PWD/build/Build/Products/Debug-iphonesimulator/ + zip -r Branch-TestBed.app.zip Branch-TestBed.app + + - name: Compress DelayedInitTest + run: | + cd $PWD/build_delayed/Build/Products/Debug-iphonesimulator/ + zip -r DelayedInitTest.app.zip DelayedInitTest.app + + - name: Compress ScenesTest + run: | + cd $PWD/build_scenes/Build/Products/Debug-iphonesimulator/ + zip -r ScenesTest.app.zip ScenesTest.app + + - name: Compress SwiftUITest + run: | + cd $PWD/build_swiftui/Build/Products/Debug-iphonesimulator/ + zip -r SwiftUITest.app.zip SwiftUITest.app + + - name: Upload builds to Mobile Boost and Run Tests + run: | + echo "Uploading Branch-TestBed..." + curl -s https://app.mobileboost.io/cli.sh | tr -d '\r' | /bin/bash -s -- "$PWD/build/Build/Products/Debug-iphonesimulator/Branch-TestBed.app.zip" ios + + echo "Uploading DelayedInitTest.app.zip..." + curl -s https://app.mobileboost.io/cli.sh | tr -d '\r' | /bin/bash -s -- "$PWD/build_delayed/Build/Products/Debug-iphonesimulator/DelayedInitTest.app.zip" ios + + echo "Uploading ScenesTest.app.zip..." + curl -s https://app.mobileboost.io/cli.sh | tr -d '\r' | /bin/bash -s -- "$PWD/build_scenes/Build/Products/Debug-iphonesimulator/ScenesTest.app.zip" ios + + echo "Uploading SwiftUITest.app.zip..." + curl -s https://app.mobileboost.io/cli.sh | tr -d '\r' | /bin/bash -s -- "$PWD/build_swiftui/Build/Products/Debug-iphonesimulator/SwiftUITest.app.zip" ios + env: + API_ORG_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }} + API_KEY: ${{ secrets.MOBILEBOOST_API_ORG_KEY }} + TEST_TAGS: Test + shell: bash diff --git a/Branch-TestBed/Branch-TestBed/Branch-TestBed-Info.plist b/Branch-TestBed/Branch-TestBed/Branch-TestBed-Info.plist index e7f466f5c..ecd1ee2a6 100644 --- a/Branch-TestBed/Branch-TestBed/Branch-TestBed-Info.plist +++ b/Branch-TestBed/Branch-TestBed/Branch-TestBed-Info.plist @@ -19,16 +19,20 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.1 + 3.7.0 CFBundleSignature ???? CFBundleURLTypes + CFBundleTypeRole + Editor CFBundleURLSchemes branchtest + CFBundleURLName + io.branch.sdk.Branch-TestBed CFBundleVersion diff --git a/Branch-TestBed/Branch-TestBed/ViewController.m b/Branch-TestBed/Branch-TestBed/ViewController.m index 994b689d4..6ef5b2063 100644 --- a/Branch-TestBed/Branch-TestBed/ViewController.m +++ b/Branch-TestBed/Branch-TestBed/ViewController.m @@ -227,10 +227,12 @@ - (IBAction)setUserIDButtonTouchUpInside:(id)sender { dispatch_async(dispatch_get_main_queue(), ^{ [appDelegate setLogFile:nil]; if (!error) { - NSLog(@"Branch TestBed: Identity Successfully Set%@", params); + NSString* newIdentity = [BNCPreferenceHelper sharedInstance].userIdentity; + + NSLog(@"Branch TestBed: Attempted to set Identity to: %@\nIdentity Successfully Set to: %@", user_id2, newIdentity); [self performSegueWithIdentifier:@"ShowLogOutput" - sender:[NSString stringWithFormat:@"Identity set to: %@\n\n%@", - user_id2, params.description]]; + sender:[NSString stringWithFormat:@"Attempted to set Identity to %@\n Identity set to: %@", + user_id2, newIdentity]]; } else { NSLog(@"Branch TestBed: Error setting identity: %@", error); [self showAlert:@"Unable to Set Identity" withDescription:error.localizedDescription]; @@ -239,6 +241,32 @@ - (IBAction)setUserIDButtonTouchUpInside:(id)sender { }]; } +- (IBAction)setDMAParamsPressed:(id)sender { + [appDelegate setLogFile:@"SetDMAParams"]; + [Branch setDMAParamsForEEA:true AdPersonalizationConsent:true AdUserDataUsageConsent:true]; + + BOOL eeaRegion = [BNCPreferenceHelper sharedInstance].eeaRegion; + BOOL adPersonalizationConsent = [BNCPreferenceHelper sharedInstance].adPersonalizationConsent; + BOOL adUserDataUsageConsent = [BNCPreferenceHelper sharedInstance].adUserDataUsageConsent; + + // Check if all DMA parameters are set to true + if (!eeaRegion || !adPersonalizationConsent || !adUserDataUsageConsent) { + [self showAlert:@"Unable to Set DMA Params" withDescription:@"One or more DMA parameters are not set correctly."]; + return; + } + + NSLog(@"Branch TestBed: Set DMA Params: %@, %@, %@", + eeaRegion ? @"YES" : @"NO", + adPersonalizationConsent ? @"YES" : @"NO", + adUserDataUsageConsent ? @"YES" : @"NO"); + + [self performSegueWithIdentifier:@"ShowLogOutput" sender:[ + NSString stringWithFormat:@"Set DMA Params: %@, %@, %@", + eeaRegion ? @"YES" : @"NO", + adPersonalizationConsent ? @"YES" : @"NO", + adUserDataUsageConsent ? @"YES" : @"NO" + ]]; +} - (IBAction)logoutWithCallback { Branch *branch = [Branch getInstance]; @@ -906,6 +934,10 @@ - (IBAction)shareLinkWithMetadata:(id)sender { [bsl presentActivityViewControllerFromViewController:self anchor:nil]; } +- (IBAction)forceQuitAppPressed:(id)sender { + exit(0); +} + - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 50; } diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/project.pbxproj b/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/project.pbxproj new file mode 100644 index 000000000..248ed3d8d --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/project.pbxproj @@ -0,0 +1,438 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 60; + objects = { + +/* Begin PBXBuildFile section */ + C121D5642C94B67C00DC22DA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C121D5632C94B67C00DC22DA /* AppDelegate.swift */; }; + C121D5662C94B67C00DC22DA /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C121D5652C94B67C00DC22DA /* SceneDelegate.swift */; }; + C121D5682C94B67C00DC22DA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C121D5672C94B67C00DC22DA /* ViewController.swift */; }; + C121D56B2C94B67C00DC22DA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C121D5692C94B67C00DC22DA /* Main.storyboard */; }; + C121D56D2C94B67D00DC22DA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C121D56C2C94B67D00DC22DA /* Assets.xcassets */; }; + C121D5702C94B67D00DC22DA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C121D56E2C94B67D00DC22DA /* LaunchScreen.storyboard */; }; + C121D57C2C94E39E00DC22DA /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D57B2C94E39E00DC22DA /* CoreServices.framework */; }; + C121D57E2C94E3A500DC22DA /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D57D2C94E3A500DC22DA /* SystemConfiguration.framework */; }; + C121D5802C94E3AA00DC22DA /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D57F2C94E3AA00DC22DA /* WebKit.framework */; }; + C121D5822C94E3B100DC22DA /* CoreSpotlight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D5812C94E3B100DC22DA /* CoreSpotlight.framework */; }; + E709037D2D3903F000E61AEF /* BranchSDK in Frameworks */ = {isa = PBXBuildFile; productRef = E709037C2D3903F000E61AEF /* BranchSDK */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + C121D5A12C98FC1D00DC22DA /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + C121D5602C94B67C00DC22DA /* DelayedInitTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DelayedInitTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C121D5632C94B67C00DC22DA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + C121D5652C94B67C00DC22DA /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + C121D5672C94B67C00DC22DA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + C121D56A2C94B67C00DC22DA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + C121D56C2C94B67D00DC22DA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + C121D56F2C94B67D00DC22DA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + C121D5712C94B67D00DC22DA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C121D5772C94E1DB00DC22DA /* DelayedInitTest.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DelayedInitTest.entitlements; sourceTree = ""; }; + C121D57B2C94E39E00DC22DA /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; + C121D57D2C94E3A500DC22DA /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + C121D57F2C94E3AA00DC22DA /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + C121D5812C94E3B100DC22DA /* CoreSpotlight.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreSpotlight.framework; path = System/Library/Frameworks/CoreSpotlight.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C121D55D2C94B67C00DC22DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E709037D2D3903F000E61AEF /* BranchSDK in Frameworks */, + C121D5822C94E3B100DC22DA /* CoreSpotlight.framework in Frameworks */, + C121D5802C94E3AA00DC22DA /* WebKit.framework in Frameworks */, + C121D57E2C94E3A500DC22DA /* SystemConfiguration.framework in Frameworks */, + C121D57C2C94E39E00DC22DA /* CoreServices.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C121D5572C94B67C00DC22DA = { + isa = PBXGroup; + children = ( + C121D5622C94B67C00DC22DA /* DelayedInitTest */, + C121D5612C94B67C00DC22DA /* Products */, + C121D57A2C94E39E00DC22DA /* Frameworks */, + ); + sourceTree = ""; + }; + C121D5612C94B67C00DC22DA /* Products */ = { + isa = PBXGroup; + children = ( + C121D5602C94B67C00DC22DA /* DelayedInitTest.app */, + ); + name = Products; + sourceTree = ""; + }; + C121D5622C94B67C00DC22DA /* DelayedInitTest */ = { + isa = PBXGroup; + children = ( + C121D5772C94E1DB00DC22DA /* DelayedInitTest.entitlements */, + C121D5632C94B67C00DC22DA /* AppDelegate.swift */, + C121D5652C94B67C00DC22DA /* SceneDelegate.swift */, + C121D5672C94B67C00DC22DA /* ViewController.swift */, + C121D5692C94B67C00DC22DA /* Main.storyboard */, + C121D56C2C94B67D00DC22DA /* Assets.xcassets */, + C121D56E2C94B67D00DC22DA /* LaunchScreen.storyboard */, + C121D5712C94B67D00DC22DA /* Info.plist */, + ); + path = DelayedInitTest; + sourceTree = ""; + }; + C121D57A2C94E39E00DC22DA /* Frameworks */ = { + isa = PBXGroup; + children = ( + C121D5812C94E3B100DC22DA /* CoreSpotlight.framework */, + C121D57F2C94E3AA00DC22DA /* WebKit.framework */, + C121D57D2C94E3A500DC22DA /* SystemConfiguration.framework */, + C121D57B2C94E39E00DC22DA /* CoreServices.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C121D55F2C94B67C00DC22DA /* DelayedInitTest */ = { + isa = PBXNativeTarget; + buildConfigurationList = C121D5742C94B67D00DC22DA /* Build configuration list for PBXNativeTarget "DelayedInitTest" */; + buildPhases = ( + C121D55C2C94B67C00DC22DA /* Sources */, + C121D55D2C94B67C00DC22DA /* Frameworks */, + C121D55E2C94B67C00DC22DA /* Resources */, + C121D5A12C98FC1D00DC22DA /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = DelayedInitTest; + packageProductDependencies = ( + E709037C2D3903F000E61AEF /* BranchSDK */, + ); + productName = ScenesTest; + productReference = C121D5602C94B67C00DC22DA /* DelayedInitTest.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C121D5582C94B67C00DC22DA /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1510; + LastUpgradeCheck = 1510; + TargetAttributes = { + C121D55F2C94B67C00DC22DA = { + CreatedOnToolsVersion = 15.1; + }; + }; + }; + buildConfigurationList = C121D55B2C94B67C00DC22DA /* Build configuration list for PBXProject "DelayedInitTest" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C121D5572C94B67C00DC22DA; + packageReferences = ( + E709037B2D3903F000E61AEF /* XCLocalSwiftPackageReference "../.." */, + ); + productRefGroup = C121D5612C94B67C00DC22DA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C121D55F2C94B67C00DC22DA /* DelayedInitTest */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C121D55E2C94B67C00DC22DA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C121D5702C94B67D00DC22DA /* LaunchScreen.storyboard in Resources */, + C121D56D2C94B67D00DC22DA /* Assets.xcassets in Resources */, + C121D56B2C94B67C00DC22DA /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C121D55C2C94B67C00DC22DA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C121D5682C94B67C00DC22DA /* ViewController.swift in Sources */, + C121D5642C94B67C00DC22DA /* AppDelegate.swift in Sources */, + C121D5662C94B67C00DC22DA /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + C121D5692C94B67C00DC22DA /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C121D56A2C94B67C00DC22DA /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + C121D56E2C94B67D00DC22DA /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C121D56F2C94B67D00DC22DA /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C121D5722C94B67D00DC22DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + C121D5732C94B67D00DC22DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + C121D5752C94B67D00DC22DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = DelayedInitTest/DelayedInitTest.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = R63EM248DP; + FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/BranchSDK.xcframework/**"; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = DelayedInitTest/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = DelayedInitTest; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 3.6.2; + PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.Branch-TestBed"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + C121D5762C94B67D00DC22DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = DelayedInitTest/DelayedInitTest.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = R63EM248DP; + FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/BranchSDK.xcframework/**"; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = DelayedInitTest/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = DelayedInitTest; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 3.6.2; + PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.Branch-TestBed"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C121D55B2C94B67C00DC22DA /* Build configuration list for PBXProject "DelayedInitTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C121D5722C94B67D00DC22DA /* Debug */, + C121D5732C94B67D00DC22DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C121D5742C94B67D00DC22DA /* Build configuration list for PBXNativeTarget "DelayedInitTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C121D5752C94B67D00DC22DA /* Debug */, + C121D5762C94B67D00DC22DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + E709037B2D3903F000E61AEF /* XCLocalSwiftPackageReference "../.." */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ../..; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + E709037C2D3903F000E61AEF /* BranchSDK */ = { + isa = XCSwiftPackageProductDependency; + productName = BranchSDK; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = C121D5582C94B67C00DC22DA /* Project object */; +} diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/xcshareddata/xcschemes/DelayedInitTest.xcscheme b/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/xcshareddata/xcschemes/DelayedInitTest.xcscheme new file mode 100644 index 000000000..47acdef57 --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest.xcodeproj/xcshareddata/xcschemes/DelayedInitTest.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/AppDelegate.swift b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/AppDelegate.swift new file mode 100644 index 000000000..f242aea98 --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/AppDelegate.swift @@ -0,0 +1,53 @@ +// +// AppDelegate.swift +// DelayedInitTest +// +// Created by Nipun Singh on 9/13/24. +// + +import UIKit +import BranchSDK + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + redirectConsoleLogs() + + Branch.enableLogging(at: .verbose, withCallback: nil) + + return true + } + + func applicationWillTerminate(_ application: UIApplication) { + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + func redirectConsoleLogs() { + let logsFilePath = getLogFilePath() + freopen(logsFilePath, "a+", stdout) + freopen(logsFilePath, "a+", stderr) + print("App started and console redirection initialized.") + } + + func getLogFilePath() -> String { + let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! + return documentsDirectory.appendingPathComponent("console.log").path + } +} + diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/AccentColor.colorset/Contents.json b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..eb8789700 --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/AppIcon.appiconset/Contents.json b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..44ac9cc28 --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,14 @@ +{ + "images" : [ + { + "filename" : "appstore.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/AppIcon.appiconset/appstore.png b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/AppIcon.appiconset/appstore.png new file mode 100644 index 000000000..1969a1810 Binary files /dev/null and b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/AppIcon.appiconset/appstore.png differ diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/Contents.json b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image.imageset/Contents.json b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image.imageset/Contents.json new file mode 100644 index 000000000..2fe69497a --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "master-unknown-Tz-stNLUwyU-unsplash.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image.imageset/master-unknown-Tz-stNLUwyU-unsplash.jpg b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image.imageset/master-unknown-Tz-stNLUwyU-unsplash.jpg new file mode 100644 index 000000000..c5ce0c6b1 Binary files /dev/null and b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image.imageset/master-unknown-Tz-stNLUwyU-unsplash.jpg differ diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image_2.imageset/Contents.json b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image_2.imageset/Contents.json new file mode 100644 index 000000000..0e1954384 --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image_2.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "tim-mossholder-hOVOEMrg9Tk-unsplash.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image_2.imageset/tim-mossholder-hOVOEMrg9Tk-unsplash.jpg b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image_2.imageset/tim-mossholder-hOVOEMrg9Tk-unsplash.jpg new file mode 100644 index 000000000..b52aa421c Binary files /dev/null and b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Assets.xcassets/dummy_image_2.imageset/tim-mossholder-hOVOEMrg9Tk-unsplash.jpg differ diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Base.lproj/LaunchScreen.storyboard b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..865e9329f --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Base.lproj/Main.storyboard b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Base.lproj/Main.storyboard new file mode 100644 index 000000000..f250e0eae --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Base.lproj/Main.storyboard @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/DelayedInitTest.entitlements b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/DelayedInitTest.entitlements new file mode 100644 index 000000000..417c603af --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/DelayedInitTest.entitlements @@ -0,0 +1,13 @@ + + + + + com.apple.developer.associated-domains + + applinks:bnctestbed.app.link + applinks:bnctestbed.test-app.link + applinks:bnctestbed-alternate.app.link + applinks:bnc.lt + + + diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Info.plist b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Info.plist new file mode 100644 index 000000000..13f434fa5 --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/Info.plist @@ -0,0 +1,52 @@ + + + + + branch_key + + live + key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB + test + key_test_hdcBLUy1xZ1JD0tKg7qrLcgirFmPPVJc + + branch_universal_link_domains + + bnctestbed.app.link + bnctestbed.test-app.link + bnctestbed-alternate.app.link + bnc.lt + + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + branchtest + + CFBundleURLName + io.branch.sdk.Branch-TestBed + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + + diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/SceneDelegate.swift b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/SceneDelegate.swift new file mode 100644 index 000000000..f896965fc --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/SceneDelegate.swift @@ -0,0 +1,123 @@ +// +// SceneDelegate.swift +// DelayedInitTest +// +// Created by Nipun Singh on 9/13/24. +// + +import UIKit +import BranchSDK + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + let firstOpen = false + + if !UserDefaults.standard.isFirstOpen { + print("NOT First App Open") + BranchScene.shared().initSession(registerDeepLinkHandler: { (params, error, scene) in + guard let data = params as? [String: AnyObject] else { return } + print("Branch Params: \(params ?? [:])") + + if (data["+clicked_branch_link"] as! Bool) == true { + self.showAlert(withParams: params ?? [:]) + } + }) + + if let userActivity = connectionOptions.userActivities.first { + print("*** Branch Scene willConnectTo User Activity: \(userActivity)") + BranchScene.shared().scene(scene, continue: userActivity) + } else if !connectionOptions.urlContexts.isEmpty { + print("*** Branch Scene willConnectTo connectionOptions.urlContexts: \(connectionOptions.urlContexts)") + BranchScene.shared().scene(scene, openURLContexts: connectionOptions.urlContexts) + } + } else { + print("First App Open") + } + } + + + func showAlert(withParams params: [AnyHashable: Any]) { + // Convert params to a readable string + let paramsString = params.map { "\($0.key): \($0.value)" }.joined(separator: "\n") + // Create alert + let alert = UIAlertController(title: "✅ Succesfully Deep Linked ", message: paramsString, preferredStyle: .alert) + + // Add OK action + alert.addAction(UIAlertAction(title: "Nice", style: .default, handler: nil)) + + // Present alert + if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene, + let rootVC = scene.windows.first?.rootViewController { + rootVC.present(alert, animated: true, completion: nil) + } + } + + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + func scene(_ scene: UIScene, willContinueUserActivityWithType userActivityType: String) { + scene.userActivity = NSUserActivity(activityType: userActivityType) + scene.delegate = self + } + + func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { + print("*** Branch Scene continueUserActivity User Activity: \(userActivity)") + BranchScene.shared().scene(scene, continue: userActivity) + } + + func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { + print("*** Branch Scene openURLContexts URLContexts: \(URLContexts)") + BranchScene.shared().scene(scene, openURLContexts: URLContexts) + } +} + +extension UserDefaults { + private enum Keys { + static let firstOpen = "firstOpen" + } + + /// Indicates whether the app is opened for the first time. + var isFirstOpen: Bool { + get { + // If the key doesn't exist, it's the first open. + return !bool(forKey: Keys.firstOpen) + } + set { + // Set the key to true after the first open. + set(!newValue, forKey: Keys.firstOpen) + } + } +} diff --git a/Linking-TestBeds/DelayedInitTest/DelayedInitTest/ViewController.swift b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/ViewController.swift new file mode 100644 index 000000000..828093704 --- /dev/null +++ b/Linking-TestBeds/DelayedInitTest/DelayedInitTest/ViewController.swift @@ -0,0 +1,183 @@ +// +// ViewController.swift +// DelayedInitTest +// +// Created by Nipun Singh on 9/13/24. +// + +import UIKit +import BranchSDK + +extension Notification.Name { + static let newLogAvailable = Notification.Name("newLogAvailable") +} + +class ViewController: UIViewController { + + private var logsFilePath: String { + let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! + return documentsDirectory.appendingPathComponent("console.log").path + } + + // Create the text view + private let textView: UITextView = { + let tv = UITextView() + tv.isEditable = false // Make it read-only + tv.font = UIFont(name: "Menlo", size: 14) // Console-like font + tv.textContainerInset = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12) // Add padding + tv.layer.cornerRadius = 10 // Rounded corners + tv.layer.borderColor = UIColor.gray.cgColor + tv.clipsToBounds = true + tv.backgroundColor = UIColor(white: 0.95, alpha: 1) // Light gray background for contrast + tv.translatesAutoresizingMaskIntoConstraints = false + return tv + }() + + // Create the "Clear" button as a bar button item + private lazy var clearButton: UIBarButtonItem = { + let button = UIBarButtonItem(title: "Clear", + style: .plain, + target: self, + action: #selector(clearLogs)) + return button + }() + + // "Init Branch" button as a bar button item + private lazy var initBranchButton: UIBarButtonItem = { + let button = UIBarButtonItem(title: "Init Branch", + style: .plain, + target: self, + action: #selector(initBranchTapped)) + return button + }() + + // Flag to prevent multiple initializations + private var isBranchInitialized = false + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + + // Set up the view + setupView() + setupNavigationBar() + setupConstraints() + + displayLogs() + + NotificationCenter.default.addObserver(self, selector: #selector(displayLogs), name: UIApplication.didBecomeActiveNotification, object: nil) + } + + + private func setupView() { + view.backgroundColor = .white + view.addSubview(textView) + } + + private func setupNavigationBar() { + title = "Delayed Init Logs" + navigationItem.rightBarButtonItem = clearButton + navigationItem.leftBarButtonItem = initBranchButton + } + + private func setupConstraints() { + NSLayoutConstraint.activate([ + textView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), + textView.leadingAnchor.constraint(equalTo: view.leadingAnchor), + textView.bottomAnchor.constraint(equalTo: view.bottomAnchor), + textView.trailingAnchor.constraint(equalTo: view.trailingAnchor) + ]) + } + + @objc private func displayLogs() { + let logsFilePath = getLogFilePath() + do { + let logs = try String(contentsOfFile: logsFilePath, encoding: .utf8) + textView.text = logs + } catch { + print("Error reading logs: \(error)") + } + } + + @objc private func clearLogs() { + let logsFilePath = getLogFilePath() + // Truncate the file without deleting it + if let fileHandle = FileHandle(forWritingAtPath: logsFilePath) { + fileHandle.truncateFile(atOffset: 0) + fileHandle.closeFile() + } + textView.text = "Cleared logs!" + } + + private func getLogFilePath() -> String { + let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! + return documentsDirectory.appendingPathComponent("console.log").path + } + + deinit { + NotificationCenter.default.removeObserver(self) + } + + @objc private func initBranchTapped() { + guard !isBranchInitialized else { + showAlert(title: "Branch Already Initialized", message: "Branch SDK has already been initialized.") + return + } + +// // Retrieve persisted launch options +// guard let launchOptions = UserDefaults.standard.retrieveBranchLaunchOptions() else { +// showAlert(title: "Launch Options Missing", message: "No launch options found to initialize Branch.") +// return +// } + +// // Convert stored strings back to objects +// let userActivities = launchOptions.userActivities.map { NSUserActivity(activityType: $0) } +// let urlContexts = launchOptions.urlStrings.compactMap { URL(string: $0) } +// + // Initialize Branch SDK + Branch.getInstance().initSession(launchOptions: nil, andRegisterDeepLinkHandler: { [weak self] params, error in + guard let self = self else { return } + + if let error = error { + self.showAlert(title: "Branch Initialization Error", message: error.localizedDescription) + return + } + + guard let data = params as? [String: AnyObject] else { return } + print("Branch Params: \(params)") + + if let clicked = data["+clicked_branch_link"] as? Bool, clicked == true { + let dataString = data.map { "\($0.key): \($0.value)" }.joined(separator: "\n") + self.showAlert(title: "Succesfully Deeplinked!", message: dataString) + } + }) + +// // Handle user activities +// for activityType in launchOptions.userActivities { +// let userActivity = NSUserActivity(activityType: activityType) +// Branch.getInstance().continue(userActivity) +// } +// +// // Handle URL contexts +// for urlString in launchOptions.urlStrings { +// if let url = URL(string: urlString) { +// Branch.getInstance().handleDeepLink(url) +// } +// } + + isBranchInitialized = true + showAlert(title: "Branch Initialized", message: "Branch SDK has been successfully initialized.") + } + + private func showAlert(title: String, message: String) { + // Create alert + let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) + + // Add OK action + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) + + // Present alert + present(alert, animated: true, completion: nil) + } +} + diff --git a/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/project.pbxproj b/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/project.pbxproj new file mode 100644 index 000000000..00ae48b30 --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/project.pbxproj @@ -0,0 +1,424 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 60; + objects = { + +/* Begin PBXBuildFile section */ + C121D5642C94B67C00DC22DA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C121D5632C94B67C00DC22DA /* AppDelegate.swift */; }; + C121D5662C94B67C00DC22DA /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C121D5652C94B67C00DC22DA /* SceneDelegate.swift */; }; + C121D5682C94B67C00DC22DA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C121D5672C94B67C00DC22DA /* ViewController.swift */; }; + C121D56B2C94B67C00DC22DA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C121D5692C94B67C00DC22DA /* Main.storyboard */; }; + C121D56D2C94B67D00DC22DA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C121D56C2C94B67D00DC22DA /* Assets.xcassets */; }; + C121D5702C94B67D00DC22DA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C121D56E2C94B67D00DC22DA /* LaunchScreen.storyboard */; }; + C121D57C2C94E39E00DC22DA /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D57B2C94E39E00DC22DA /* CoreServices.framework */; }; + C121D57E2C94E3A500DC22DA /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D57D2C94E3A500DC22DA /* SystemConfiguration.framework */; }; + C121D5802C94E3AA00DC22DA /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D57F2C94E3AA00DC22DA /* WebKit.framework */; }; + C121D5822C94E3B100DC22DA /* CoreSpotlight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D5812C94E3B100DC22DA /* CoreSpotlight.framework */; }; + E70903802D396B1700E61AEF /* BranchSDK in Frameworks */ = {isa = PBXBuildFile; productRef = E709037F2D396B1700E61AEF /* BranchSDK */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + C121D5602C94B67C00DC22DA /* ScenesTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ScenesTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C121D5632C94B67C00DC22DA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + C121D5652C94B67C00DC22DA /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + C121D5672C94B67C00DC22DA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + C121D56A2C94B67C00DC22DA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + C121D56C2C94B67D00DC22DA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + C121D56F2C94B67D00DC22DA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + C121D5712C94B67D00DC22DA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C121D5772C94E1DB00DC22DA /* ScenesTest.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ScenesTest.entitlements; sourceTree = ""; }; + C121D57B2C94E39E00DC22DA /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; + C121D57D2C94E3A500DC22DA /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + C121D57F2C94E3AA00DC22DA /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + C121D5812C94E3B100DC22DA /* CoreSpotlight.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreSpotlight.framework; path = System/Library/Frameworks/CoreSpotlight.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C121D55D2C94B67C00DC22DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E70903802D396B1700E61AEF /* BranchSDK in Frameworks */, + C121D5822C94E3B100DC22DA /* CoreSpotlight.framework in Frameworks */, + C121D5802C94E3AA00DC22DA /* WebKit.framework in Frameworks */, + C121D57E2C94E3A500DC22DA /* SystemConfiguration.framework in Frameworks */, + C121D57C2C94E39E00DC22DA /* CoreServices.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C121D5572C94B67C00DC22DA = { + isa = PBXGroup; + children = ( + C121D5622C94B67C00DC22DA /* ScenesTest */, + C121D5612C94B67C00DC22DA /* Products */, + C121D57A2C94E39E00DC22DA /* Frameworks */, + ); + sourceTree = ""; + }; + C121D5612C94B67C00DC22DA /* Products */ = { + isa = PBXGroup; + children = ( + C121D5602C94B67C00DC22DA /* ScenesTest.app */, + ); + name = Products; + sourceTree = ""; + }; + C121D5622C94B67C00DC22DA /* ScenesTest */ = { + isa = PBXGroup; + children = ( + C121D5772C94E1DB00DC22DA /* ScenesTest.entitlements */, + C121D5632C94B67C00DC22DA /* AppDelegate.swift */, + C121D5652C94B67C00DC22DA /* SceneDelegate.swift */, + C121D5672C94B67C00DC22DA /* ViewController.swift */, + C121D5692C94B67C00DC22DA /* Main.storyboard */, + C121D56C2C94B67D00DC22DA /* Assets.xcassets */, + C121D56E2C94B67D00DC22DA /* LaunchScreen.storyboard */, + C121D5712C94B67D00DC22DA /* Info.plist */, + ); + path = ScenesTest; + sourceTree = ""; + }; + C121D57A2C94E39E00DC22DA /* Frameworks */ = { + isa = PBXGroup; + children = ( + C121D5812C94E3B100DC22DA /* CoreSpotlight.framework */, + C121D57F2C94E3AA00DC22DA /* WebKit.framework */, + C121D57D2C94E3A500DC22DA /* SystemConfiguration.framework */, + C121D57B2C94E39E00DC22DA /* CoreServices.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C121D55F2C94B67C00DC22DA /* ScenesTest */ = { + isa = PBXNativeTarget; + buildConfigurationList = C121D5742C94B67D00DC22DA /* Build configuration list for PBXNativeTarget "ScenesTest" */; + buildPhases = ( + C121D55C2C94B67C00DC22DA /* Sources */, + C121D55D2C94B67C00DC22DA /* Frameworks */, + C121D55E2C94B67C00DC22DA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ScenesTest; + packageProductDependencies = ( + E709037F2D396B1700E61AEF /* BranchSDK */, + ); + productName = ScenesTest; + productReference = C121D5602C94B67C00DC22DA /* ScenesTest.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C121D5582C94B67C00DC22DA /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1510; + LastUpgradeCheck = 1510; + TargetAttributes = { + C121D55F2C94B67C00DC22DA = { + CreatedOnToolsVersion = 15.1; + }; + }; + }; + buildConfigurationList = C121D55B2C94B67C00DC22DA /* Build configuration list for PBXProject "ScenesTest" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C121D5572C94B67C00DC22DA; + packageReferences = ( + E709037E2D396B1700E61AEF /* XCLocalSwiftPackageReference "../.." */, + ); + productRefGroup = C121D5612C94B67C00DC22DA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C121D55F2C94B67C00DC22DA /* ScenesTest */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C121D55E2C94B67C00DC22DA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C121D5702C94B67D00DC22DA /* LaunchScreen.storyboard in Resources */, + C121D56D2C94B67D00DC22DA /* Assets.xcassets in Resources */, + C121D56B2C94B67C00DC22DA /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C121D55C2C94B67C00DC22DA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C121D5682C94B67C00DC22DA /* ViewController.swift in Sources */, + C121D5642C94B67C00DC22DA /* AppDelegate.swift in Sources */, + C121D5662C94B67C00DC22DA /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + C121D5692C94B67C00DC22DA /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C121D56A2C94B67C00DC22DA /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + C121D56E2C94B67D00DC22DA /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C121D56F2C94B67D00DC22DA /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C121D5722C94B67D00DC22DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + C121D5732C94B67D00DC22DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + C121D5752C94B67D00DC22DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = ScenesTest/ScenesTest.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = R63EM248DP; + FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/BranchSDK.xcframework/**"; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = ScenesTest/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = ScenesTest; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 3.6.2; + PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.Branch-TestBed"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + C121D5762C94B67D00DC22DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = ScenesTest/ScenesTest.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = R63EM248DP; + FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/BranchSDK.xcframework/**"; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = ScenesTest/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = ScenesTest; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 3.6.2; + PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.Branch-TestBed"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C121D55B2C94B67C00DC22DA /* Build configuration list for PBXProject "ScenesTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C121D5722C94B67D00DC22DA /* Debug */, + C121D5732C94B67D00DC22DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C121D5742C94B67D00DC22DA /* Build configuration list for PBXNativeTarget "ScenesTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C121D5752C94B67D00DC22DA /* Debug */, + C121D5762C94B67D00DC22DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + E709037E2D396B1700E61AEF /* XCLocalSwiftPackageReference "../.." */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ../..; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + E709037F2D396B1700E61AEF /* BranchSDK */ = { + isa = XCSwiftPackageProductDependency; + productName = BranchSDK; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = C121D5582C94B67C00DC22DA /* Project object */; +} diff --git a/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/xcshareddata/xcschemes/ScenesTest.xcscheme b/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/xcshareddata/xcschemes/ScenesTest.xcscheme new file mode 100644 index 000000000..d4c6892bf --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest.xcodeproj/xcshareddata/xcschemes/ScenesTest.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/AppDelegate.swift b/Linking-TestBeds/ScenesTest/ScenesTest/AppDelegate.swift new file mode 100644 index 000000000..a479b2448 --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/AppDelegate.swift @@ -0,0 +1,53 @@ +// +// AppDelegate.swift +// ScenesTest +// +// Created by Nipun Singh on 9/13/24. +// + +import UIKit +import BranchSDK + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + redirectConsoleLogs() + + Branch.enableLogging(at: .verbose, withCallback: nil) + + return true + } + + func applicationWillTerminate(_ application: UIApplication) { + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + func redirectConsoleLogs() { + let logsFilePath = getLogFilePath() + freopen(logsFilePath, "a+", stdout) + freopen(logsFilePath, "a+", stderr) + print("App started and console redirection initialized.") + } + + func getLogFilePath() -> String { + let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! + return documentsDirectory.appendingPathComponent("console.log").path + } +} + diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/AccentColor.colorset/Contents.json b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..eb8789700 --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/AppIcon.appiconset/Contents.json b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..44ac9cc28 --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,14 @@ +{ + "images" : [ + { + "filename" : "appstore.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/AppIcon.appiconset/appstore.png b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/AppIcon.appiconset/appstore.png new file mode 100644 index 000000000..1969a1810 Binary files /dev/null and b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/AppIcon.appiconset/appstore.png differ diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/Contents.json b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image.imageset/Contents.json b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image.imageset/Contents.json new file mode 100644 index 000000000..2fe69497a --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "master-unknown-Tz-stNLUwyU-unsplash.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image.imageset/master-unknown-Tz-stNLUwyU-unsplash.jpg b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image.imageset/master-unknown-Tz-stNLUwyU-unsplash.jpg new file mode 100644 index 000000000..c5ce0c6b1 Binary files /dev/null and b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image.imageset/master-unknown-Tz-stNLUwyU-unsplash.jpg differ diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image_2.imageset/Contents.json b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image_2.imageset/Contents.json new file mode 100644 index 000000000..0e1954384 --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image_2.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "tim-mossholder-hOVOEMrg9Tk-unsplash.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image_2.imageset/tim-mossholder-hOVOEMrg9Tk-unsplash.jpg b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image_2.imageset/tim-mossholder-hOVOEMrg9Tk-unsplash.jpg new file mode 100644 index 000000000..b52aa421c Binary files /dev/null and b/Linking-TestBeds/ScenesTest/ScenesTest/Assets.xcassets/dummy_image_2.imageset/tim-mossholder-hOVOEMrg9Tk-unsplash.jpg differ diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/Base.lproj/LaunchScreen.storyboard b/Linking-TestBeds/ScenesTest/ScenesTest/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..865e9329f --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/Base.lproj/Main.storyboard b/Linking-TestBeds/ScenesTest/ScenesTest/Base.lproj/Main.storyboard new file mode 100644 index 000000000..f250e0eae --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/Base.lproj/Main.storyboard @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/Info.plist b/Linking-TestBeds/ScenesTest/ScenesTest/Info.plist new file mode 100644 index 000000000..13f434fa5 --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/Info.plist @@ -0,0 +1,52 @@ + + + + + branch_key + + live + key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB + test + key_test_hdcBLUy1xZ1JD0tKg7qrLcgirFmPPVJc + + branch_universal_link_domains + + bnctestbed.app.link + bnctestbed.test-app.link + bnctestbed-alternate.app.link + bnc.lt + + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + branchtest + + CFBundleURLName + io.branch.sdk.Branch-TestBed + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + + diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/SceneDelegate.swift b/Linking-TestBeds/ScenesTest/ScenesTest/SceneDelegate.swift new file mode 100644 index 000000000..a890b2619 --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/SceneDelegate.swift @@ -0,0 +1,100 @@ +// +// SceneDelegate.swift +// ScenesTest +// +// Created by Nipun Singh on 9/13/24. +// + +import UIKit +import BranchSDK + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + + BranchScene.shared().initSession(registerDeepLinkHandler: { (params, error, scene) in + guard let data = params as? [String: AnyObject] else { return } + print("Branch Params: \(params ?? [:])") + + if (data["+clicked_branch_link"] as! Bool) == true { + self.showAlert(withParams: params ?? [:]) + } + }) + + if let userActivity = connectionOptions.userActivities.first { + print("*** Branch Scene willConnectTo User Activity: \(userActivity)") + BranchScene.shared().scene(scene, continue: userActivity) + } else if !connectionOptions.urlContexts.isEmpty { + print("*** Branch Scene willConnectTo connectionOptions.urlContexts: \(connectionOptions.urlContexts)") + BranchScene.shared().scene(scene, openURLContexts: connectionOptions.urlContexts) + } + } + + + func showAlert(withParams params: [AnyHashable: Any]) { + // Convert params to a readable string + let paramsString = params.map { "\($0.key): \($0.value)" }.joined(separator: "\n") + // Create alert + let alert = UIAlertController(title: "✅ Succesfully Deep Linked ", message: paramsString, preferredStyle: .alert) + + // Add OK action + alert.addAction(UIAlertAction(title: "Nice", style: .default, handler: nil)) + + // Present alert + if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene, + let rootVC = scene.windows.first?.rootViewController { + rootVC.present(alert, animated: true, completion: nil) + } + } + + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + func scene(_ scene: UIScene, willContinueUserActivityWithType userActivityType: String) { + scene.userActivity = NSUserActivity(activityType: userActivityType) + scene.delegate = self + } + + func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { + print("*** Branch Scene continueUserActivity User Activity: \(userActivity)") + BranchScene.shared().scene(scene, continue: userActivity) + } + + func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { + print("*** Branch Scene openURLContexts URLContexts: \(URLContexts)") + BranchScene.shared().scene(scene, openURLContexts: URLContexts) + } +} + diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/ScenesTest.entitlements b/Linking-TestBeds/ScenesTest/ScenesTest/ScenesTest.entitlements new file mode 100644 index 000000000..417c603af --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/ScenesTest.entitlements @@ -0,0 +1,13 @@ + + + + + com.apple.developer.associated-domains + + applinks:bnctestbed.app.link + applinks:bnctestbed.test-app.link + applinks:bnctestbed-alternate.app.link + applinks:bnc.lt + + + diff --git a/Linking-TestBeds/ScenesTest/ScenesTest/ViewController.swift b/Linking-TestBeds/ScenesTest/ScenesTest/ViewController.swift new file mode 100644 index 000000000..cb0d997ff --- /dev/null +++ b/Linking-TestBeds/ScenesTest/ScenesTest/ViewController.swift @@ -0,0 +1,108 @@ +// +// ViewController.swift +// ScenesTest +// +// Created by Nipun Singh on 9/13/24. +// + +import UIKit + +extension Notification.Name { + static let newLogAvailable = Notification.Name("newLogAvailable") +} + +class ViewController: UIViewController { + + private var logsFilePath: String { + let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! + return documentsDirectory.appendingPathComponent("console.log").path + } + + // Create the text view + private let textView: UITextView = { + let tv = UITextView() + tv.isEditable = false // Make it read-only + tv.font = UIFont(name: "Menlo", size: 14) // Console-like font + tv.textContainerInset = UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12) // Add padding + tv.layer.cornerRadius = 10 // Rounded corners + tv.layer.borderColor = UIColor.gray.cgColor + tv.clipsToBounds = true + tv.backgroundColor = UIColor(white: 0.95, alpha: 1) // Light gray background for contrast + tv.translatesAutoresizingMaskIntoConstraints = false + return tv + }() + + // Create the "Clear" button as a bar button item + private lazy var clearButton: UIBarButtonItem = { + let button = UIBarButtonItem(title: "Clear", + style: .plain, + target: self, + action: #selector(clearLogs)) + return button + }() + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + + // Set up the view + setupView() + setupNavigationBar() + setupConstraints() + + displayLogs() + + NotificationCenter.default.addObserver(self, selector: #selector(displayLogs), name: UIApplication.didBecomeActiveNotification, object: nil) + } + + + private func setupView() { + view.backgroundColor = .white + view.addSubview(textView) + } + + private func setupNavigationBar() { + title = "Logs" + navigationItem.rightBarButtonItem = clearButton + } + + private func setupConstraints() { + NSLayoutConstraint.activate([ + textView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), + textView.leadingAnchor.constraint(equalTo: view.leadingAnchor), + textView.bottomAnchor.constraint(equalTo: view.bottomAnchor), + textView.trailingAnchor.constraint(equalTo: view.trailingAnchor) + ]) + } + + @objc private func displayLogs() { + let logsFilePath = getLogFilePath() + do { + let logs = try String(contentsOfFile: logsFilePath, encoding: .utf8) + textView.text = logs + } catch { + print("Error reading logs: \(error)") + } + } + + @objc private func clearLogs() { + let logsFilePath = getLogFilePath() + // Truncate the file without deleting it + if let fileHandle = FileHandle(forWritingAtPath: logsFilePath) { + fileHandle.truncateFile(atOffset: 0) + fileHandle.closeFile() + } + textView.text = "Cleared logs!" + } + + private func getLogFilePath() -> String { + let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! + return documentsDirectory.appendingPathComponent("console.log").path + } + + deinit { + NotificationCenter.default.removeObserver(self) + } + +} + diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest.xcodeproj/project.pbxproj b/Linking-TestBeds/SwiftUITest/SwiftUITest.xcodeproj/project.pbxproj new file mode 100644 index 000000000..2a9fee085 --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest.xcodeproj/project.pbxproj @@ -0,0 +1,423 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 60; + objects = { + +/* Begin PBXBuildFile section */ + C121D5902C950ADC00DC22DA /* SwiftUITestApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C121D58F2C950ADC00DC22DA /* SwiftUITestApp.swift */; }; + C121D5922C950ADC00DC22DA /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C121D5912C950ADC00DC22DA /* ContentView.swift */; }; + C121D5942C950ADF00DC22DA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C121D5932C950ADF00DC22DA /* Assets.xcassets */; }; + C121D5972C950ADF00DC22DA /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C121D5962C950ADF00DC22DA /* Preview Assets.xcassets */; }; + C121D5AD2C9A53FA00DC22DA /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D5AC2C9A53FA00DC22DA /* CoreServices.framework */; }; + C121D5AF2C9A540300DC22DA /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D5AE2C9A540300DC22DA /* SystemConfiguration.framework */; }; + C121D5B12C9A540900DC22DA /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D5B02C9A540900DC22DA /* WebKit.framework */; }; + C121D5B32C9A540E00DC22DA /* CoreSpotlight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C121D5B22C9A540E00DC22DA /* CoreSpotlight.framework */; }; + C121D5B92C9B97DF00DC22DA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C121D5B82C9B97DF00DC22DA /* AppDelegate.swift */; }; + E70690302D396C60008FEDB5 /* BranchSDK in Frameworks */ = {isa = PBXBuildFile; productRef = E706902F2D396C60008FEDB5 /* BranchSDK */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + C121D5AA2C9A53E700DC22DA /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + C121D58C2C950ADC00DC22DA /* SwiftUITest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftUITest.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C121D58F2C950ADC00DC22DA /* SwiftUITestApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUITestApp.swift; sourceTree = ""; }; + C121D5912C950ADC00DC22DA /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + C121D5932C950ADF00DC22DA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + C121D5962C950ADF00DC22DA /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + C121D5AC2C9A53FA00DC22DA /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; + C121D5AE2C9A540300DC22DA /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + C121D5B02C9A540900DC22DA /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + C121D5B22C9A540E00DC22DA /* CoreSpotlight.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreSpotlight.framework; path = System/Library/Frameworks/CoreSpotlight.framework; sourceTree = SDKROOT; }; + C121D5B42C9A541F00DC22DA /* SwiftUITest.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SwiftUITest.entitlements; sourceTree = ""; }; + C121D5B72C9B6FF500DC22DA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; + C121D5B82C9B97DF00DC22DA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C121D5892C950ADC00DC22DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E70690302D396C60008FEDB5 /* BranchSDK in Frameworks */, + C121D5B32C9A540E00DC22DA /* CoreSpotlight.framework in Frameworks */, + C121D5B12C9A540900DC22DA /* WebKit.framework in Frameworks */, + C121D5AF2C9A540300DC22DA /* SystemConfiguration.framework in Frameworks */, + C121D5AD2C9A53FA00DC22DA /* CoreServices.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C121D5832C950ADC00DC22DA = { + isa = PBXGroup; + children = ( + C121D58E2C950ADC00DC22DA /* SwiftUITest */, + C121D58D2C950ADC00DC22DA /* Products */, + C121D5AB2C9A53F900DC22DA /* Frameworks */, + ); + sourceTree = ""; + }; + C121D58D2C950ADC00DC22DA /* Products */ = { + isa = PBXGroup; + children = ( + C121D58C2C950ADC00DC22DA /* SwiftUITest.app */, + ); + name = Products; + sourceTree = ""; + }; + C121D58E2C950ADC00DC22DA /* SwiftUITest */ = { + isa = PBXGroup; + children = ( + C121D5B72C9B6FF500DC22DA /* Info.plist */, + C121D5B42C9A541F00DC22DA /* SwiftUITest.entitlements */, + C121D58F2C950ADC00DC22DA /* SwiftUITestApp.swift */, + C121D5912C950ADC00DC22DA /* ContentView.swift */, + C121D5B82C9B97DF00DC22DA /* AppDelegate.swift */, + C121D5932C950ADF00DC22DA /* Assets.xcassets */, + C121D5952C950ADF00DC22DA /* Preview Content */, + ); + path = SwiftUITest; + sourceTree = ""; + }; + C121D5952C950ADF00DC22DA /* Preview Content */ = { + isa = PBXGroup; + children = ( + C121D5962C950ADF00DC22DA /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + C121D5AB2C9A53F900DC22DA /* Frameworks */ = { + isa = PBXGroup; + children = ( + C121D5B22C9A540E00DC22DA /* CoreSpotlight.framework */, + C121D5B02C9A540900DC22DA /* WebKit.framework */, + C121D5AE2C9A540300DC22DA /* SystemConfiguration.framework */, + C121D5AC2C9A53FA00DC22DA /* CoreServices.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C121D58B2C950ADC00DC22DA /* SwiftUITest */ = { + isa = PBXNativeTarget; + buildConfigurationList = C121D59A2C950ADF00DC22DA /* Build configuration list for PBXNativeTarget "SwiftUITest" */; + buildPhases = ( + C121D5882C950ADC00DC22DA /* Sources */, + C121D5892C950ADC00DC22DA /* Frameworks */, + C121D58A2C950ADC00DC22DA /* Resources */, + C121D5AA2C9A53E700DC22DA /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SwiftUITest; + packageProductDependencies = ( + E706902F2D396C60008FEDB5 /* BranchSDK */, + ); + productName = SwiftUITest; + productReference = C121D58C2C950ADC00DC22DA /* SwiftUITest.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C121D5842C950ADC00DC22DA /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1510; + LastUpgradeCheck = 1510; + TargetAttributes = { + C121D58B2C950ADC00DC22DA = { + CreatedOnToolsVersion = 15.1; + }; + }; + }; + buildConfigurationList = C121D5872C950ADC00DC22DA /* Build configuration list for PBXProject "SwiftUITest" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C121D5832C950ADC00DC22DA; + packageReferences = ( + E706902E2D396C60008FEDB5 /* XCLocalSwiftPackageReference "../.." */, + ); + productRefGroup = C121D58D2C950ADC00DC22DA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C121D58B2C950ADC00DC22DA /* SwiftUITest */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C121D58A2C950ADC00DC22DA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C121D5972C950ADF00DC22DA /* Preview Assets.xcassets in Resources */, + C121D5942C950ADF00DC22DA /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C121D5882C950ADC00DC22DA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C121D5B92C9B97DF00DC22DA /* AppDelegate.swift in Sources */, + C121D5922C950ADC00DC22DA /* ContentView.swift in Sources */, + C121D5902C950ADC00DC22DA /* SwiftUITestApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + C121D5982C950ADF00DC22DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + C121D5992C950ADF00DC22DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + C121D59B2C950ADF00DC22DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = SwiftUITest/SwiftUITest.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"SwiftUITest/Preview Content\""; + DEVELOPMENT_TEAM = R63EM248DP; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = SwiftUITest/Info.plist; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.Branch-TestBed"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + C121D59C2C950ADF00DC22DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = SwiftUITest/SwiftUITest.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"SwiftUITest/Preview Content\""; + DEVELOPMENT_TEAM = R63EM248DP; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = SwiftUITest/Info.plist; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.Branch-TestBed"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C121D5872C950ADC00DC22DA /* Build configuration list for PBXProject "SwiftUITest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C121D5982C950ADF00DC22DA /* Debug */, + C121D5992C950ADF00DC22DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C121D59A2C950ADF00DC22DA /* Build configuration list for PBXNativeTarget "SwiftUITest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C121D59B2C950ADF00DC22DA /* Debug */, + C121D59C2C950ADF00DC22DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + E706902E2D396C60008FEDB5 /* XCLocalSwiftPackageReference "../.." */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ../..; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + E706902F2D396C60008FEDB5 /* BranchSDK */ = { + isa = XCSwiftPackageProductDependency; + productName = BranchSDK; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = C121D5842C950ADC00DC22DA /* Project object */; +} diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Linking-TestBeds/SwiftUITest/SwiftUITest.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Linking-TestBeds/SwiftUITest/SwiftUITest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest/AppDelegate.swift b/Linking-TestBeds/SwiftUITest/SwiftUITest/AppDelegate.swift new file mode 100644 index 000000000..2d4d3aefb --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest/AppDelegate.swift @@ -0,0 +1,57 @@ +// +// AppDelegate.swift +// SwiftUITest +// +// Created by Nipun Singh on 9/18/24. +// + +import SwiftUI +import BranchSDK + +class AppDelegate: UIResponder, UIApplicationDelegate { + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { + redirectConsoleLogs() + + Branch.enableLogging(at: .verbose, withCallback: nil) + + Branch.getInstance().initSession(launchOptions: launchOptions) { (params, error) in + guard let data = params as? [String: AnyObject] else { return } + print("Branch Params: \(params ?? [:])") + + if (data["+clicked_branch_link"] as! Bool) == true { + self.showAlert(withParams: params ?? [:]) + } + } + + return true + } + + func showAlert(withParams params: [AnyHashable: Any]) { + // Convert params to a readable string + let paramsString = params.map { "\($0.key): \($0.value)" }.joined(separator: "\n") + // Create alert + let alert = UIAlertController(title: "✅ Successfully Deep Linked", message: paramsString, preferredStyle: .alert) + + // Add OK action + alert.addAction(UIAlertAction(title: "Nice", style: .default, handler: nil)) + + // Present alert + if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene, + let rootVC = scene.windows.first?.rootViewController { + rootVC.present(alert, animated: true, completion: nil) + } + } + + func redirectConsoleLogs() { + let logsFilePath = getLogFilePath() + freopen(logsFilePath, "a+", stdout) + freopen(logsFilePath, "a+", stderr) + print("App started and console redirection initialized.") + } + + func getLogFilePath() -> String { + let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! + return documentsDirectory.appendingPathComponent("console.log").path + } +} diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/AccentColor.colorset/Contents.json b/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..eb8789700 --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/AppIcon.appiconset/Contents.json b/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..44ac9cc28 --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,14 @@ +{ + "images" : [ + { + "filename" : "appstore.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/AppIcon.appiconset/appstore.png b/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/AppIcon.appiconset/appstore.png new file mode 100644 index 000000000..1969a1810 Binary files /dev/null and b/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/AppIcon.appiconset/appstore.png differ diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/Contents.json b/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest/ContentView.swift b/Linking-TestBeds/SwiftUITest/SwiftUITest/ContentView.swift new file mode 100644 index 000000000..88f06a03c --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest/ContentView.swift @@ -0,0 +1,78 @@ +// +// ContentView.swift +// SwiftUITest +// +// Created by Nipun Singh on 9/13/24. +// + +import SwiftUI + +struct ContentView: View { + @StateObject private var logReader = LogReader() + + var body: some View { + NavigationView { + VStack { + ScrollView { + Text(logReader.logs) + .padding() + .frame(maxWidth: .infinity, alignment: .leading) + } + .background(Color(.systemGray6)) + .cornerRadius(8) + .padding() + + } + .navigationTitle("Logs") + .toolbar { + ToolbarItem(placement: .navigationBarTrailing) { + Button(action: { + logReader.clearLogs() + }) { + Text("Clear") + } + } + } + } + } +} + +class LogReader: ObservableObject { + @Published var logs: String = "" + private var timer: Timer? + + init() { + startReadingLogs() + } + + deinit { + timer?.invalidate() + } + + private func startReadingLogs() { + timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] _ in + self?.readLogs() + } + } + + private func readLogs() { + let logsFilePath = getLogFilePath() + if let logData = try? String(contentsOfFile: logsFilePath) { + DispatchQueue.main.async { + self.logs = logData + } + } + } + + func clearLogs() { + let logsFilePath = getLogFilePath() + // Clear the content of the log file + try? "".write(toFile: logsFilePath, atomically: true, encoding: .utf8) + self.logs = "" + } + + private func getLogFilePath() -> String { + let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! + return documentsDirectory.appendingPathComponent("console.log").path + } +} diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest/Info.plist b/Linking-TestBeds/SwiftUITest/SwiftUITest/Info.plist new file mode 100644 index 000000000..31601309f --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest/Info.plist @@ -0,0 +1,33 @@ + + + + + branch_key + + live + key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB + test + key_test_hdcBLUy1xZ1JD0tKg7qrLcgirFmPPVJc + + branch_universal_link_domains + + bnctestbed.app.link + bnctestbed.test-app.link + bnctestbed-alternate.app.link + bnc.lt + + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + branchtest + + CFBundleURLName + io.branch.sdk.Branch-TestBed + + + + diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest/Preview Content/Preview Assets.xcassets/Contents.json b/Linking-TestBeds/SwiftUITest/SwiftUITest/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest/SwiftUITest.entitlements b/Linking-TestBeds/SwiftUITest/SwiftUITest/SwiftUITest.entitlements new file mode 100644 index 000000000..b601e954c --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest/SwiftUITest.entitlements @@ -0,0 +1,13 @@ + + + + + com.apple.developer.associated-domains + + applinks:bnctestbed.app.link + applinks:bnctestbed-alternate.app.link + applinks:bnc.lt + applinks:bnctestbed.test-app.link + + + diff --git a/Linking-TestBeds/SwiftUITest/SwiftUITest/SwiftUITestApp.swift b/Linking-TestBeds/SwiftUITest/SwiftUITest/SwiftUITestApp.swift new file mode 100644 index 000000000..d21d5a91b --- /dev/null +++ b/Linking-TestBeds/SwiftUITest/SwiftUITest/SwiftUITestApp.swift @@ -0,0 +1,25 @@ +// +// SwiftUITestApp.swift +// SwiftUITest +// +// Created by Nipun Singh on 9/13/24. +// + +import SwiftUI +import BranchSDK + +@main +struct SwiftUITestApp: App { + + @UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate + + var body: some Scene { + WindowGroup { + ContentView() + .onOpenURL(perform: { url in + print("[onOpenURL] Branch handling deep link: \(url)") + Branch.getInstance().handleDeepLink(url) + }) + } + } +}