4545#import " BNCServerAPI.h"
4646#import " BranchPluginSupport.h"
4747#import " BranchLogger.h"
48+ #import " Private/BranchConfigurationController.h"
4849
4950
50- #if SWIFT_PACKAGE
51- @import BranchSwiftSDK;
52- #else
53- #import " BranchSDK/BranchSDK-Swift.h"
51+
52+ // Swift integration - BranchSwiftSDK module is loaded dynamically at runtime
53+ // No compile-time import needed to avoid circular dependencies in SPM
54+ #if !SWIFT_PACKAGE
55+ // Swift bridging header - auto-generated by Xcode when Swift files are present
56+ #if __has_include("BranchSDK-Swift.h")
57+ #import " BranchSDK-Swift.h"
58+ #endif
5459#endif
5560
5661#if !TARGET_OS_TV
@@ -194,7 +199,7 @@ + (Branch *)getInstance {
194199
195200+ (Branch *)getInstance : (NSString *)branchKey {
196201 self.branchKey = branchKey;
197- [ConfigurationController shared ].branchKeySource = BRANCH_KEY_SOURCE_GET_INSTANCE_API;
202+ [BranchConfigurationController sharedInstance ].branchKeySource = BRANCH_KEY_SOURCE_GET_INSTANCE_API;
198203 return [Branch getInstanceInternal: self .branchKey];
199204}
200205
@@ -254,8 +259,8 @@ - (id)initWithInterface:(BNCServerInterface *)interface
254259
255260 BranchJsonConfig *config = BranchJsonConfig.instance ;
256261 self.deferInitForPluginRuntime = config.deferInitForPluginRuntime ;
257- [ConfigurationController shared ].deferInitForPluginRuntime = self.deferInitForPluginRuntime ;
258-
262+ [BranchConfigurationController sharedInstance ].deferInitForPluginRuntime = self.deferInitForPluginRuntime ;
263+
259264 if (config.apiUrl ) {
260265 [Branch setAPIUrl: config.apiUrl];
261266 }
@@ -282,6 +287,7 @@ - (id)initWithInterface:(BNCServerInterface *)interface
282287 }
283288 }
284289
290+ [self .requestQueue configureWithServerInterface: _serverInterface branchKey: key preferenceHelper: preferenceHelper];
285291 return self;
286292}
287293
@@ -416,7 +422,7 @@ + (void)setBranchKey:(NSString*)branchKey error:(NSError **)error {
416422 [[BranchLogger shared ] logError: [NSString stringWithFormat: @" Invalid Branch key format. Did you add your Branch key to your Info.plist? Passed key is '%@ '." , branchKey] error: *error];
417423 return ;
418424 }
419- [ConfigurationController shared ].branchKeySource = BRANCH_KEY_SOURCE_SET_BRANCH_KEY_API;
425+ [BranchConfigurationController sharedInstance ].branchKeySource = BRANCH_KEY_SOURCE_SET_BRANCH_KEY_API;
420426 bnc_branchKey = branchKey;
421427 }
422428}
@@ -452,7 +458,7 @@ + (NSString *)branchKey {
452458 if (!bnc_branchKey) {
453459 [[BranchLogger shared ] logError: @" Your Branch key is not set in your Info.plist file. See https://dev.branch.io/getting-started/sdk-integration-guide/guide/ios/#configure-xcode-project for configuration instructions." error: nil ];
454460 }
455- [ConfigurationController shared ].branchKeySource = branchKeySource;
461+ [BranchConfigurationController sharedInstance ].branchKeySource = branchKeySource;
456462 return bnc_branchKey;
457463 }
458464}
@@ -1014,7 +1020,7 @@ - (void)startLoadingOfODMInfo {
10141020
10151021- (void )checkPasteboardOnInstall {
10161022 [BNCPasteboard sharedInstance ].checkOnInstall = YES ;
1017- [ConfigurationController shared ].checkPasteboardOnInstall = YES ;
1023+ [BranchConfigurationController sharedInstance ].checkPasteboardOnInstall = YES ;
10181024}
10191025
10201026- (BOOL )willShowPasteboardToast {
@@ -1150,7 +1156,6 @@ - (void)sendServerRequest:(BNCServerRequest*)request {
11501156 [self initSafetyCheck ];
11511157 dispatch_async (self.isolationQueue , ^(){
11521158 [self .requestQueue enqueue: request];
1153- [self processNextQueueItem ];
11541159 });
11551160}
11561161
@@ -1350,7 +1355,6 @@ - (void)getSpotlightUrlWithParams:(NSDictionary *)params callback:(callbackWithP
13501355 dispatch_async (self.isolationQueue , ^(){
13511356 BranchSpotlightUrlRequest *req = [[BranchSpotlightUrlRequest alloc ] initWithParams: params callback: callback];
13521357 [self .requestQueue enqueue: req];
1353- [self processNextQueueItem ];
13541358 });
13551359}
13561360
@@ -1646,7 +1650,6 @@ - (void)generateShortUrl:(NSArray *)tags
16461650 linkCache: self .linkCache
16471651 callback: callback];
16481652 [self .requestQueue enqueue: req];
1649- [self processNextQueueItem ];
16501653 });
16511654}
16521655
@@ -1875,14 +1878,6 @@ - (void)setNetworkCount:(NSInteger)networkCount {
18751878 }
18761879}
18771880
1878- - (void )insertRequestAtFront : (BNCServerRequest *)req {
1879- if (self.networkCount == 0 ) {
1880- [self .requestQueue insert: req at: 0 ];
1881- } else {
1882- [self .requestQueue insert: req at: 1 ];
1883- }
1884- }
1885-
18861881static inline void BNCPerformBlockOnMainThreadSync (dispatch_block_t block) {
18871882 if (block) {
18881883 if ([NSThread isMainThread ]) {
@@ -1902,7 +1897,7 @@ - (void) processRequest:(BNCServerRequest*)req
19021897 error : (NSError *)error {
19031898
19041899 // If the request was successful, or was a bad user request, continue processing.
1905- if (!error ||
1900+ /* if (!error ||
19061901 error.code == BNCTrackingDisabledError ||
19071902 error.code == BNCBadRequestError ||
19081903 error.code == BNCDuplicateResourceError) {
@@ -1956,7 +1951,7 @@ - (void) processRequest:(BNCServerRequest*)req
19561951 }
19571952 });
19581953 }
1959- }
1954+ }*/
19601955}
19611956
19621957- (BOOL )isReplayableRequest : (BNCServerRequest *)request {
@@ -1980,6 +1975,7 @@ - (BOOL)isReplayableRequest:(BNCServerRequest *)request {
19801975}
19811976
19821977- (void )processNextQueueItem {
1978+ /*
19831979 dispatch_semaphore_wait(self.processing_sema, DISPATCH_TIME_FOREVER);
19841980
19851981 [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Processing next queue item. Network Count: %ld. Queue depth: %ld", (long)self.networkCount, (long)self.requestQueue.queueDepth] error:nil];
@@ -2027,7 +2023,7 @@ - (void)processNextQueueItem {
20272023 }
20282024 else {
20292025 dispatch_semaphore_signal(self.processing_sema);
2030- }
2026+ }*/
20312027}
20322028
20332029- (void )clearNetworkQueue {
@@ -2166,7 +2162,7 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS
21662162 req.callback = initSessionCallback;
21672163 req.urlString = urlString;
21682164
2169- [self .requestQueue insert : req at: 0 ];
2165+ [self .requestQueue enqueue : req withPriority: NSOperationQueuePriorityHigh ];
21702166
21712167 NSString *message = [NSString stringWithFormat: @" Request %@ callback %@ link %@ " , req, req.callback, req.urlString];
21722168 [[BranchLogger shared ] logDebug: message error: nil ];
@@ -2180,7 +2176,7 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS
21802176 req.urlString = urlString;
21812177
21822178 // put it behind the one that's already on queue
2183- [self .requestQueue insert : req at: 1 ];
2179+ [self .requestQueue enqueue : req withPriority: NSOperationQueuePriorityHigh ];
21842180
21852181 [[BranchLogger shared ] logDebug: @" Link resolution request" error: nil ];
21862182 NSString *message = [NSString stringWithFormat: @" Request %@ callback %@ link %@ " , req, req.callback, req.urlString];
@@ -2190,8 +2186,6 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS
21902186
21912187 self.initializationStatus = BNCInitStatusInitializing;
21922188 [[BranchLogger shared ] logVerbose: [NSString stringWithFormat: @" initializationStatus %ld " , self .initializationStatus] error: nil ];
2193-
2194- [self processNextQueueItem ];
21952189 });
21962190 }
21972191}
0 commit comments