-
Notifications
You must be signed in to change notification settings - Fork 241
EMT-2309: Add Class BNCServerRequestOperation. #1533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wpinho-branch
wants to merge
44
commits into
master
Choose a base branch
from
BNC-Server-Request-Queue-Refactoring-And-Auto-Request-Processing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
EMT-2309: Add Class BNCServerRequestOperation. #1533
wpinho-branch
wants to merge
44
commits into
master
from
BNC-Server-Request-Queue-Refactoring-And-Auto-Request-Processing
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… with v1/install request.
This reverts commit 0ad4564.
This reverts commit 53d322c.
This reverts commit ef025f1.
-> Removed DeepLinkDemo, TestDeepLinking and TestHost Apps for the repo. -> Removed Unit tests from Branch Test Bed App -> Added Test Host App and Unit tests to BranchSDK Workspace.
This reverts commit 83cd178.
This reverts commit af22cad.
…de-Restructure-Cleanup
This commit introduces modern Swift Concurrency patterns to the iOS Branch SDK, mirroring the Android Kotlin Coroutines implementation. The changes enable async/await request processing, actor-based thread safety, and structured concurrency throughout the SDK. ## Swift Concurrency Implementation Added three core Swift files using modern concurrency patterns: - `BranchRequestOperation.swift`: Actor-isolated async operation for processing Branch server requests with structured concurrency, automatic main thread dispatching for callbacks, and session validation matching Android's implementation - `BranchRequestQueue.swift`: Actor-based request queue with serial execution, async/await API, and thread-safe queue management replacing manual NSOperationQueue patterns - `ConfigurationController.swift`: Swift configuration management with async initialization and proper error handling Architecture parallels to Android: - Android: CoroutineScope + Channel → iOS: Actor + AsyncStream - Android: Dispatchers.IO → iOS: Task.detached - Android: Dispatchers.Main → iOS: MainActor ## Swift Package Manager (SPM) Integration Updated Package.swift to define dual-target architecture: - `BranchObjCSDK`: Core Objective-C framework with all existing functionality - `BranchSDK`: Swift wrapper exposing async/await APIs and importing BranchObjCSDK This enables seamless Swift integration while maintaining full Objective-C compatibility. ## Objective-C Bridge Enhancements Modified `BNCServerRequestOperation.m` to support Swift interop: - Added Swift availability checks (@available decorators) - Integrated async callback completion handling - Maintained backward compatibility with existing Objective-C code Updated `BNCServerRequestQueue.m` and `BNCRequestFactory.m` for improved Swift interaction. ## Public API Visibility Changes Moved `BNCConfig.h` from Private to Public headers to enable SPM package visibility. Added `BranchConstants.h` and `BranchConstants.m` to public BranchSDK directory for proper module exposure. ## Test Infrastructure Updates Updated 16 test files to use modular imports: - Changed from `#import "Branch.h"` to `@import BranchSDK` - Updated bridging headers for Swift/Objective-C interop - Modified test schemes to support SPM package dependencies Test files updated: - BNCAPIServerTest.m, BNCODMTests.m, BNCPasteboardTests.m - BNCPreferenceHelperTests.m, BranchActivityItemTests.m - BranchClassTests.m, BranchLoggerTests.m, BranchQRCodeTests.m - BranchShareLinkTests.m, DispatchToIsolationQueueTests.m - Branch_setBranchKeyTests.m - UITestCaseMisc.m, UITestCaseTracking.m, UITestSendV2Event.m - UITestSetIdentity.m, Branch-SDK-Tests-Bridging-Header.h ## Branch-TestBed Configuration Updated Branch-TestBed Xcode project: - Configured SPM package dependency reference - Updated project.pbxproj with proper target dependencies - Removed Package.resolved to allow flexible dependency resolution - Updated all test schemes for SPM compatibility - Modified AppDelegate.m and ViewControllers for async initialization ## Project Structure Cleanup Organized source files into proper directory structure: - Created `Sources/BranchSwiftSDK/` for Swift implementation - Moved configuration files to appropriate locations - Removed duplicate/temporary Swift files from previous iterations - Updated both BranchSDK.xcodeproj and Package.swift configurations ## Key Features - Structured concurrency with proper cancellation support - Actor-based thread safety eliminating race conditions - Automatic main thread dispatching for UI callbacks - Session validation matching Android implementation - Performance optimized with cooperative thread pool - Serial request processing ensuring proper ordering - Modern async/await API for Swift developers - Full backward compatibility with existing Objective-C code
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use MatterAICommand List
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reference
EMT-2309 -- Add Class BNCServerRequestOperation.
Summary
This PR implements Swift Concurrency (async/await) patterns for the iOS Branch SDK, mirroring the Android Kotlin Coroutines implementation. The changes introduce modern asynchronous request processing using Swift Actors and structured concurrency while maintaining full backward compatibility with existing Objective-C code.
Key Components:
BranchRequestOperation
: Modern async/await operation for request processingBranchRequestQueue
: Actor-based thread-safe queue managementConfigurationController
: SDK configuration telemetry in SwiftMotivation
The iOS SDK currently uses legacy GCD-based asynchronous patterns, while the Android SDK has migrated to modern Kotlin Coroutines. This creates architectural inconsistency between platforms and makes the codebase harder to maintain.
Benefits of Swift Concurrency:
Technical Alignment:
CoroutineScope + Channel
→ iOS:Actor + AsyncStream
Dispatchers.IO
→ iOS:Task.detached
Dispatchers.Main
→ iOS:@MainActor
Type Of Change
Testing Instructions
1. Build Verification
2. Runtime Verification
Run the Branch-TestBed app and verify console output shows:
3. Functional Testing
4. Backward Compatibility
5. Code Quality Checks
Checklist
Implementation Details
Architecture
Runtime Detection Flow
BNCServerRequestOperation
checks iOS version (≥13.0)NSClassFromString()
to detect Swift classesNSInvocation
cc @BranchMetrics/saas-sdk-devs for visibility.
https://branch.atlassian.net/browse/EMT-2309