1717#include " app/src/util_ios.h"
1818
1919#include " app/src/assert.h"
20- #include " app/src/include/firebase/internal/common.h"
21- #include " app/src/log.h"
2220
2321#include < assert.h>
2422#include < stdlib.h>
2927
3028static IMP g_original_setDelegate_imp = NULL ;
3129static Class g_app_delegate_class = nil ;
32- static void (^g_pending_app_delegate_block)(Class ) = nil; // New
33-
34- #include " app/src/log.h" // For LogDebug
30+ static void (^g_pending_app_delegate_block)(Class ) = nil;
3531
3632// Swizzled implementation of setDelegate:
3733static void Firebase_setDelegate (id self, SEL _cmd, id <UIApplicationDelegate> delegate) {
3834 if (delegate) {
3935 g_app_delegate_class = [delegate class ];
40- firebase::LogDebug ( " Firebase: UIApplication setDelegate: called with class %s (Swizzled)" ,
36+ NSLog ( @ " Firebase: UIApplication setDelegate: called with class %s (Swizzled)" ,
4137 class_getName (g_app_delegate_class));
4238 } else {
4339 g_app_delegate_class = nil ;
44- firebase::LogDebug ( " Firebase: UIApplication setDelegate: called with nil delegate (Swizzled)" );
40+ NSLog ( @ " Firebase: UIApplication setDelegate: called with nil delegate (Swizzled)" );
4541 }
4642
47- // New part to add:
4843 if (g_pending_app_delegate_block && g_app_delegate_class) {
49- firebase::LogDebug ( " Firebase: Firebase_setDelegate executing pending block with delegate class: %s." ,
44+ NSLog ( @ " Firebase: Firebase_setDelegate executing pending block with delegate class: %s ." ,
5045 class_getName (g_app_delegate_class));
5146 g_pending_app_delegate_block (g_app_delegate_class);
5247 g_pending_app_delegate_block = nil ; // Clear the block after execution (ARC handles release)
5348 } else if (g_pending_app_delegate_block && !g_app_delegate_class) {
5449 // This case: setDelegate was called with nil, but a block was pending.
5550 // The pending block expects a Class. We don't have one.
5651 // So, we should clear the pending block as it can no longer be satisfied.
57- firebase::LogDebug ( " Firebase: Firebase_setDelegate called with nil delegate, clearing pending block as it cannot be executed." );
52+ NSLog ( @ " Firebase: Firebase_setDelegate called with nil delegate, clearing pending block as it cannot be executed." );
5853 g_pending_app_delegate_block = nil ;
5954 }
6055
6156 if (g_original_setDelegate_imp) {
6257 ((void (*)(id , SEL , id <UIApplicationDelegate>))g_original_setDelegate_imp)(self, _cmd, delegate);
6358 } else {
64- firebase::LogError ( " Firebase: Original setDelegate: IMP not found, cannot call original method." );
59+ NSLog ( @ " Firebase Error : Original setDelegate: IMP not found, cannot call original method." );
6560 }
6661}
6762
@@ -75,16 +70,16 @@ + (void)load {
7570 Method originalMethod = class_getInstanceMethod (uiApplicationClass, originalSelector);
7671
7772 if (!originalMethod) {
78- firebase::LogError ( " Firebase: Original [UIApplication setDelegate:] method not found for swizzling." );
73+ NSLog ( @ " Firebase Error : Original [UIApplication setDelegate:] method not found for swizzling." );
7974 return ;
8075 }
8176
8277 IMP previousImp = method_setImplementation (originalMethod, (IMP )Firebase_setDelegate);
8378 if (previousImp) {
8479 g_original_setDelegate_imp = previousImp;
85- firebase::LogDebug ( " Firebase: Successfully swizzled [UIApplication setDelegate:] and stored original IMP." );
80+ NSLog ( @ " Firebase: Successfully swizzled [UIApplication setDelegate:] and stored original IMP." );
8681 } else {
87- firebase::LogError ( " Firebase: Swizzled [UIApplication setDelegate:], but original IMP was NULL (or method_setImplementation failed)." );
82+ NSLog ( @ " Firebase Error : Swizzled [UIApplication setDelegate:], but original IMP was NULL (or method_setImplementation failed)." );
8883 }
8984 });
9085}
@@ -145,15 +140,15 @@ - (BOOL)application:(UIApplication *)application
145140
146141void ForEachAppDelegateClass (void (^block)(Class )) {
147142 if (g_app_delegate_class) {
148- firebase::LogDebug ( " Firebase: ForEachAppDelegateClass executing with stored delegate class: %s." ,
143+ NSLog ( @ " Firebase: ForEachAppDelegateClass executing with stored delegate class: %s ." ,
149144 class_getName (g_app_delegate_class));
150145 block (g_app_delegate_class);
151146 // Clear any pending block as we've now executed with a known delegate.
152147 if (g_pending_app_delegate_block) {
153148 g_pending_app_delegate_block = nil ; // ARC handles release
154149 }
155150 } else {
156- firebase::LogDebug ( " Firebase: ForEachAppDelegateClass - delegate class not yet known. Saving block for later execution." );
151+ NSLog ( @ " Firebase: ForEachAppDelegateClass - delegate class not yet known. Saving block for later execution." );
157152 // If a block is already pending, the new one replaces it. ARC handles the old one.
158153 // Make sure to copy the block to move it to the heap.
159154 g_pending_app_delegate_block = [block copy ];
0 commit comments