备份CatanBuilding瘦身独立工程
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyTrackingDomains</key>
|
||||
<array>
|
||||
</array>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array>
|
||||
</array>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPIType</key>
|
||||
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
|
||||
<key>NSPrivacyAccessedAPITypeReasons</key>
|
||||
<array>
|
||||
<string>C617.1</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPIType</key>
|
||||
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
|
||||
<key>NSPrivacyAccessedAPITypeReasons</key>
|
||||
<array>
|
||||
<string>1C8F.1</string>
|
||||
<string>C56D.1</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GULApplication.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NSString *const GULAppDelegateInterceptorID;
|
||||
|
||||
/** This class contains methods that isa swizzle the app delegate. */
|
||||
@interface GULAppDelegateSwizzler : NSProxy
|
||||
|
||||
/** Registers an app delegate interceptor whose methods will be invoked as they're invoked on the
|
||||
* original app delegate.
|
||||
*
|
||||
* @param interceptor An instance of a class that conforms to the application delegate protocol.
|
||||
* The interceptor is NOT retained.
|
||||
* @return A unique GULAppDelegateInterceptorID if interceptor was successfully registered; nil
|
||||
* if it fails.
|
||||
*/
|
||||
+ (nullable GULAppDelegateInterceptorID)registerAppDelegateInterceptor:
|
||||
(id<GULApplicationDelegate>)interceptor;
|
||||
|
||||
/** Unregisters an interceptor with the given ID if it exists.
|
||||
*
|
||||
* @param interceptorID The object that was generated when the interceptor was registered.
|
||||
*/
|
||||
+ (void)unregisterAppDelegateInterceptorWithID:(GULAppDelegateInterceptorID)interceptorID;
|
||||
|
||||
/** This method ensures that the original app delegate has been proxied. Call this before
|
||||
* registering your interceptor. This method is safe to call multiple times (but it only proxies
|
||||
* the app delegate once).
|
||||
*
|
||||
* This method doesn't proxy APNS related methods:
|
||||
* @code
|
||||
* - application:didRegisterForRemoteNotificationsWithDeviceToken:
|
||||
* - application:didFailToRegisterForRemoteNotificationsWithError:
|
||||
* - application:didReceiveRemoteNotification:fetchCompletionHandler:
|
||||
* - application:didReceiveRemoteNotification:
|
||||
* @endcode
|
||||
*
|
||||
* To proxy these methods use +[GULAppDelegateSwizzler
|
||||
* proxyOriginalDelegateIncludingAPNSMethods]. The methods have to be proxied separately to
|
||||
* avoid potential warnings from Apple review about missing Push Notification Entitlement (e.g.
|
||||
* https://github.com/firebase/firebase-ios-sdk/issues/2807)
|
||||
*
|
||||
* The method has no effect for extensions.
|
||||
*
|
||||
* @see proxyOriginalDelegateIncludingAPNSMethods
|
||||
*/
|
||||
+ (void)proxyOriginalDelegate;
|
||||
|
||||
/** This method ensures that the original app delegate has been proxied including APNS related
|
||||
* methods. Call this before registering your interceptor. This method is safe to call multiple
|
||||
* times (but it only proxies the app delegate once) or
|
||||
* after +[GULAppDelegateSwizzler proxyOriginalDelegate]
|
||||
*
|
||||
* This method calls +[GULAppDelegateSwizzler proxyOriginalDelegate] under the hood.
|
||||
* After calling this method the following App Delegate methods will be proxied in addition to
|
||||
* the methods proxied by proxyOriginalDelegate:
|
||||
* @code
|
||||
* - application:didRegisterForRemoteNotificationsWithDeviceToken:
|
||||
* - application:didFailToRegisterForRemoteNotificationsWithError:
|
||||
* - application:didReceiveRemoteNotification:fetchCompletionHandler:
|
||||
* - application:didReceiveRemoteNotification:
|
||||
* @endcode
|
||||
*
|
||||
* The method has no effect for extensions.
|
||||
*
|
||||
* @see proxyOriginalDelegate
|
||||
*/
|
||||
+ (void)proxyOriginalDelegateIncludingAPNSMethods;
|
||||
|
||||
/** Indicates whether app delegate proxy is explicitly disabled or enabled. Enabled by default.
|
||||
*
|
||||
* @return YES if AppDelegateProxy is Enabled, NO otherwise.
|
||||
*/
|
||||
+ (BOOL)isAppDelegateProxyEnabled;
|
||||
|
||||
/** Returns the current sharedApplication.
|
||||
*
|
||||
* @return the current application instance if in an app, or nil if in extension or if it doesn't
|
||||
* exist.
|
||||
*/
|
||||
+ (nullable GULApplication *)sharedApplication;
|
||||
|
||||
/** Do not initialize this class. */
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface GULAppEnvironmentUtil : NSObject
|
||||
|
||||
/// Indicates whether the app is from Apple Store or not. Returns NO if the app is on simulator,
|
||||
/// development environment or sideloaded.
|
||||
+ (BOOL)isFromAppStore;
|
||||
|
||||
/// Indicates whether the app is a Testflight app. Returns YES if the app has sandbox receipt.
|
||||
/// Returns NO otherwise.
|
||||
+ (BOOL)isAppStoreReceiptSandbox;
|
||||
|
||||
/// Indicates whether the app is on simulator or not at runtime depending on the device
|
||||
/// architecture.
|
||||
+ (BOOL)isSimulator;
|
||||
|
||||
/// The current device model. Returns an empty string if device model cannot be retrieved.
|
||||
+ (nullable NSString *)deviceModel;
|
||||
|
||||
/// The current device model, with simulator-specific values. Returns an empty string if device
|
||||
/// model cannot be retrieved.
|
||||
+ (nullable NSString *)deviceSimulatorModel;
|
||||
|
||||
/// The current operating system version. Returns an empty string if the system version cannot be
|
||||
/// retrieved.
|
||||
+ (NSString *)systemVersion;
|
||||
|
||||
/// Indicates whether it is running inside an extension or an app.
|
||||
+ (BOOL)isAppExtension;
|
||||
|
||||
/// @return Returns @YES when is run on iOS version greater or equal to 7.0
|
||||
+ (BOOL)isIOS7OrHigher DEPRECATED_MSG_ATTRIBUTE(
|
||||
"Always `YES` because only iOS 8 and higher supported. The method will be removed.");
|
||||
|
||||
/// @return YES if Swift runtime detected in the app.
|
||||
+ (BOOL)hasSwiftRuntime __deprecated;
|
||||
|
||||
/// @return An Apple platform. Possible values "ios", "tvos", "macos", "watchos", "maccatalyst", and
|
||||
/// "visionos".
|
||||
+ (NSString *)applePlatform;
|
||||
|
||||
/// @return An Apple Device platform. Same possible values as `applePlatform`, with the addition of
|
||||
/// "ipados".
|
||||
+ (NSString *)appleDevicePlatform;
|
||||
|
||||
/// @return The way the library was added to the app, e.g. "swiftpm", "cocoapods", etc.
|
||||
+ (NSString *)deploymentType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if TARGET_OS_IOS || TARGET_OS_TV || (defined(TARGET_OS_VISION) && TARGET_OS_VISION)
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#define GULApplication UIApplication
|
||||
#define GULApplicationDelegate UIApplicationDelegate
|
||||
#define GULUserActivityRestoring UIUserActivityRestoring
|
||||
|
||||
static NSString *const kGULApplicationClassName = @"UIApplication";
|
||||
|
||||
#elif TARGET_OS_OSX
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#define GULApplication NSApplication
|
||||
#define GULApplicationDelegate NSApplicationDelegate
|
||||
#define GULUserActivityRestoring NSUserActivityRestoring
|
||||
|
||||
static NSString *const kGULApplicationClassName = @"NSApplication";
|
||||
|
||||
#elif TARGET_OS_WATCH
|
||||
|
||||
#import <WatchKit/WatchKit.h>
|
||||
|
||||
// We match the according watchOS API but swizzling should not work in watch
|
||||
#define GULApplication WKExtension
|
||||
#define GULApplicationDelegate WKExtensionDelegate
|
||||
#define GULUserActivityRestoring NSUserActivityRestoring
|
||||
|
||||
static NSString *const kGULApplicationClassName = @"WKExtension";
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* Describes an object that can store and fetch heartbeat dates for given tags.
|
||||
*/
|
||||
@protocol GULHeartbeatDateStorable <NSObject>
|
||||
|
||||
/**
|
||||
* Reads the date from the specified file for the given tag.
|
||||
* @return Returns date if exists, otherwise `nil`.
|
||||
*/
|
||||
- (nullable NSDate *)heartbeatDateForTag:(NSString *)tag;
|
||||
|
||||
/**
|
||||
* Saves the date for the specified tag in the specified file.
|
||||
* @return YES on success, NO otherwise.
|
||||
*/
|
||||
- (BOOL)setHearbeatDate:(NSDate *)date forTag:(NSString *)tag;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2019 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GULHeartbeatDateStorable.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// The name of the directory where the heartbeat data is stored.
|
||||
extern NSString *const kGULHeartbeatStorageDirectory;
|
||||
|
||||
/// Stores either a date or a dictionary to a specified file.
|
||||
@interface GULHeartbeatDateStorage : NSObject <GULHeartbeatDateStorable>
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@property(nonatomic, readonly) NSURL *fileURL;
|
||||
|
||||
/**
|
||||
* Default initializer.
|
||||
* @param fileName The name of the file to store the date information.
|
||||
* exist, it will be created if needed.
|
||||
*/
|
||||
- (instancetype)initWithFileName:(NSString *)fileName;
|
||||
|
||||
/**
|
||||
* Reads the date from the specified file for the given tag.
|
||||
* @return Returns date if exists, otherwise `nil`.
|
||||
*/
|
||||
- (nullable NSDate *)heartbeatDateForTag:(NSString *)tag;
|
||||
|
||||
/**
|
||||
* Saves the date for the specified tag in the specified file.
|
||||
* @return YES on success, NO otherwise.
|
||||
*/
|
||||
- (BOOL)setHearbeatDate:(NSDate *)date forTag:(NSString *)tag;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GULHeartbeatDateStorable.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// Stores either a date or a dictionary to a specified file.
|
||||
@interface GULHeartbeatDateStorageUserDefaults : NSObject <GULHeartbeatDateStorable>
|
||||
|
||||
/**
|
||||
* Default initializer. tvOS can only write to the cache directory and
|
||||
* there are no guarantees that the directory will persist. User defaults will
|
||||
* be retained, so that should be used instead.
|
||||
* @param defaults User defaults instance to store the heartbeat information.
|
||||
* @param key The key to be used with the user defaults instance.
|
||||
*/
|
||||
- (instancetype)initWithDefaults:(NSUserDefaults *)defaults key:(NSString *)key;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* Reads the date from the specified file for the given tag.
|
||||
* @return Returns date if exists, otherwise `nil`.
|
||||
*/
|
||||
- (nullable NSDate *)heartbeatDateForTag:(NSString *)tag;
|
||||
|
||||
/**
|
||||
* Saves the date for the specified tag in the specified file.
|
||||
* @return YES on success, NO otherwise.
|
||||
*/
|
||||
- (BOOL)setHearbeatDate:(NSDate *)date forTag:(NSString *)tag;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright 2019 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class FBLPromise<ValueType>;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// The class provides a convenient, multiplatform abstraction of the Keychain.
|
||||
///
|
||||
/// When using this API on macOS, the corresponding target must be signed with a provisioning
|
||||
/// profile that has the Keychain Sharing capability enabled.
|
||||
@interface GULKeychainStorage : NSObject
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/** Initializes the keychain storage with Keychain Service name.
|
||||
* @param service A Keychain Service name that will be used to store and retrieve objects. See also
|
||||
* `kSecAttrService`.
|
||||
*/
|
||||
- (instancetype)initWithService:(NSString *)service;
|
||||
|
||||
/**
|
||||
* Get an object by key.
|
||||
* @param key The key.
|
||||
* @param objectClass The expected object class required by `NSSecureCoding`.
|
||||
* @param accessGroup The Keychain Access Group.
|
||||
*
|
||||
* @return Returns a promise. It is resolved with an object stored by key if exists. It is resolved
|
||||
* with `nil` when the object not found. It fails on a Keychain error.
|
||||
*/
|
||||
- (FBLPromise<id<NSSecureCoding>> *)getObjectForKey:(NSString *)key
|
||||
objectClass:(Class)objectClass
|
||||
accessGroup:(nullable NSString *)accessGroup;
|
||||
|
||||
/**
|
||||
* Saves the given object by the given key.
|
||||
* @param object The object to store.
|
||||
* @param key The key to store the object. If there is an existing object by the key, it will be
|
||||
* overridden.
|
||||
* @param accessGroup The Keychain Access Group.
|
||||
*
|
||||
* @return Returns which is resolved with `[NSNull null]` on success.
|
||||
*/
|
||||
- (FBLPromise<NSNull *> *)setObject:(id<NSSecureCoding>)object
|
||||
forKey:(NSString *)key
|
||||
accessGroup:(nullable NSString *)accessGroup;
|
||||
|
||||
/**
|
||||
* Removes the object by the given key.
|
||||
* @param key The key to store the object. If there is an existing object by the key, it will be
|
||||
* overridden.
|
||||
* @param accessGroup The Keychain Access Group.
|
||||
*
|
||||
* @return Returns which is resolved with `[NSNull null]` on success.
|
||||
*/
|
||||
- (FBLPromise<NSNull *> *)removeObjectForKey:(NSString *)key
|
||||
accessGroup:(nullable NSString *)accessGroup;
|
||||
|
||||
#if TARGET_OS_OSX
|
||||
/// If not `nil`, then only this keychain will be used to save and read data (see
|
||||
/// `kSecMatchSearchList` and `kSecUseKeychain`. It is mostly intended to be used by unit tests.
|
||||
@property(nonatomic, nullable) SecKeychainRef keychainRef;
|
||||
#endif // TARGET_OS_OSX
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2019 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
FOUNDATION_EXPORT NSString *const kGULKeychainUtilsErrorDomain;
|
||||
|
||||
/// A collection of helper functions that abstract away common Keychain operations.
|
||||
///
|
||||
/// When using this API on macOS, the corresponding target must be signed with a provisioning
|
||||
/// profile that has the Keychain Sharing capability enabled.
|
||||
@interface GULKeychainUtils : NSObject
|
||||
|
||||
/** Fetches a keychain item data matching to the provided query.
|
||||
* @param query A dictionary with Keychain query parameters. See docs for `SecItemCopyMatching` for
|
||||
* details.
|
||||
* @param outError A pointer to `NSError` instance or `NULL`. The instance at `outError` will be
|
||||
* assigned with an error if there is.
|
||||
* @returns Data for the first Keychain Item matching the provided query or `nil` if there is not
|
||||
* such an item (`outError` will be `nil` in this case) or an error occurred.
|
||||
*/
|
||||
+ (nullable NSData *)getItemWithQuery:(NSDictionary *)query
|
||||
error:(NSError *_Nullable *_Nullable)outError;
|
||||
|
||||
/** Stores data to a Keychain Item matching to the provided query. An existing Keychain Item
|
||||
* matching the query parameters will be updated or a new will be created.
|
||||
* @param item A Keychain Item data to store.
|
||||
* @param query A dictionary with Keychain query parameters. See docs for `SecItemAdd` and
|
||||
* `SecItemUpdate` for details.
|
||||
* @param outError A pointer to `NSError` instance or `NULL`. The instance at `outError` will be
|
||||
* assigned with an error if there is.
|
||||
* @returns `YES` when data was successfully stored, `NO` otherwise.
|
||||
*/
|
||||
+ (BOOL)setItem:(NSData *)item
|
||||
withQuery:(NSDictionary *)query
|
||||
error:(NSError *_Nullable *_Nullable)outError;
|
||||
|
||||
/** Removes a Keychain Item matching to the provided query.
|
||||
* @param query A dictionary with Keychain query parameters. See docs for `SecItemDelete` for
|
||||
* details.
|
||||
* @param outError A pointer to `NSError` instance or `NULL`. The instance at `outError` will be
|
||||
* assigned with an error if there is.
|
||||
* @returns `YES` if the item was removed successfully or doesn't exist, `NO` otherwise.
|
||||
*/
|
||||
+ (BOOL)removeItemWithQuery:(NSDictionary *)query error:(NSError *_Nullable *_Nullable)outError;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GULLoggerLevel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* The services used in the logger.
|
||||
*/
|
||||
typedef NSString *const GULLoggerService;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
* Initialize GULLogger.
|
||||
*/
|
||||
extern void GULLoggerInitializeASL(void);
|
||||
|
||||
/**
|
||||
* Override log level to Debug.
|
||||
*/
|
||||
void GULLoggerForceDebug(void);
|
||||
|
||||
/**
|
||||
* Turn on logging to STDERR.
|
||||
*/
|
||||
extern void GULLoggerEnableSTDERR(void);
|
||||
|
||||
/**
|
||||
* Gets the current GULLoggerLevel.
|
||||
*/
|
||||
extern GULLoggerLevel GULGetLoggerLevel(void);
|
||||
|
||||
/**
|
||||
* Changes the default logging level of GULLoggerLevelNotice to a user-specified level.
|
||||
* The default level cannot be set above GULLoggerLevelNotice if the app is running from App Store.
|
||||
* (required) log level (one of the GULLoggerLevel enum values).
|
||||
*/
|
||||
extern void GULSetLoggerLevel(GULLoggerLevel loggerLevel);
|
||||
|
||||
/**
|
||||
* Checks if the specified logger level is loggable given the current settings.
|
||||
* (required) log level (one of the GULLoggerLevel enum values).
|
||||
*/
|
||||
extern BOOL GULIsLoggableLevel(GULLoggerLevel loggerLevel);
|
||||
|
||||
/**
|
||||
* Register version to include in logs.
|
||||
* (required) version
|
||||
*/
|
||||
extern void GULLoggerRegisterVersion(NSString *version);
|
||||
|
||||
/**
|
||||
* Logs a message to the Xcode console and the device log. If running from AppStore, will
|
||||
* not log any messages with a level higher than GULLoggerLevelNotice to avoid log spamming.
|
||||
* (required) log level (one of the GULLoggerLevel enum values).
|
||||
* (required) service name of type GULLoggerService.
|
||||
* (required) message code starting with "I-" which means iOS, followed by a capitalized
|
||||
* three-character service identifier and a six digit integer message ID that is unique
|
||||
* within the service.
|
||||
* An example of the message code is @"I-COR000001".
|
||||
* (required) message string which can be a format string.
|
||||
* (optional) variable arguments list obtained from calling va_start, used when message is a format
|
||||
* string.
|
||||
*/
|
||||
extern void GULLogBasic(GULLoggerLevel level,
|
||||
GULLoggerService service,
|
||||
BOOL forceLog,
|
||||
NSString *messageCode,
|
||||
NSString *message,
|
||||
// On 64-bit simulators, va_list is not a pointer, so cannot be marked nullable
|
||||
// See: http://stackoverflow.com/q/29095469
|
||||
#if __LP64__ && TARGET_OS_SIMULATOR || TARGET_OS_OSX
|
||||
va_list args_ptr
|
||||
#else
|
||||
va_list _Nullable args_ptr
|
||||
#endif
|
||||
);
|
||||
|
||||
/**
|
||||
* The following functions accept the following parameters in order:
|
||||
* (required) service name of type GULLoggerService.
|
||||
* (required) message code starting from "I-" which means iOS, followed by a capitalized
|
||||
* three-character service identifier and a six digit integer message ID that is unique
|
||||
* within the service.
|
||||
* An example of the message code is @"I-COR000001".
|
||||
* See go/firebase-log-proposal for details.
|
||||
* (required) message string which can be a format string.
|
||||
* (optional) the list of arguments to substitute into the format string.
|
||||
* Example usage:
|
||||
* GULLogError(kGULLoggerCore, @"I-COR000001", @"Configuration of %@ failed.", app.name);
|
||||
*/
|
||||
extern void GULLogError(GULLoggerService service,
|
||||
BOOL force,
|
||||
NSString *messageCode,
|
||||
NSString *message,
|
||||
...) NS_FORMAT_FUNCTION(4, 5);
|
||||
extern void GULLogWarning(GULLoggerService service,
|
||||
BOOL force,
|
||||
NSString *messageCode,
|
||||
NSString *message,
|
||||
...) NS_FORMAT_FUNCTION(4, 5);
|
||||
extern void GULLogNotice(GULLoggerService service,
|
||||
BOOL force,
|
||||
NSString *messageCode,
|
||||
NSString *message,
|
||||
...) NS_FORMAT_FUNCTION(4, 5);
|
||||
extern void GULLogInfo(GULLoggerService service,
|
||||
BOOL force,
|
||||
NSString *messageCode,
|
||||
NSString *message,
|
||||
...) NS_FORMAT_FUNCTION(4, 5);
|
||||
extern void GULLogDebug(GULLoggerService service,
|
||||
BOOL force,
|
||||
NSString *messageCode,
|
||||
NSString *message,
|
||||
...) NS_FORMAT_FUNCTION(4, 5);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
@interface GULLoggerWrapper : NSObject
|
||||
|
||||
/**
|
||||
* Objective-C wrapper for GULLogBasic to allow weak linking to GULLogger
|
||||
* (required) log level (one of the GULLoggerLevel enum values).
|
||||
* (required) service name of type GULLoggerService.
|
||||
* (required) message code starting with "I-" which means iOS, followed by a capitalized
|
||||
* three-character service identifier and a six digit integer message ID that is unique
|
||||
* within the service.
|
||||
* An example of the message code is @"I-COR000001".
|
||||
* (required) message string which can be a format string.
|
||||
* (optional) variable arguments list obtained from calling va_start, used when message is a format
|
||||
* string.
|
||||
*/
|
||||
|
||||
+ (void)logWithLevel:(GULLoggerLevel)level
|
||||
withService:(GULLoggerService)service
|
||||
withCode:(NSString *)messageCode
|
||||
withMessage:(NSString *)message
|
||||
withArgs:(va_list)args;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* The log levels used by internal logging.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, GULLoggerLevel) {
|
||||
/** Error level, matches ASL_LEVEL_ERR. */
|
||||
GULLoggerLevelError = 3,
|
||||
/** Warning level, matches ASL_LEVEL_WARNING. */
|
||||
GULLoggerLevelWarning = 4,
|
||||
/** Notice level, matches ASL_LEVEL_NOTICE. */
|
||||
GULLoggerLevelNotice = 5,
|
||||
/** Info level, matches ASL_LEVEL_INFO. */
|
||||
GULLoggerLevelInfo = 6,
|
||||
/** Debug level, matches ASL_LEVEL_DEBUG. */
|
||||
GULLoggerLevelDebug = 7,
|
||||
/** Minimum log level. */
|
||||
GULLoggerLevelMin = GULLoggerLevelError,
|
||||
/** Maximum log level. */
|
||||
GULLoggerLevelMax = GULLoggerLevelDebug
|
||||
} NS_SWIFT_NAME(GoogleLoggerLevel);
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/// A mutable dictionary that provides atomic accessor and mutators.
|
||||
@interface GULMutableDictionary : NSObject
|
||||
|
||||
/// Returns an object given a key in the dictionary or nil if not found.
|
||||
- (id)objectForKey:(id)key;
|
||||
|
||||
/// Updates the object given its key or adds it to the dictionary if it is not in the dictionary.
|
||||
- (void)setObject:(id)object forKey:(id<NSCopying>)key;
|
||||
|
||||
/// Removes the object given its session ID from the dictionary.
|
||||
- (void)removeObjectForKey:(id)key;
|
||||
|
||||
/// Removes all objects.
|
||||
- (void)removeAllObjects;
|
||||
|
||||
/// Returns the number of current objects in the dictionary.
|
||||
- (NSUInteger)count;
|
||||
|
||||
/// Returns an object given a key in the dictionary or nil if not found.
|
||||
- (id)objectForKeyedSubscript:(id<NSCopying>)key;
|
||||
|
||||
/// Updates the object given its key or adds it to the dictionary if it is not in the dictionary.
|
||||
- (void)setObject:(id)obj forKeyedSubscript:(id<NSCopying>)key;
|
||||
|
||||
/// Returns the immutable dictionary.
|
||||
- (NSDictionary *)dictionary;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright 2018 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/// This is a copy of Google Toolbox for Mac library to avoid creating an extra framework.
|
||||
|
||||
// NOTE: For 64bit, none of these apis handle input sizes >32bits, they will return nil when given
|
||||
// such data. To handle data of that size you really should be streaming it rather then doing it all
|
||||
// in memory.
|
||||
|
||||
@interface NSData (GULGzip)
|
||||
|
||||
/// Returns an data as the result of decompressing the payload of |data|.The data to decompress must
|
||||
/// be a gzipped payloads.
|
||||
+ (NSData *)gul_dataByInflatingGzippedData:(NSData *)data error:(NSError **)error;
|
||||
|
||||
/// Returns an compressed data with the result of gzipping the payload of |data|. Uses the default
|
||||
/// compression level.
|
||||
+ (NSData *)gul_dataByGzippingData:(NSData *)data error:(NSError **)error;
|
||||
|
||||
FOUNDATION_EXPORT NSString *const GULNSDataZlibErrorDomain;
|
||||
FOUNDATION_EXPORT NSString *const GULNSDataZlibErrorKey; // NSNumber
|
||||
FOUNDATION_EXPORT NSString *const GULNSDataZlibRemainingBytesKey; // NSNumber
|
||||
|
||||
typedef NS_ENUM(NSInteger, GULNSDataZlibError) {
|
||||
GULNSDataZlibErrorGreaterThan32BitsToCompress = 1024,
|
||||
// An internal zlib error.
|
||||
// GULNSDataZlibErrorKey will contain the error value.
|
||||
// NSLocalizedDescriptionKey may contain an error string from zlib.
|
||||
// Look in zlib.h for list of errors.
|
||||
GULNSDataZlibErrorInternal,
|
||||
// There was left over data in the buffer that was not used.
|
||||
// GULNSDataZlibRemainingBytesKey will contain number of remaining bytes.
|
||||
GULNSDataZlibErrorDataRemaining
|
||||
};
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GULNetworkConstants.h"
|
||||
#import "GULNetworkLoggerProtocol.h"
|
||||
#import "GULNetworkURLSession.h"
|
||||
|
||||
/// Delegate protocol for GULNetwork events.
|
||||
@protocol GULNetworkReachabilityDelegate
|
||||
|
||||
/// Tells the delegate to handle events when the network reachability changes to connected or not
|
||||
/// connected.
|
||||
- (void)reachabilityDidChange;
|
||||
|
||||
@end
|
||||
|
||||
/// The Network component that provides network status and handles network requests and responses.
|
||||
/// This is not thread safe.
|
||||
///
|
||||
/// NOTE:
|
||||
/// User must add FIRAnalytics handleEventsForBackgroundURLSessionID:completionHandler to the
|
||||
/// AppDelegate application:handleEventsForBackgroundURLSession:completionHandler:
|
||||
@interface GULNetwork : NSObject
|
||||
|
||||
/// Indicates if network connectivity is available.
|
||||
@property(nonatomic, readonly, getter=isNetworkConnected) BOOL networkConnected;
|
||||
|
||||
/// Indicates if there are any uploads in progress.
|
||||
@property(nonatomic, readonly, getter=hasUploadInProgress) BOOL uploadInProgress;
|
||||
|
||||
/// An optional delegate that can be used in the event when network reachability changes.
|
||||
@property(nonatomic, weak) id<GULNetworkReachabilityDelegate> reachabilityDelegate;
|
||||
|
||||
/// An optional delegate that can be used to log messages, warnings or errors that occur in the
|
||||
/// network operations.
|
||||
@property(nonatomic, weak) id<GULNetworkLoggerDelegate> loggerDelegate;
|
||||
|
||||
/// Indicates whether the logger should display debug messages.
|
||||
@property(nonatomic, assign) BOOL isDebugModeEnabled;
|
||||
|
||||
/// The time interval in seconds for the network request to timeout.
|
||||
@property(nonatomic, assign) NSTimeInterval timeoutInterval;
|
||||
|
||||
/// Initializes with the default reachability host.
|
||||
- (instancetype)init;
|
||||
|
||||
/// Initializes with a custom reachability host.
|
||||
- (instancetype)initWithReachabilityHost:(NSString *)reachabilityHost;
|
||||
|
||||
/// Handles events when background session with the given ID has finished.
|
||||
+ (void)handleEventsForBackgroundURLSessionID:(NSString *)sessionID
|
||||
completionHandler:(GULNetworkSystemCompletionHandler)completionHandler;
|
||||
|
||||
/// Compresses and sends a POST request with the provided data to the URL. The session will be
|
||||
/// background session if usingBackgroundSession is YES. Otherwise, the POST session is default
|
||||
/// session. Returns a session ID or nil if an error occurs.
|
||||
- (NSString *)postURL:(NSURL *)url
|
||||
payload:(NSData *)payload
|
||||
queue:(dispatch_queue_t)queue
|
||||
usingBackgroundSession:(BOOL)usingBackgroundSession
|
||||
completionHandler:(GULNetworkCompletionHandler)handler;
|
||||
|
||||
/// Compresses and sends a POST request with the provided headers and data to the URL. The session
|
||||
/// will be background session if usingBackgroundSession is YES. Otherwise, the POST session is
|
||||
/// default session. Returns a session ID or nil if an error occurs.
|
||||
- (NSString *)postURL:(NSURL *)url
|
||||
headers:(NSDictionary *)headers
|
||||
payload:(NSData *)payload
|
||||
queue:(dispatch_queue_t)queue
|
||||
usingBackgroundSession:(BOOL)usingBackgroundSession
|
||||
completionHandler:(GULNetworkCompletionHandler)handler;
|
||||
|
||||
/// Sends a GET request with the provided data to the URL. The session will be background session
|
||||
/// if usingBackgroundSession is YES. Otherwise, the GET session is default session. Returns a
|
||||
/// session ID or nil if an error occurs.
|
||||
- (NSString *)getURL:(NSURL *)url
|
||||
headers:(NSDictionary *)headers
|
||||
queue:(dispatch_queue_t)queue
|
||||
usingBackgroundSession:(BOOL)usingBackgroundSession
|
||||
completionHandler:(GULNetworkCompletionHandler)handler;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/// Error codes in Firebase Network error domain.
|
||||
/// Note: these error codes should never change. It would make it harder to decode the errors if
|
||||
/// we inadvertently altered any of these codes in a future SDK version.
|
||||
typedef NS_ENUM(NSInteger, GULNetworkErrorCode) {
|
||||
/// Unknown error.
|
||||
GULNetworkErrorCodeUnknown = 0,
|
||||
/// Error occurs when the request URL is invalid.
|
||||
GULErrorCodeNetworkInvalidURL = 1,
|
||||
/// Error occurs when request cannot be constructed.
|
||||
GULErrorCodeNetworkRequestCreation = 2,
|
||||
/// Error occurs when payload cannot be compressed.
|
||||
GULErrorCodeNetworkPayloadCompression = 3,
|
||||
/// Error occurs when session task cannot be created.
|
||||
GULErrorCodeNetworkSessionTaskCreation = 4,
|
||||
/// Error occurs when there is no response.
|
||||
GULErrorCodeNetworkInvalidResponse = 5
|
||||
};
|
||||
|
||||
#pragma mark - Network constants
|
||||
|
||||
/// The prefix of the ID of the background session.
|
||||
extern NSString *const kGULNetworkBackgroundSessionConfigIDPrefix;
|
||||
|
||||
/// The sub directory to store the files of data that is being uploaded in the background.
|
||||
extern NSString *const kGULNetworkApplicationSupportSubdirectory;
|
||||
|
||||
/// Name of the temporary directory that stores files for background uploading.
|
||||
extern NSString *const kGULNetworkTempDirectoryName;
|
||||
|
||||
/// The period when the temporary uploading file can stay.
|
||||
extern const NSTimeInterval kGULNetworkTempFolderExpireTime;
|
||||
|
||||
/// The default network request timeout interval.
|
||||
extern const NSTimeInterval kGULNetworkTimeOutInterval;
|
||||
|
||||
/// The host to check the reachability of the network.
|
||||
extern NSString *const kGULNetworkReachabilityHost;
|
||||
|
||||
/// The key to get the error context of the UserInfo.
|
||||
extern NSString *const kGULNetworkErrorContext;
|
||||
|
||||
#pragma mark - Network Status Code
|
||||
|
||||
extern const int kGULNetworkHTTPStatusOK;
|
||||
extern const int kGULNetworkHTTPStatusNoContent;
|
||||
extern const int kGULNetworkHTTPStatusCodeMultipleChoices;
|
||||
extern const int kGULNetworkHTTPStatusCodeMovedPermanently;
|
||||
extern const int kGULNetworkHTTPStatusCodeFound;
|
||||
extern const int kGULNetworkHTTPStatusCodeNotModified;
|
||||
extern const int kGULNetworkHTTPStatusCodeMovedTemporarily;
|
||||
extern const int kGULNetworkHTTPStatusCodeNotFound;
|
||||
extern const int kGULNetworkHTTPStatusCodeCannotAcceptTraffic;
|
||||
extern const int kGULNetworkHTTPStatusCodeUnavailable;
|
||||
@@ -0,0 +1,57 @@
|
||||
// Copyright 2022 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// The type of network that the device is running with. Values should correspond to the NetworkType
|
||||
/// values in android/play/playlog/proto/clientanalytics.proto
|
||||
typedef NS_ENUM(NSInteger, GULNetworkType) {
|
||||
GULNetworkTypeNone = -1,
|
||||
GULNetworkTypeMobile = 0,
|
||||
GULNetworkTypeWIFI = 1,
|
||||
};
|
||||
|
||||
/// Collection of utilities to read network status information
|
||||
@interface GULNetworkInfo : NSObject
|
||||
|
||||
/// Returns the cellular mobile country code (mcc) if CoreTelephony is supported, otherwise nil
|
||||
+ (NSString *_Nullable)getNetworkMobileCountryCode;
|
||||
|
||||
/// Returns the cellular mobile network code (mnc) if CoreTelephony is supported, otherwise nil
|
||||
+ (NSString *_Nullable)getNetworkMobileNetworkCode;
|
||||
|
||||
/**
|
||||
* Returns the formatted MccMnc if the inputs are valid, otherwise nil
|
||||
* @param mcc The Mobile Country Code returned from `getNetworkMobileCountryCode`
|
||||
* @param mnc The Mobile Network Code returned from `getNetworkMobileNetworkCode`
|
||||
* @returns A string with the concatenated mccMnc if both inputs are valid, otherwise nil
|
||||
*/
|
||||
+ (NSString *_Nullable)formatMcc:(NSString *_Nullable)mcc andMNC:(NSString *_Nullable)mnc;
|
||||
|
||||
/// Returns an enum indicating the network type. The enum values should be easily transferrable to
|
||||
/// the NetworkType value in android/play/playlog/proto/clientanalytics.proto. Right now this always
|
||||
/// returns None on platforms other than iOS. This should be updated in the future to return Wi-Fi
|
||||
/// values for the other platforms when applicable.
|
||||
+ (GULNetworkType)getNetworkType;
|
||||
|
||||
/// Returns a string indicating the radio access technology used by the app. The return value will
|
||||
/// be one of CTRadioAccess constants defined in
|
||||
/// https://developer.apple.com/documentation/coretelephony/cttelephonynetworkinfo/radio_access_technology_constants
|
||||
+ (NSString *)getNetworkRadioType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GULNetworkMessageCode.h"
|
||||
|
||||
/// The log levels used by GULNetworkLogger.
|
||||
typedef NS_ENUM(NSInteger, GULNetworkLogLevel) {
|
||||
kGULNetworkLogLevelError = 3,
|
||||
kGULNetworkLogLevelWarning = 4,
|
||||
kGULNetworkLogLevelInfo = 6,
|
||||
kGULNetworkLogLevelDebug = 7,
|
||||
};
|
||||
|
||||
@protocol GULNetworkLoggerDelegate <NSObject>
|
||||
|
||||
@required
|
||||
/// Tells the delegate to log a message with an array of contexts and the log level.
|
||||
- (void)GULNetwork_logWithLevel:(GULNetworkLogLevel)logLevel
|
||||
messageCode:(GULNetworkMessageCode)messageCode
|
||||
message:(NSString *)message
|
||||
contexts:(NSArray *)contexts;
|
||||
|
||||
/// Tells the delegate to log a message with a context and the log level.
|
||||
- (void)GULNetwork_logWithLevel:(GULNetworkLogLevel)logLevel
|
||||
messageCode:(GULNetworkMessageCode)messageCode
|
||||
message:(NSString *)message
|
||||
context:(id)context;
|
||||
|
||||
/// Tells the delegate to log a message with the log level.
|
||||
- (void)GULNetwork_logWithLevel:(GULNetworkLogLevel)logLevel
|
||||
messageCode:(GULNetworkMessageCode)messageCode
|
||||
message:(NSString *)message;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// Make sure these codes do not overlap with any contained in the FIRAMessageCode enum.
|
||||
typedef NS_ENUM(NSInteger, GULNetworkMessageCode) {
|
||||
// GULNetwork.m
|
||||
kGULNetworkMessageCodeNetwork000 = 900000, // I-NET900000
|
||||
kGULNetworkMessageCodeNetwork001 = 900001, // I-NET900001
|
||||
kGULNetworkMessageCodeNetwork002 = 900002, // I-NET900002
|
||||
kGULNetworkMessageCodeNetwork003 = 900003, // I-NET900003
|
||||
// GULNetworkURLSession.m
|
||||
kGULNetworkMessageCodeURLSession000 = 901000, // I-NET901000
|
||||
kGULNetworkMessageCodeURLSession001 = 901001, // I-NET901001
|
||||
kGULNetworkMessageCodeURLSession002 = 901002, // I-NET901002
|
||||
kGULNetworkMessageCodeURLSession003 = 901003, // I-NET901003
|
||||
kGULNetworkMessageCodeURLSession004 = 901004, // I-NET901004
|
||||
kGULNetworkMessageCodeURLSession005 = 901005, // I-NET901005
|
||||
kGULNetworkMessageCodeURLSession006 = 901006, // I-NET901006
|
||||
kGULNetworkMessageCodeURLSession007 = 901007, // I-NET901007
|
||||
kGULNetworkMessageCodeURLSession008 = 901008, // I-NET901008
|
||||
kGULNetworkMessageCodeURLSession009 = 901009, // I-NET901009
|
||||
kGULNetworkMessageCodeURLSession010 = 901010, // I-NET901010
|
||||
kGULNetworkMessageCodeURLSession011 = 901011, // I-NET901011
|
||||
kGULNetworkMessageCodeURLSession012 = 901012, // I-NET901012
|
||||
kGULNetworkMessageCodeURLSession013 = 901013, // I-NET901013
|
||||
kGULNetworkMessageCodeURLSession014 = 901014, // I-NET901014
|
||||
kGULNetworkMessageCodeURLSession015 = 901015, // I-NET901015
|
||||
kGULNetworkMessageCodeURLSession016 = 901016, // I-NET901016
|
||||
kGULNetworkMessageCodeURLSession017 = 901017, // I-NET901017
|
||||
kGULNetworkMessageCodeURLSession018 = 901018, // I-NET901018
|
||||
kGULNetworkMessageCodeURLSession019 = 901019, // I-NET901019
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GULNetworkLoggerProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef void (^GULNetworkCompletionHandler)(NSHTTPURLResponse *_Nullable response,
|
||||
NSData *_Nullable data,
|
||||
NSError *_Nullable error);
|
||||
typedef void (^GULNetworkURLSessionCompletionHandler)(NSHTTPURLResponse *_Nullable response,
|
||||
NSData *_Nullable data,
|
||||
NSString *sessionID,
|
||||
NSError *_Nullable error);
|
||||
typedef void (^GULNetworkSystemCompletionHandler)(void);
|
||||
|
||||
/// The protocol that uses NSURLSession for iOS >= 7.0 to handle requests and responses.
|
||||
@interface GULNetworkURLSession : NSObject
|
||||
|
||||
/// Indicates whether the background network is enabled. Default value is NO.
|
||||
@property(nonatomic, getter=isBackgroundNetworkEnabled) BOOL backgroundNetworkEnabled;
|
||||
|
||||
/// The logger delegate to log message, errors or warnings that occur during the network operations.
|
||||
@property(nonatomic, weak, nullable) id<GULNetworkLoggerDelegate> loggerDelegate;
|
||||
|
||||
/// Calls the system provided completion handler after the background session is finished.
|
||||
+ (void)handleEventsForBackgroundURLSessionID:(NSString *)sessionID
|
||||
completionHandler:(GULNetworkSystemCompletionHandler)completionHandler;
|
||||
|
||||
/// Initializes with logger delegate.
|
||||
- (instancetype)initWithNetworkLoggerDelegate:
|
||||
(nullable id<GULNetworkLoggerDelegate>)networkLoggerDelegate NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/// Sends an asynchronous POST request and calls the provided completion handler when the request
|
||||
/// completes or when errors occur, and returns an ID of the session/connection.
|
||||
- (nullable NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request
|
||||
completionHandler:(GULNetworkURLSessionCompletionHandler)handler;
|
||||
|
||||
/// Sends an asynchronous GET request and calls the provided completion handler when the request
|
||||
/// completes or when errors occur, and returns an ID of the session.
|
||||
- (nullable NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request
|
||||
completionHandler:(GULNetworkURLSessionCompletionHandler)handler;
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@end
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** Enums that map to their OBJC-prefixed counterparts. */
|
||||
typedef OBJC_ENUM(uintptr_t, GUL_ASSOCIATION){
|
||||
|
||||
// Is a weak association.
|
||||
GUL_ASSOCIATION_ASSIGN,
|
||||
|
||||
// Is a nonatomic strong association.
|
||||
GUL_ASSOCIATION_RETAIN_NONATOMIC,
|
||||
|
||||
// Is a nonatomic copy association.
|
||||
GUL_ASSOCIATION_COPY_NONATOMIC,
|
||||
|
||||
// Is an atomic strong association.
|
||||
GUL_ASSOCIATION_RETAIN,
|
||||
|
||||
// Is an atomic copy association.
|
||||
GUL_ASSOCIATION_COPY};
|
||||
|
||||
/** This class handles swizzling a specific instance of a class by generating a
|
||||
* dynamic subclass and installing selectors and properties onto the dynamic
|
||||
* subclass. Then, the instance's class is set to the dynamic subclass. There
|
||||
* should be a 1:1 ratio of object swizzlers to swizzled instances.
|
||||
*/
|
||||
@interface GULObjectSwizzler : NSObject
|
||||
|
||||
/** The subclass that is generated. */
|
||||
@property(nullable, nonatomic, readonly) Class generatedClass;
|
||||
|
||||
/** Sets an associated object in the runtime. This mechanism can be used to
|
||||
* simulate adding properties.
|
||||
*
|
||||
* @param object The object that will be queried for the associated object.
|
||||
* @param key The key of the associated object.
|
||||
* @param value The value to associate to the swizzled object.
|
||||
* @param association The mechanism to use when associating the objects.
|
||||
*/
|
||||
+ (void)setAssociatedObject:(id)object
|
||||
key:(NSString *)key
|
||||
value:(nullable id)value
|
||||
association:(GUL_ASSOCIATION)association;
|
||||
|
||||
/** Gets an associated object in the runtime. This mechanism can be used to
|
||||
* simulate adding properties.
|
||||
*
|
||||
* @param object The object that will be queried for the associated object.
|
||||
* @param key The key of the associated object.
|
||||
*/
|
||||
+ (nullable id)getAssociatedObject:(id)object key:(NSString *)key;
|
||||
|
||||
/** Please use the designated initializer. */
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/** Instantiates an object swizzler using an object it will operate on.
|
||||
* Generates a new class pair.
|
||||
*
|
||||
* @note There is no need to store this object. After calling -swizzle, this
|
||||
* object can be found by calling -gul_objectSwizzler
|
||||
*
|
||||
* @param object The object to be swizzled.
|
||||
* @return An instance of this class.
|
||||
*/
|
||||
- (instancetype)initWithObject:(id)object NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/** Sets an associated object in the runtime. This mechanism can be used to
|
||||
* simulate adding properties.
|
||||
*
|
||||
* @param key The key of the associated object.
|
||||
* @param value The value to associate to the swizzled object.
|
||||
* @param association The mechanism to use when associating the objects.
|
||||
*/
|
||||
- (void)setAssociatedObjectWithKey:(NSString *)key
|
||||
value:(id)value
|
||||
association:(GUL_ASSOCIATION)association;
|
||||
|
||||
/** Gets an associated object in the runtime. This mechanism can be used to
|
||||
* simulate adding properties.
|
||||
*
|
||||
* @param key The key of the associated object.
|
||||
*/
|
||||
- (nullable id)getAssociatedObjectForKey:(NSString *)key;
|
||||
|
||||
/** Copies a selector from an existing class onto the generated dynamic subclass
|
||||
* that this object will adopt. This mechanism can be used to add methods to
|
||||
* specific instances of a class.
|
||||
*
|
||||
* @note Should not be called after calling -swizzle.
|
||||
* @param selector The selector to add to the instance.
|
||||
* @param aClass The class supplying an implementation of the method.
|
||||
* @param isClassSelector A BOOL specifying whether the selector is a class or
|
||||
* instance selector.
|
||||
*/
|
||||
- (void)copySelector:(SEL)selector fromClass:(Class)aClass isClassSelector:(BOOL)isClassSelector;
|
||||
|
||||
/** Swizzles the object, changing its class to the generated class. Registers
|
||||
* the class pair. */
|
||||
- (void)swizzle;
|
||||
|
||||
/** @return The value of -[objectBeingSwizzled isProxy] */
|
||||
- (BOOL)isSwizzlingProxyObject;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* GULOriginalIMPConvenienceMacros.h
|
||||
*
|
||||
* This header contains convenience macros for invoking the original IMP of a swizzled method.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Invokes original IMP when the original selector takes no arguments.
|
||||
*
|
||||
* @param __receivingObject The object on which the IMP is invoked.
|
||||
* @param __swizzledSEL The selector used for swizzling.
|
||||
* @param __returnType The return type of the original implementation.
|
||||
* @param __originalIMP The original IMP.
|
||||
*/
|
||||
#define GUL_INVOKE_ORIGINAL_IMP0(__receivingObject, __swizzledSEL, __returnType, __originalIMP) \
|
||||
((__returnType(*)(id, SEL))__originalIMP)(__receivingObject, __swizzledSEL)
|
||||
|
||||
/**
|
||||
* Invokes original IMP when the original selector takes 1 argument.
|
||||
*
|
||||
* @param __receivingObject The object on which the IMP is invoked.
|
||||
* @param __swizzledSEL The selector used for swizzling.
|
||||
* @param __returnType The return type of the original implementation.
|
||||
* @param __originalIMP The original IMP.
|
||||
* @param __arg1 The first argument.
|
||||
*/
|
||||
#define GUL_INVOKE_ORIGINAL_IMP1(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \
|
||||
__arg1) \
|
||||
((__returnType(*)(id, SEL, __typeof__(__arg1)))__originalIMP)(__receivingObject, __swizzledSEL, \
|
||||
__arg1)
|
||||
|
||||
/**
|
||||
* Invokes original IMP when the original selector takes 2 arguments.
|
||||
*
|
||||
* @param __receivingObject The object on which the IMP is invoked.
|
||||
* @param __swizzledSEL The selector used for swizzling.
|
||||
* @param __returnType The return type of the original implementation.
|
||||
* @param __originalIMP The original IMP.
|
||||
* @param __arg1 The first argument.
|
||||
* @param __arg2 The second argument.
|
||||
*/
|
||||
#define GUL_INVOKE_ORIGINAL_IMP2(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \
|
||||
__arg1, __arg2) \
|
||||
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2)))__originalIMP)( \
|
||||
__receivingObject, __swizzledSEL, __arg1, __arg2)
|
||||
|
||||
/**
|
||||
* Invokes original IMP when the original selector takes 3 arguments.
|
||||
*
|
||||
* @param __receivingObject The object on which the IMP is invoked.
|
||||
* @param __swizzledSEL The selector used for swizzling.
|
||||
* @param __returnType The return type of the original implementation.
|
||||
* @param __originalIMP The original IMP.
|
||||
* @param __arg1 The first argument.
|
||||
* @param __arg2 The second argument.
|
||||
* @param __arg3 The third argument.
|
||||
*/
|
||||
#define GUL_INVOKE_ORIGINAL_IMP3(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \
|
||||
__arg1, __arg2, __arg3) \
|
||||
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), \
|
||||
__typeof__(__arg3)))__originalIMP)(__receivingObject, __swizzledSEL, __arg1, \
|
||||
__arg2, __arg3)
|
||||
|
||||
/**
|
||||
* Invokes original IMP when the original selector takes 4 arguments.
|
||||
*
|
||||
* @param __receivingObject The object on which the IMP is invoked.
|
||||
* @param __swizzledSEL The selector used for swizzling.
|
||||
* @param __returnType The return type of the original implementation.
|
||||
* @param __originalIMP The original IMP.
|
||||
* @param __arg1 The first argument.
|
||||
* @param __arg2 The second argument.
|
||||
* @param __arg3 The third argument.
|
||||
* @param __arg4 The fourth argument.
|
||||
*/
|
||||
#define GUL_INVOKE_ORIGINAL_IMP4(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \
|
||||
__arg1, __arg2, __arg3, __arg4) \
|
||||
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \
|
||||
__typeof__(__arg4)))__originalIMP)(__receivingObject, __swizzledSEL, __arg1, \
|
||||
__arg2, __arg3, __arg4)
|
||||
|
||||
/**
|
||||
* Invokes original IMP when the original selector takes 5 arguments.
|
||||
*
|
||||
* @param __receivingObject The object on which the IMP is invoked.
|
||||
* @param __swizzledSEL The selector used for swizzling.
|
||||
* @param __returnType The return type of the original implementation.
|
||||
* @param __originalIMP The original IMP.
|
||||
* @param __arg1 The first argument.
|
||||
* @param __arg2 The second argument.
|
||||
* @param __arg3 The third argument.
|
||||
* @param __arg4 The fourth argument.
|
||||
* @param __arg5 The fifth argument.
|
||||
*/
|
||||
#define GUL_INVOKE_ORIGINAL_IMP5(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \
|
||||
__arg1, __arg2, __arg3, __arg4, __arg5) \
|
||||
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \
|
||||
__typeof__(__arg4), __typeof__(__arg5)))__originalIMP)( \
|
||||
__receivingObject, __swizzledSEL, __arg1, __arg2, __arg3, __arg4, __arg5)
|
||||
|
||||
/**
|
||||
* Invokes original IMP when the original selector takes 6 arguments.
|
||||
*
|
||||
* @param __receivingObject The object on which the IMP is invoked.
|
||||
* @param __swizzledSEL The selector used for swizzling.
|
||||
* @param __returnType The return type of the original implementation.
|
||||
* @param __originalIMP The original IMP.
|
||||
* @param __arg1 The first argument.
|
||||
* @param __arg2 The second argument.
|
||||
* @param __arg3 The third argument.
|
||||
* @param __arg4 The fourth argument.
|
||||
* @param __arg5 The fifth argument.
|
||||
* @param __arg6 The sixth argument.
|
||||
*/
|
||||
#define GUL_INVOKE_ORIGINAL_IMP6(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \
|
||||
__arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
|
||||
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \
|
||||
__typeof__(__arg4), __typeof__(__arg5), __typeof__(__arg6)))__originalIMP)( \
|
||||
__receivingObject, __swizzledSEL, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6)
|
||||
|
||||
/**
|
||||
* Invokes original IMP when the original selector takes 7 arguments.
|
||||
*
|
||||
* @param __receivingObject The object on which the IMP is invoked.
|
||||
* @param __swizzledSEL The selector used for swizzling.
|
||||
* @param __returnType The return type of the original implementation.
|
||||
* @param __originalIMP The original IMP.
|
||||
* @param __arg1 The first argument.
|
||||
* @param __arg2 The second argument.
|
||||
* @param __arg3 The third argument.
|
||||
* @param __arg4 The fourth argument.
|
||||
* @param __arg5 The fifth argument.
|
||||
* @param __arg6 The sixth argument.
|
||||
* @param __arg7 The seventh argument.
|
||||
*/
|
||||
#define GUL_INVOKE_ORIGINAL_IMP7(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \
|
||||
__arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7) \
|
||||
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \
|
||||
__typeof__(__arg4), __typeof__(__arg5), __typeof__(__arg6), \
|
||||
__typeof__(__arg7)))__originalIMP)( \
|
||||
__receivingObject, __swizzledSEL, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7)
|
||||
|
||||
/**
|
||||
* Invokes original IMP when the original selector takes 8 arguments.
|
||||
*
|
||||
* @param __receivingObject The object on which the IMP is invoked.
|
||||
* @param __swizzledSEL The selector used for swizzling.
|
||||
* @param __returnType The return type of the original implementation.
|
||||
* @param __originalIMP The original IMP.
|
||||
* @param __arg1 The first argument.
|
||||
* @param __arg2 The second argument.
|
||||
* @param __arg3 The third argument.
|
||||
* @param __arg4 The fourth argument.
|
||||
* @param __arg5 The fifth argument.
|
||||
* @param __arg6 The sixth argument.
|
||||
* @param __arg7 The seventh argument.
|
||||
* @param __arg8 The eighth argument.
|
||||
*/
|
||||
#define GUL_INVOKE_ORIGINAL_IMP8(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \
|
||||
__arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7, __arg8) \
|
||||
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \
|
||||
__typeof__(__arg4), __typeof__(__arg5), __typeof__(__arg6), \
|
||||
__typeof__(__arg7), __typeof__(__arg8)))__originalIMP)( \
|
||||
__receivingObject, __swizzledSEL, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7, \
|
||||
__arg8)
|
||||
|
||||
/**
|
||||
* Invokes original IMP when the original selector takes 9 arguments.
|
||||
*
|
||||
* @param __receivingObject The object on which the IMP is invoked.
|
||||
* @param __swizzledSEL The selector used for swizzling.
|
||||
* @param __returnType The return type of the original implementation.
|
||||
* @param __originalIMP The original IMP.
|
||||
* @param __arg1 The first argument.
|
||||
* @param __arg2 The second argument.
|
||||
* @param __arg3 The third argument.
|
||||
* @param __arg4 The fourth argument.
|
||||
* @param __arg5 The fifth argument.
|
||||
* @param __arg6 The sixth argument.
|
||||
* @param __arg7 The seventh argument.
|
||||
* @param __arg8 The eighth argument.
|
||||
* @param __arg9 The ninth argument.
|
||||
*/
|
||||
#define GUL_INVOKE_ORIGINAL_IMP9(__receivingObject, __swizzledSEL, __returnType, __originalIMP, \
|
||||
__arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7, __arg8, \
|
||||
__arg9) \
|
||||
((__returnType(*)(id, SEL, __typeof__(__arg1), __typeof__(__arg2), __typeof__(__arg3), \
|
||||
__typeof__(__arg4), __typeof__(__arg5), __typeof__(__arg6), \
|
||||
__typeof__(__arg7), __typeof__(__arg8), __typeof__(__arg9)))__originalIMP)( \
|
||||
__receivingObject, __swizzledSEL, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6, __arg7, \
|
||||
__arg8, __arg9)
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#if !TARGET_OS_WATCH
|
||||
#import <SystemConfiguration/SystemConfiguration.h>
|
||||
#endif
|
||||
|
||||
/// Reachability Status
|
||||
typedef enum {
|
||||
kGULReachabilityUnknown, ///< Have not yet checked or been notified whether host is reachable.
|
||||
kGULReachabilityNotReachable, ///< Host is not reachable.
|
||||
kGULReachabilityViaWifi, ///< Host is reachable via Wifi.
|
||||
kGULReachabilityViaCellular, ///< Host is reachable via cellular.
|
||||
} GULReachabilityStatus;
|
||||
|
||||
const NSString *GULReachabilityStatusString(GULReachabilityStatus status);
|
||||
|
||||
@class GULReachabilityChecker;
|
||||
|
||||
/// Google Analytics iOS Reachability Checker.
|
||||
@protocol GULReachabilityDelegate
|
||||
@required
|
||||
/// Called when network status has changed.
|
||||
- (void)reachability:(GULReachabilityChecker *)reachability
|
||||
statusChanged:(GULReachabilityStatus)status;
|
||||
@end
|
||||
|
||||
/// Google Analytics iOS Network Status Checker.
|
||||
@interface GULReachabilityChecker : NSObject
|
||||
|
||||
/// The last known reachability status, or GULReachabilityStatusUnknown if the
|
||||
/// checker is not active.
|
||||
@property(nonatomic, readonly) GULReachabilityStatus reachabilityStatus;
|
||||
/// The host to which reachability status is to be checked.
|
||||
@property(nonatomic, copy, readonly) NSString *host;
|
||||
/// The delegate to be notified of reachability status changes.
|
||||
@property(nonatomic, weak) id<GULReachabilityDelegate> reachabilityDelegate;
|
||||
/// `YES` if the reachability checker is active, `NO` otherwise.
|
||||
@property(nonatomic, readonly) BOOL isActive;
|
||||
|
||||
/// Initialize the reachability checker. Note that you must call start to begin checking for and
|
||||
/// receiving notifications about network status changes.
|
||||
///
|
||||
/// @param reachabilityDelegate The delegate to be notified when reachability status to host
|
||||
/// changes.
|
||||
///
|
||||
/// @param host The name of the host.
|
||||
///
|
||||
- (instancetype)initWithReachabilityDelegate:(id<GULReachabilityDelegate>)reachabilityDelegate
|
||||
withHost:(NSString *)host;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/// Start checking for reachability to the specified host. This has no effect if the status
|
||||
/// checker is already checking for connectivity.
|
||||
///
|
||||
/// @return `YES` if initiating status checking was successful or the status checking has already
|
||||
/// been initiated, `NO` otherwise.
|
||||
- (BOOL)start;
|
||||
|
||||
/// Stop checking for reachability to the specified host. This has no effect if the status
|
||||
/// checker is not checking for connectivity.
|
||||
- (void)stop;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TargetConditionals.h>
|
||||
|
||||
#if !TARGET_OS_OSX
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif // !TARGET_OS_OSX
|
||||
|
||||
#if ((TARGET_OS_IOS || TARGET_OS_TV) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000))
|
||||
#define UISCENE_SUPPORTED 1
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NSString *const GULSceneDelegateInterceptorID;
|
||||
|
||||
/** This class contains methods that isa swizzle the scene delegate. */
|
||||
@interface GULSceneDelegateSwizzler : NSProxy
|
||||
|
||||
#if UISCENE_SUPPORTED
|
||||
|
||||
/** Registers a scene delegate interceptor whose methods will be invoked as they're invoked on the
|
||||
* original scene delegate.
|
||||
*
|
||||
* @param interceptor An instance of a class that conforms to the application delegate protocol.
|
||||
* The interceptor is NOT retained.
|
||||
* @return A unique GULSceneDelegateInterceptorID if interceptor was successfully registered; nil
|
||||
* if it fails.
|
||||
*/
|
||||
+ (nullable GULSceneDelegateInterceptorID)registerSceneDelegateInterceptor:
|
||||
(id<UISceneDelegate>)interceptor API_AVAILABLE(ios(13.0), tvos(13.0));
|
||||
|
||||
/** Unregisters an interceptor with the given ID if it exists.
|
||||
*
|
||||
* @param interceptorID The object that was generated when the interceptor was registered.
|
||||
*/
|
||||
+ (void)unregisterSceneDelegateInterceptorWithID:(GULSceneDelegateInterceptorID)interceptorID
|
||||
API_AVAILABLE(ios(13.0), tvos(13.0));
|
||||
|
||||
/** Do not initialize this class. */
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
#endif // UISCENE_SUPPORTED
|
||||
|
||||
/** This method ensures that the original scene delegate has been proxied. Call this before
|
||||
* registering your interceptor. This method is safe to call multiple times (but it only proxies
|
||||
* the scene delegate once).
|
||||
*
|
||||
* The method has no effect for extensions.
|
||||
*/
|
||||
+ (void)proxyOriginalSceneDelegate;
|
||||
|
||||
/** Indicates whether scene delegate proxy is explicitly disabled or enabled. Enabled by default.
|
||||
*
|
||||
* @return YES if SceneDelegateProxy is Enabled, NO otherwise.
|
||||
*/
|
||||
+ (BOOL)isSceneDelegateProxyEnabled;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright 2019 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** The class wraps `NSKeyedArchiver` and `NSKeyedUnarchiver` API to provide a unified secure coding
|
||||
* methods for iOS versions before and after 11.
|
||||
*/
|
||||
@interface GULSecureCoding : NSObject
|
||||
|
||||
+ (nullable id)unarchivedObjectOfClasses:(NSSet<Class> *)classes
|
||||
fromData:(NSData *)data
|
||||
error:(NSError **)outError;
|
||||
|
||||
+ (nullable id)unarchivedObjectOfClass:(Class)aClass
|
||||
fromData:(NSData *)data
|
||||
error:(NSError **)outError;
|
||||
|
||||
+ (nullable NSData *)archivedDataWithRootObject:(id<NSCoding>)object error:(NSError **)outError;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class GULObjectSwizzler;
|
||||
|
||||
/** This class exists as a method donor. These methods will be added to all objects that are
|
||||
* swizzled by the object swizzler. This class should not be instantiated.
|
||||
*/
|
||||
@interface GULSwizzledObject : NSObject
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/** Copies the methods below to the swizzled object.
|
||||
*
|
||||
* @param objectSwizzler The swizzler to use when adding the methods below.
|
||||
*/
|
||||
+ (void)copyDonorSelectorsUsingObjectSwizzler:(GULObjectSwizzler *)objectSwizzler;
|
||||
|
||||
#pragma mark - Donor methods.
|
||||
|
||||
/** @return The generated subclass. Used in respondsToSelector: calls. */
|
||||
- (Class)gul_class;
|
||||
|
||||
/** @return The object swizzler that manages this object. */
|
||||
- (GULObjectSwizzler *)gul_objectSwizzler;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** This class handles the runtime manipulation necessary to instrument selectors. It stores the
|
||||
* classes and selectors that have been swizzled, and runs all operations on its own queue.
|
||||
*/
|
||||
@interface GULSwizzler : NSObject
|
||||
|
||||
/** Manipulates the Objective-C runtime to replace the original IMP with the supplied block.
|
||||
*
|
||||
* @param aClass The class to swizzle.
|
||||
* @param selector The selector of the class to swizzle.
|
||||
* @param isClassSelector A BOOL specifying whether the selector is a class or instance selector.
|
||||
* @param block The block that replaces the original IMP.
|
||||
*/
|
||||
+ (void)swizzleClass:(Class)aClass
|
||||
selector:(SEL)selector
|
||||
isClassSelector:(BOOL)isClassSelector
|
||||
withBlock:(nullable id)block;
|
||||
|
||||
/** Returns the current IMP for the given class and selector.
|
||||
*
|
||||
* @param aClass The class to use.
|
||||
* @param selector The selector to find the implementation of.
|
||||
* @param isClassSelector A BOOL specifying whether the selector is a class or instance selector.
|
||||
* @return The implementation of the selector in the runtime.
|
||||
*/
|
||||
+ (nullable IMP)currentImplementationForClass:(Class)aClass
|
||||
selector:(SEL)selector
|
||||
isClassSelector:(BOOL)isClassSelector;
|
||||
|
||||
/** Checks the runtime to see if a selector exists on a class. If a property is declared as
|
||||
* @dynamic, we have a reverse swizzling situation, where the implementation of a method exists
|
||||
* only in concrete subclasses, and NOT in the superclass. We can detect that situation using
|
||||
* this helper method. Similarly, we can detect situations where a class doesn't implement a
|
||||
* protocol method.
|
||||
*
|
||||
* @param selector The selector to check for.
|
||||
* @param aClass The class to check.
|
||||
* @param isClassSelector A BOOL specifying whether the selector is a class or instance selector.
|
||||
* @return YES if the method was found in this selector/class combination, NO otherwise.
|
||||
*/
|
||||
+ (BOOL)selector:(SEL)selector existsInClass:(Class)aClass isClassSelector:(BOOL)isClassSelector;
|
||||
|
||||
/** Returns a list of all Objective-C (and not primitive) ivars contained by the given object.
|
||||
*
|
||||
* @param object The object whose ivars will be iterated.
|
||||
* @return The list of ivar objects.
|
||||
*/
|
||||
+ (NSArray<id> *)ivarObjectsForObject:(id)object;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** The class represents HTTP response received from `NSURLSession`. */
|
||||
@interface GULURLSessionDataResponse : NSObject
|
||||
|
||||
@property(nonatomic, readonly) NSHTTPURLResponse *HTTPResponse;
|
||||
@property(nonatomic, nullable, readonly) NSData *HTTPBody;
|
||||
|
||||
- (instancetype)initWithResponse:(NSHTTPURLResponse *)response HTTPBody:(nullable NSData *)body;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,110 @@
|
||||
// Copyright 2018 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// A thread-safe user defaults that uses C functions from CFPreferences.h instead of
|
||||
/// `NSUserDefaults`. This is to avoid sending an `NSNotification` when it's changed from a
|
||||
/// background thread to avoid crashing. // TODO: Insert radar number here.
|
||||
@interface GULUserDefaults : NSObject
|
||||
|
||||
/// A shared user defaults similar to +[NSUserDefaults standardUserDefaults] and accesses the same
|
||||
/// data of the standardUserDefaults.
|
||||
+ (GULUserDefaults *)standardUserDefaults;
|
||||
|
||||
/// Initializes preferences with a suite name that is the same with the NSUserDefaults' suite name.
|
||||
/// Both of CFPreferences and NSUserDefaults share the same plist file so their data will exactly
|
||||
/// the same.
|
||||
///
|
||||
/// @param suiteName The name of the suite of the user defaults.
|
||||
- (instancetype)initWithSuiteName:(nullable NSString *)suiteName;
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
/// Searches the receiver's search list for a default with the key 'defaultName' and return it. If
|
||||
/// another process has changed defaults in the search list, NSUserDefaults will automatically
|
||||
/// update to the latest values. If the key in question has been marked as ubiquitous via a Defaults
|
||||
/// Configuration File, the latest value may not be immediately available, and the registered value
|
||||
/// will be returned instead.
|
||||
- (nullable id)objectForKey:(NSString *)defaultName;
|
||||
|
||||
/// Equivalent to -objectForKey:, except that it will return nil if the value is not an NSArray.
|
||||
- (nullable NSArray *)arrayForKey:(NSString *)defaultName;
|
||||
|
||||
/// Equivalent to -objectForKey:, except that it will return nil if the value
|
||||
/// is not an NSDictionary.
|
||||
- (nullable NSDictionary<NSString *, id> *)dictionaryForKey:(NSString *)defaultName;
|
||||
|
||||
/// Equivalent to -objectForKey:, except that it will convert NSNumber values to their NSString
|
||||
/// representation. If a non-string non-number value is found, nil will be returned.
|
||||
- (nullable NSString *)stringForKey:(NSString *)defaultName;
|
||||
|
||||
/// Equivalent to -objectForKey:, except that it converts the returned value to an NSInteger. If the
|
||||
/// value is an NSNumber, the result of -integerValue will be returned. If the value is an NSString,
|
||||
/// it will be converted to NSInteger if possible. If the value is a boolean, it will be converted
|
||||
/// to either 1 for YES or 0 for NO. If the value is absent or can't be converted to an integer, 0
|
||||
/// will be returned.
|
||||
- (NSInteger)integerForKey:(NSString *)defaultName;
|
||||
|
||||
/// Similar to -integerForKey:, except that it returns a float, and boolean values will not be
|
||||
/// converted.
|
||||
- (float)floatForKey:(NSString *)defaultName;
|
||||
|
||||
/// Similar to -integerForKey:, except that it returns a double, and boolean values will not be
|
||||
/// converted.
|
||||
- (double)doubleForKey:(NSString *)defaultName;
|
||||
|
||||
/// Equivalent to -objectForKey:, except that it converts the returned value to a BOOL. If the value
|
||||
/// is an NSNumber, NO will be returned if the value is 0, YES otherwise. If the value is an
|
||||
/// NSString, values of "YES" or "1" will return YES, and values of "NO", "0", or any other string
|
||||
/// will return NO. If the value is absent or can't be converted to a BOOL, NO will be returned.
|
||||
- (BOOL)boolForKey:(NSString *)defaultName;
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
/// Immediately stores a value (or removes the value if `nil` is passed as the value) for the
|
||||
/// provided key in the search list entry for the receiver's suite name in the current user and any
|
||||
/// host, then asynchronously stores the value persistently, where it is made available to other
|
||||
/// processes.
|
||||
- (void)setObject:(nullable id)value forKey:(NSString *)defaultName;
|
||||
|
||||
/// Equivalent to -setObject:forKey: except that the value is converted from a float to an NSNumber.
|
||||
- (void)setFloat:(float)value forKey:(NSString *)defaultName;
|
||||
|
||||
/// Equivalent to -setObject:forKey: except that the value is converted from a double to an
|
||||
/// NSNumber.
|
||||
- (void)setDouble:(double)value forKey:(NSString *)defaultName;
|
||||
|
||||
/// Equivalent to -setObject:forKey: except that the value is converted from an NSInteger to an
|
||||
/// NSNumber.
|
||||
- (void)setInteger:(NSInteger)value forKey:(NSString *)defaultName;
|
||||
|
||||
/// Equivalent to -setObject:forKey: except that the value is converted from a BOOL to an NSNumber.
|
||||
- (void)setBool:(BOOL)value forKey:(NSString *)defaultName;
|
||||
|
||||
#pragma mark - Removing Defaults
|
||||
|
||||
/// Equivalent to -[... setObject:nil forKey:defaultName]
|
||||
- (void)removeObjectForKey:(NSString *)defaultName;
|
||||
|
||||
#pragma mark - Save data
|
||||
|
||||
/// Blocks the calling thread until all in-progress set operations have completed.
|
||||
- (void)synchronize;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#else
|
||||
#ifndef FOUNDATION_EXPORT
|
||||
#if defined(__cplusplus)
|
||||
#define FOUNDATION_EXPORT extern "C"
|
||||
#else
|
||||
#define FOUNDATION_EXPORT extern
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#import "GULAppDelegateSwizzler.h"
|
||||
#import "GULApplication.h"
|
||||
#import "GULSceneDelegateSwizzler.h"
|
||||
#import "GULAppEnvironmentUtil.h"
|
||||
#import "GULHeartbeatDateStorable.h"
|
||||
#import "GULHeartbeatDateStorage.h"
|
||||
#import "GULHeartbeatDateStorageUserDefaults.h"
|
||||
#import "GULKeychainStorage.h"
|
||||
#import "GULKeychainUtils.h"
|
||||
#import "GULNetworkInfo.h"
|
||||
#import "GULSecureCoding.h"
|
||||
#import "GULURLSessionDataResponse.h"
|
||||
#import "NSURLSession+GULPromises.h"
|
||||
#import "GULObjectSwizzler.h"
|
||||
#import "GULSwizzledObject.h"
|
||||
#import "GULLogger.h"
|
||||
#import "GULLoggerLevel.h"
|
||||
#import "GULOriginalIMPConvenienceMacros.h"
|
||||
#import "GULSwizzler.h"
|
||||
#import "GULNSData+zlib.h"
|
||||
#import "GULMutableDictionary.h"
|
||||
#import "GULNetwork.h"
|
||||
#import "GULNetworkConstants.h"
|
||||
#import "GULNetworkLoggerProtocol.h"
|
||||
#import "GULNetworkMessageCode.h"
|
||||
#import "GULNetworkURLSession.h"
|
||||
#import "GULReachabilityChecker.h"
|
||||
#import "GULUserDefaults.h"
|
||||
|
||||
FOUNDATION_EXPORT double GoogleUtilitiesVersionNumber;
|
||||
FOUNDATION_EXPORT const unsigned char GoogleUtilitiesVersionString[];
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class FBLPromise<Value>;
|
||||
@class GULURLSessionDataResponse;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** Promise based API for `NSURLSession`. */
|
||||
@interface NSURLSession (GULPromises)
|
||||
|
||||
/** Creates a promise wrapping `-[NSURLSession dataTaskWithRequest:completionHandler:]` method.
|
||||
* @param URLRequest The request to create a data task with.
|
||||
* @return A promise that is fulfilled when an HTTP response is received (with any response code),
|
||||
* or is rejected with the error passed to the task completion.
|
||||
*/
|
||||
- (FBLPromise<GULURLSessionDataResponse *> *)gul_dataTaskPromiseWithRequest:
|
||||
(NSURLRequest *)URLRequest;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>23F79</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>GoogleUtilities</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.cocoapods.GoogleUtilities</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>GoogleUtilities</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>7.13.3</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>iPhoneOS</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>21C52</string>
|
||||
<key>DTPlatformName</key>
|
||||
<string>iphoneos</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>17.2</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>21C52</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>iphoneos17.2</string>
|
||||
<key>DTXcode</key>
|
||||
<string>1520</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>15C500b</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>100.0</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,8 @@
|
||||
framework module GoogleUtilities {
|
||||
umbrella header "GoogleUtilities-umbrella.h"
|
||||
export *
|
||||
module * { export * }
|
||||
link framework "Security"
|
||||
link framework "SystemConfiguration"
|
||||
link "z"
|
||||
}
|
||||
Reference in New Issue
Block a user