2 * Copyright 2018 Google LLC
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #import <GoogleUtilities/GULAppDelegateSwizzler.h>
18 #import <GoogleUtilities/GULMutableDictionary.h>
22 NS_ASSUME_NONNULL_BEGIN
24 @interface GULAppDelegateSwizzler ()
26 /** Returns the current sharedApplication.
28 * @return the current UIApplication if in an app, or nil if in extension or if it doesn't exist.
30 + (nullable UIApplication *)sharedApplication;
32 /** ISA Swizzles the given appDelegate as the original app delegate would be.
34 * @param appDelegate The object that needs to be isa swizzled. This should conform to the
35 * UIApplicationDelegate protocol.
37 + (void)proxyAppDelegate:(id<UIApplicationDelegate>)appDelegate;
39 /** Returns a dictionary containing interceptor IDs mapped to a GULZeroingWeakContainer.
41 * @return A dictionary of the form {NSString : GULZeroingWeakContainer}, where the NSString is
44 + (GULMutableDictionary *)interceptors;
46 #ifdef GUL_APP_DELEGATE_TESTING // Methods only used in tests.
48 /** Deletes all the registered interceptors. */
49 + (void)clearInterceptors;
51 /** Resets the token that prevents the app delegate proxy from being isa swizzled multiple times. */
52 + (void)resetProxyOriginalDelegateOnceToken;
54 /** Returns the original app delegate that was proxied.
56 * @return The original app delegate instance that was proxied.
58 + (id<UIApplicationDelegate>)originalDelegate;
60 #endif // GUL_APP_DELEGATE_TESTING