You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
iOS: Allow specifying your AppDelegate class's name in the Info.plist file. (#1741)
* Feature: Allow specifying AppDelegate via Info.plist for RunOnAppDelegateClasses
Currently, `firebase::util::RunOnAppDelegateClasses` on iOS automatically
swizzles `[UIApplication setDelegate:]` to capture and act on any class
set as the application delegate.
This change introduces an optional feature where developers can specify their
app's main AppDelegate class name directly in the `Info.plist` file using
the key `FirebaseAppDelegateClassName`.
If this key is present and provides a valid class name:
- `RunOnAppDelegateClasses` will only execute blocks for this specified class.
- `[UIApplication setDelegate:]` will NOT be swizzled by Firebase.
If the key is not present, is invalid, or the specified class is not found,
Firebase will fall back to the original behavior of swizzling
`[UIApplication setDelegate:]`.
This provides developers more control over Firebase's interaction with the
AppDelegate, especially in scenarios where swizzling might be undesirable or
needs to be more targeted.
Detailed logging has been added to trace the behavior in both modes.
A manual testing plan has been outlined to cover various scenarios.
* Feature: Allow specifying AppDelegate via Info.plist for RunOnAppDelegateClasses (Refined)
Currently, `firebase::util::RunOnAppDelegateClasses` on iOS automatically
swizzles `[UIApplication setDelegate:]` to capture and act on any class
set as the application delegate.
This change introduces an optional feature where developers can specify their
app's main AppDelegate class name directly in the `Info.plist` file using
the key `FirebaseAppDelegateClassName`.
If this key is present and provides a valid class name:
- `RunOnAppDelegateClasses` will only execute blocks for this specified class.
- Pending blocks are processed once for this target.
- New blocks execute immediately on this target and are not queued for others.
- `[UIApplication setDelegate:]` will NOT be swizzled by Firebase.
If the key is not present, is invalid, or the specified class is not found,
Firebase will fall back to the original behavior of swizzling
`[UIApplication setDelegate:]`.
This provides developers more control over Firebase's interaction with the
AppDelegate. The implementation of `RunOnAppDelegateClasses` has been refined
to support this new mode more simply while ensuring correct block execution
and pending queue management.
Detailed logging has been added. A manual testing plan is provided.
* Refactor: Improve comments and logging for AppDelegate Info.plist feature
This commit cleans up comments and refines logging messages within the
`+load` method in `FirebaseAppDelegateSwizzling` category for clarity
and accuracy related to the recently added feature for specifying the
AppDelegate via Info.plist.
- Clarified comments explaining the Info.plist handling path, including
the setup of the specified delegate and the execution of pending blocks.
- Ensured comments accurately reflect that pending blocks are not cleared
from the queue after execution in `+load` when in Info.plist mode.
- Minor wording improvements to log messages for better diagnostics.
- Removed redundant or outdated comments from previous iterations.
No functional code changes are included in this commit.
* Docs: Simplify AppDelegate Info.plist option in README
Further refines the documentation for the `FirebaseAppDelegateClassName`
Info.plist key feature on iOS.
- The explanation in `release_build_files/readme.md` under "Specifying Your
AppDelegate Class Directly (iOS)" has been made more concise and
user-focused, removing internal implementation details.
- The corresponding release note for version 12.9.0 has also been
simplified to match this approach.
This change aims to make the documentation easier for developers to
understand by focusing on the action and benefit rather than Firebase
internal mechanisms.
* Docs: Use generic 'Upcoming Release' title in README
Changes the heading for the newest release notes entry from
'### 12.9.0 (Upcoming)' to '### Upcoming Release' as the specific
version number is not yet known.
* Update logging to not be verbose unless debug logs are on.
Also clean up NSLog messages elsewhere.
* Update log message.
* Fix build error.
* Format code.
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
NSLog(@"Firebase: Successfully swizzled [UIApplication setDelegate:] and stored original IMP.");
256
+
g_original_setDelegate_imp = previousImp;
257
+
if (GetLogLevel() <= kLogLevelDebug)
258
+
NSLog(@"Firebase: Successfully swizzled [UIApplication setDelegate:] and stored original "
259
+
@"IMP.");
181
260
} else {
182
-
// This would be unusual - method_setImplementation replacing a NULL IMP,
183
-
// or method_setImplementation itself failed (though it doesn't typically return NULL on failure,
184
-
// it might return the new IMP or the old one depending on versions/runtime).
185
-
// More robustly, g_original_setDelegate_imp should be checked before use.
186
-
// For now, this logging indicates if previousImp was unexpectedly nil.
187
-
NSLog(@"Firebase Error: Swizzled [UIApplication setDelegate:], but original IMP was NULL (or method_setImplementation failed to return the previous IMP).");
261
+
NSLog(@"Firebase Error: Swizzled [UIApplication setDelegate:], but original IMP was NULL (or "
262
+
@"method_setImplementation failed to return the previous IMP).");
NSLog(@"Firebase: RunOnAppDelegateClasses - added block to pending list (total pending: %d). This block will run on future new delegate classes.", g_pending_block_count);
293
+
if (GetLogLevel() <= kLogLevelDebug)
294
+
NSLog(@"Firebase: RunOnAppDelegateClasses - added block to pending list (total pending: %d). "
295
+
@"This block will run on future new delegate classes.",
296
+
g_pending_block_count);
215
297
} else {
216
-
NSLog(@"Firebase Error: RunOnAppDelegateClasses - pending block queue is full (max %d). Cannot add new block for future execution. Discarding block.", MAX_PENDING_APP_DELEGATE_BLOCKS);
298
+
NSLog(@"Firebase Error: RunOnAppDelegateClasses - pending block queue is full (max %d). Cannot "
299
+
@"add new block for future execution. Discarding block.",
0 commit comments