修改pods

This commit is contained in:
2025-09-20 17:13:38 +08:00
parent 7787b3ee30
commit 28ff2b0264
5251 changed files with 345029 additions and 285168 deletions

View File

@@ -14,6 +14,9 @@
* limitations under the License.
*/
#ifndef FIREBASECORE_FIRAPPINTERNAL_H
#define FIREBASECORE_FIRAPPINTERNAL_H
#import <FirebaseCore/FIRApp.h>
@class FIRComponentContainer;
@@ -40,8 +43,26 @@ extern NSString *const kFIRAppNameKey;
extern NSString *const kFIRGoogleAppIDKey;
extern NSString *const kFirebaseCoreErrorDomain;
/** The `UserDefaults` suite name for `FirebaseCore`, for those storage locations that use it. */
extern NSString *const kFirebaseCoreDefaultsSuiteName;
/**
* Keys for the strings in the plist file.
*/
extern NSString *const kFIRAPIKey;
extern NSString *const kFIRTrackingID;
extern NSString *const kFIRGoogleAppID;
extern NSString *const kFIRClientID;
extern NSString *const kFIRGCMSenderID;
extern NSString *const kFIRAndroidClientID;
extern NSString *const kFIRDatabaseURL;
extern NSString *const kFIRStorageBucket;
extern NSString *const kFIRBundleID;
extern NSString *const kFIRProjectID;
/**
* Keys for the plist file name
*/
extern NSString *const kServiceInfoFileName;
extern NSString *const kServiceInfoFileType;
/**
* The format string for the `UserDefaults` key used for storing the data collection enabled flag.
@@ -157,3 +178,5 @@ extern NSString *const FIRAuthStateDidChangeInternalNotificationUIDKey;
@end
NS_ASSUME_NONNULL_END
#endif // FIREBASECORE_FIRAPPINTERNAL_H

View File

@@ -14,6 +14,9 @@
* limitations under the License.
*/
#ifndef FIREBASECORE_FIRCOMPONENT_H
#define FIREBASECORE_FIRCOMPONENT_H
#import <Foundation/Foundation.h>
@class FIRApp;
@@ -32,8 +35,6 @@ typedef _Nullable id (^FIRComponentCreationBlock)(FIRComponentContainer *contain
BOOL *isCacheable)
NS_SWIFT_NAME(ComponentCreationBlock);
@class FIRDependency;
/// Describes the timing of instantiation. Note: new components should default to lazy unless there
/// is a strong reason to be eager.
typedef NS_ENUM(NSInteger, FIRInstantiationTiming) {
@@ -52,9 +53,6 @@ NS_SWIFT_NAME(Component)
/// The timing of instantiation.
@property(nonatomic, readonly) FIRInstantiationTiming instantiationTiming;
/// An array of dependencies for the component.
@property(nonatomic, copy, readonly) NSArray<FIRDependency *> *dependencies;
/// A block to instantiate an instance of the component with the appropriate dependencies.
@property(nonatomic, copy, readonly) FIRComponentCreationBlock creationBlock;
@@ -72,14 +70,12 @@ NS_SWIFT_NAME(init(_:creationBlock:));
/// @param protocol - The protocol describing functionality provided by the component.
/// @param instantiationTiming - When the component should be initialized. Use .lazy unless there's
/// a good reason to be instantiated earlier.
/// @param dependencies - Any dependencies the `implementingClass` has, optional or required.
/// @param creationBlock - A block to instantiate the component with a container, and if
/// @return A component that can be registered with the component container.
+ (instancetype)componentWithProtocol:(Protocol *)protocol
instantiationTiming:(FIRInstantiationTiming)instantiationTiming
dependencies:(NSArray<FIRDependency *> *)dependencies
creationBlock:(FIRComponentCreationBlock)creationBlock
NS_SWIFT_NAME(init(_:instantiationTiming:dependencies:creationBlock:));
NS_SWIFT_NAME(init(_:instantiationTiming:creationBlock:));
// clang-format on
@@ -89,3 +85,5 @@ NS_SWIFT_NAME(init(_:instantiationTiming:dependencies:creationBlock:));
@end
NS_ASSUME_NONNULL_END
#endif // FIREBASECORE_FIRCOMPONENT_H

View File

@@ -13,6 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FIREBASECORE_FIRCOMPONENTCONTAINER_H
#define FIREBASECORE_FIRCOMPONENTCONTAINER_H
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@@ -43,3 +47,5 @@ NS_SWIFT_NAME(FirebaseComponentContainer)
@end
NS_ASSUME_NONNULL_END
#endif // FIREBASECORE_FIRCOMPONENTCONTAINER_H

View File

@@ -14,6 +14,9 @@
* limitations under the License.
*/
#ifndef FIREBASECORE_FIRCOMPONENTTYPE_H
#define FIREBASECORE_FIRCOMPONENTTYPE_H
#import <Foundation/Foundation.h>
@class FIRComponentContainer;
@@ -33,3 +36,5 @@ NS_SWIFT_NAME(ComponentType)
@end
NS_ASSUME_NONNULL_END
#endif // FIREBASECORE_FIRCOMPONENTTYPE_H

View File

@@ -1,45 +0,0 @@
/*
* 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 dependency on a specific protocol's functionality.
NS_SWIFT_NAME(Dependency)
@interface FIRDependency : NSObject
/// The protocol describing functionality being depended on.
@property(nonatomic, strong, readonly) Protocol *protocol;
/// A flag to specify if the dependency is required or not.
@property(nonatomic, readonly) BOOL isRequired;
/// Initializes a dependency that is required. Calls `init(protocol:isRequired:)` with true for
/// the required parameter.
/// Creates a required dependency on the specified protocol's functionality.
+ (instancetype)dependencyWithProtocol:(Protocol *)protocol;
/// Creates a dependency on the specified protocol's functionality and specify if it's required for
/// the class's functionality.
+ (instancetype)dependencyWithProtocol:(Protocol *)protocol isRequired:(BOOL)required;
/// Use `init(withProtocol:isRequired:)` instead.
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END

View File

@@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef FIREBASECORE_FIRHEARTBEATLOGGER_H
#define FIREBASECORE_FIRHEARTBEATLOGGER_H
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@@ -30,19 +33,24 @@ typedef NS_ENUM(NSInteger, FIRDailyHeartbeatCode) {
FIRDailyHeartbeatCodeSome = 2,
};
NS_SWIFT_SENDABLE
@protocol FIRHeartbeatLoggerProtocol <NSObject>
/// Asynchronously logs a heartbeat.
- (void)log;
#ifndef FIREBASE_BUILD_CMAKE
/// Flushes heartbeats from storage into a structured payload of heartbeats.
- (FIRHeartbeatsPayload *)flushHeartbeatsIntoPayload;
#endif // FIREBASE_BUILD_CMAKE
/// Gets the heartbeat code for today.
- (FIRDailyHeartbeatCode)heartbeatCodeForToday;
#ifndef FIREBASE_BUILD_CMAKE
/// Returns the header value for the heartbeat logger via the given completion handler..
- (void)asyncHeaderValueWithCompletionHandler:(void (^)(NSString *_Nullable))completionHandler
API_AVAILABLE(ios(13.0), macosx(10.15), macCatalyst(13.0), tvos(13.0), watchos(6.0));
/// Return the header value for the heartbeat logger.
- (NSString *_Nullable)headerValue;
#endif // FIREBASE_BUILD_CMAKE
@end
#ifndef FIREBASE_BUILD_CMAKE
@@ -68,13 +76,23 @@ NSString *_Nullable FIRHeaderValueFromHeartbeatsPayload(FIRHeartbeatsPayload *he
- (void)log;
#ifndef FIREBASE_BUILD_CMAKE
/// Flushes heartbeats from storage into a structured payload of heartbeats.
/// Synchronously flushes heartbeats from storage into a structured payload of heartbeats.
///
/// This API is for clients using platform logging V2.
///
/// @note This API is thread-safe.
/// @return A payload of heartbeats.
- (FIRHeartbeatsPayload *)flushHeartbeatsIntoPayload;
/// Asynchronously flushes heartbeats from storage into a structured payload of heartbeats.
///
/// This API is for clients using platform logging V2.
///
/// @note This API is thread-safe.
/// @param completionHandler A completion handler to process the flushed payload of heartbeats.
- (void)flushHeartbeatsIntoPayloadWithCompletionHandler:
(void (^)(FIRHeartbeatsPayload *))completionHandler
API_AVAILABLE(ios(13.0), macosx(10.15), macCatalyst(13.0), tvos(13.0), watchos(6.0));
#endif // FIREBASE_BUILD_CMAKE
/// Gets today's corresponding heartbeat code.
@@ -88,3 +106,5 @@ NSString *_Nullable FIRHeaderValueFromHeartbeatsPayload(FIRHeartbeatsPayload *he
@end
NS_ASSUME_NONNULL_END
#endif // FIREBASECORE_FIRHEARTBEATLOGGER_H

View File

@@ -14,6 +14,9 @@
* limitations under the License.
*/
#ifndef FIREBASECORE_FIRLIBRARY_H
#define FIREBASECORE_FIRLIBRARY_H
#ifndef FIRLibrary_h
#define FIRLibrary_h
@@ -32,13 +35,10 @@ NS_SWIFT_NAME(Library)
/// FirebaseApp and participate in dependency resolution and injection.
+ (NSArray<FIRComponent *> *)componentsToRegister;
@optional
/// Implement this method if the library needs notifications for lifecycle events. This method is
/// called when the developer calls `FirebaseApp.configure()`.
+ (void)configureWithApp:(FIRApp *)app;
@end
NS_ASSUME_NONNULL_END
#endif /* FIRLibrary_h */
#endif // FIREBASECORE_FIRLIBRARY_H

View File

@@ -14,9 +14,12 @@
* limitations under the License.
*/
#ifndef FIREBASECORE_FIRLOGGER_H
#define FIREBASECORE_FIRLOGGER_H
#import <Foundation/Foundation.h>
#import <FirebaseCore/FIRLoggerLevel.h>
typedef NS_ENUM(NSInteger, FIRLoggerLevel);
NS_ASSUME_NONNULL_BEGIN
@@ -25,10 +28,10 @@ NS_ASSUME_NONNULL_BEGIN
*/
typedef NSString *const FIRLoggerService;
extern FIRLoggerService kFIRLoggerAnalytics;
extern FIRLoggerService kFIRLoggerCrash;
extern FIRLoggerService kFIRLoggerCore;
extern FIRLoggerService kFIRLoggerRemoteConfig;
extern NSString *const kFIRLoggerAnalytics;
extern NSString *const kFIRLoggerCrash;
extern NSString *const kFIRLoggerCore;
extern NSString *const kFIRLoggerRemoteConfig;
/**
* The key used to store the logger's error count.
@@ -64,6 +67,11 @@ FIRLoggerLevel FIRGetLoggerLevel(void);
*/
void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel);
void FIRSetLoggerLevelNotice(void);
void FIRSetLoggerLevelWarning(void);
void FIRSetLoggerLevelError(void);
void FIRSetLoggerLevelDebug(void);
/**
* Checks if the specified logger level is loggable given the current settings.
* (required) log level (one of the FirebaseLoggerLevel enum values).
@@ -71,6 +79,11 @@ void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel);
*/
BOOL FIRIsLoggableLevel(FIRLoggerLevel loggerLevel, BOOL analyticsComponent);
BOOL FIRIsLoggableLevelNotice(void);
BOOL FIRIsLoggableLevelWarning(void);
BOOL FIRIsLoggableLevelError(void);
BOOL FIRIsLoggableLevelDebug(void);
/**
* 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 FirebaseLoggerLevelNotice to avoid log spamming.
@@ -85,7 +98,7 @@ BOOL FIRIsLoggableLevel(FIRLoggerLevel loggerLevel, BOOL analyticsComponent);
* string.
*/
extern void FIRLogBasic(FIRLoggerLevel level,
FIRLoggerService service,
NSString *category,
NSString *messageCode,
NSString *message,
// On 64-bit simulators, va_list is not a pointer, so cannot be marked nullable
@@ -110,43 +123,51 @@ extern void FIRLogBasic(FIRLoggerLevel level,
* Example usage:
* FirebaseLogError(kFirebaseLoggerCore, @"I-COR000001", @"Configuration of %@ failed.", app.name);
*/
extern void FIRLogError(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
extern void FIRLogError(NSString *category, NSString *messageCode, NSString *message, ...)
NS_FORMAT_FUNCTION(3, 4);
extern void FIRLogWarning(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
extern void FIRLogWarning(NSString *category, NSString *messageCode, NSString *message, ...)
NS_FORMAT_FUNCTION(3, 4);
extern void FIRLogNotice(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
extern void FIRLogNotice(NSString *category, NSString *messageCode, NSString *message, ...)
NS_FORMAT_FUNCTION(3, 4);
extern void FIRLogInfo(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
extern void FIRLogInfo(NSString *category, NSString *messageCode, NSString *message, ...)
NS_FORMAT_FUNCTION(3, 4);
extern void FIRLogDebug(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
extern void FIRLogDebug(NSString *category, NSString *messageCode, NSString *message, ...)
NS_FORMAT_FUNCTION(3, 4);
// TODO: Come up with a better logging scheme for Swift.
/**
* Logs a debug message to the Xcode console and the device log. If running from AppStore, will
* not log any messages with a level higher than FirebaseLoggerLevelNotice to avoid log spamming.
* This function is intended to be used by Swift clients that do not support variadic parameters.
* This function is similar to the one above, except it takes a `va_list` instead of the listed
* variables.
*
* @param service The service name of type `FirebaseLoggerService`.
* @param messageCode The mesage 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".
* @param message The message string.
*/
extern void FIRLogDebugSwift(FIRLoggerService service, NSString *messageCode, NSString *message);
/**
* Logs a warning message to the Xcode console and the device log. If running from AppStore, will
* not log any messages with a level higher than FirebaseLoggerLevelNotice to avoid log spamming.
* This function is intended to be used by Swift clients that do not support variadic parameters.
* The following functions accept the following parameters in order: (required) service
* name of type FirebaseLoggerService.
*
* @param service The service name of type `FirebaseLoggerService`.
* @param messageCode The mesage 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".
* @param message The message string.
* (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) A va_list
*/
extern void FIRLogWarningSwift(FIRLoggerService service, NSString *messageCode, NSString *message);
extern void FIRLogBasicError(NSString *category,
NSString *messageCode,
NSString *message,
va_list args_ptr);
extern void FIRLogBasicWarning(NSString *category,
NSString *messageCode,
NSString *message,
va_list args_ptr);
extern void FIRLogBasicNotice(NSString *category,
NSString *messageCode,
NSString *message,
va_list args_ptr);
extern void FIRLogBasicInfo(NSString *category,
NSString *messageCode,
NSString *message,
va_list args_ptr);
extern void FIRLogBasicDebug(NSString *category,
NSString *messageCode,
NSString *message,
va_list args_ptr);
#ifdef __cplusplus
} // extern "C"
@@ -155,35 +176,17 @@ extern void FIRLogWarningSwift(FIRLoggerService service, NSString *messageCode,
NS_SWIFT_NAME(FirebaseLogger)
@interface FIRLoggerWrapper : NSObject
/// Logs a given message at a given log level. This API is effectively a wrapper for the
/// `FIRLogBasic` C API.
///
/// - Parameters:
/// - level: The log level to use (defined by `FirebaseLoggerLevel` enum values).
/// - service: The service name of type `FirebaseLoggerService`.
/// - code: The mesage 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".
/// - message: Formatted string to be used as the log's message.
/// - args: Arguments list obtained from calling `va_start`, used when message is a format string.
+ (void)logWithLevel:(FIRLoggerLevel)level
withService:(FIRLoggerService)service
withCode:(NSString *)messageCode
withMessage:(NSString *)message
withArgs:(va_list)args;
/// Logs a given message at a given log level.
///
/// - Parameters:
/// - level: The log level to use (defined by `FirebaseLoggerLevel` enum values).
/// - service: The service name of type `FirebaseLoggerService`.
/// - code: The mesage code. Starting with "I-" which means iOS, followed by a capitalized
/// - category: The service name of type `FirebaseLoggerService`.
/// - code: The 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".
/// - message: Formatted string to be used as the log's message.
/// - args: Arguments list obtained from calling `va_start`, used when message is a format string.
+ (void)logWithLevel:(FIRLoggerLevel)level
service:(FIRLoggerService)service
service:(NSString *)category
code:(NSString *)code
message:(NSString *)message
__attribute__((__swift_name__("log(level:service:code:message:)")));
@@ -191,3 +194,5 @@ NS_SWIFT_NAME(FirebaseLogger)
@end
NS_ASSUME_NONNULL_END
#endif // FIREBASECORE_FIRLOGGER_H

View File

@@ -12,14 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef FIREBASECORE_FIREBASECOREINTERNAL_H
#define FIREBASECORE_FIREBASECOREINTERNAL_H
@import FirebaseCore;
#import "FIRAppInternal.h"
#import "FIRComponent.h"
#import "FIRComponentContainer.h"
#import "FIRComponentType.h"
#import "FIRDependency.h"
#import "FIRHeartbeatLogger.h"
#import "FIRLibrary.h"
#import "FIRLogger.h"
#import "FIROptionsInternal.h"
#endif // FIREBASECORE_FIREBASECOREINTERNAL_H

View File

@@ -38,7 +38,8 @@
#import "FirebaseCore/Extension/FIRHeartbeatLogger.h"
#import "FirebaseCore/Extension/FIRLibrary.h"
#import "FirebaseCore/Extension/FIRLogger.h"
#import "FirebaseCore/Extension/FIROptionsInternal.h"
#import "FirebaseCore/Sources/FIROptionsInternal.h"
#import "FirebaseCore/Sources/Public/FirebaseCore/FIROptions.h"
#import "FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h"
#import <GoogleUtilities/GULAppEnvironmentUtil.h>
@@ -79,20 +80,11 @@ NSString *const FIRAuthStateDidChangeInternalNotificationUIDKey =
*/
NSString *const kFirebaseCoreErrorDomain = @"com.firebase.core";
/** The NSUserDefaults suite name for FirebaseCore, for those storage locations that use it. */
NSString *const kFirebaseCoreDefaultsSuiteName = @"com.firebase.core";
/**
* The URL to download plist files.
*/
static NSString *const kPlistURL = @"https://console.firebase.google.com/";
/**
* An array of all classes that registered as `FIRCoreConfigurable` in order to receive lifecycle
* events from Core.
*/
static NSMutableArray<Class<FIRLibrary>> *sRegisteredAsConfigurable;
@interface FIRApp ()
#ifdef DEBUG
@@ -241,7 +233,8 @@ static FIRApp *sDefaultApp;
@"application initialization. This can be done in "
@"in the App Delegate's application(_:didFinishLaunchingWithOptions:)` "
@"(or the `@main` struct's initializer in SwiftUI). "
@"Read more: https://goo.gl/ctyzm8.");
@"Read more: "
@"https://firebase.google.com/docs/ios/setup#initialize_firebase_in_your_app");
return nil;
}
@@ -453,14 +446,6 @@ static FIRApp *sDefaultApp;
[[NSNotificationCenter defaultCenter] postNotificationName:kFIRAppReadyToConfigureSDKNotification
object:self
userInfo:appInfoDict];
// This is the new way of sending information to SDKs.
// TODO: Do we want this on a background thread, maybe?
@synchronized(self) {
for (Class<FIRLibrary> library in sRegisteredAsConfigurable) {
[library configureWithApp:app];
}
}
}
+ (NSError *)errorForMissingOptions {
@@ -525,15 +510,6 @@ static FIRApp *sDefaultApp;
}
[FIRComponentContainer registerAsComponentRegistrant:library];
if ([(Class)library respondsToSelector:@selector(configureWithApp:)]) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sRegisteredAsConfigurable = [[NSMutableArray alloc] init];
});
@synchronized(self) {
[sRegisteredAsConfigurable addObject:library];
}
}
[self registerLibrary:name withVersion:version];
}
@@ -651,7 +627,7 @@ static FIRApp *sDefaultApp;
*
* @param appID Contents of GOOGLE_APP_ID from the plist file.
* @param version Indicates what version of the app id format this string should be.
* @return YES if provided string fufills the expected format, NO otherwise.
* @return YES if provided string fulfills the expected format, NO otherwise.
*/
+ (BOOL)validateAppIDFormat:(NSString *)appID withVersion:(NSString *)version {
if (!appID.length || !version.length) {
@@ -733,8 +709,8 @@ static FIRApp *sDefaultApp;
*
* @param appID Contents of GOOGLE_APP_ID from the plist file.
* @param version Indicates what version of the app id format this string should be.
* @return YES if provided string fufills the expected hashed bundle ID and the version is known, NO
* otherwise.
* @return YES if provided string fulfills the expected hashed bundle ID and the version is known,
* NO otherwise.
*/
+ (BOOL)validateBundleIDHashWithinAppID:(NSString *)appID forVersion:(NSString *)version {
// Extract the hashed bundle ID from the given app ID.
@@ -825,10 +801,10 @@ static FIRApp *sDefaultApp;
SEL componentsToRegisterSEL = @selector(componentsToRegister);
// Dictionary of class names that conform to `FIRLibrary` and their user agents. These should only
// be SDKs that are written in Swift but still visible to ObjC.
// This is only necessary for products that need to do work at launch during configuration.
NSDictionary<NSString *, NSString *> *swiftComponents = @{
@"FIRSessions" : @"fire-ses",
@"FIRFunctionsComponent" : @"fire-fun",
@"FIRStorageComponent" : @"fire-str",
@"FIRAuthComponent" : @"fire-auth",
};
for (NSString *className in swiftComponents.allKeys) {
Class klass = NSClassFromString(className);
@@ -843,11 +819,27 @@ static FIRApp *sDefaultApp;
@"FIRCombineFirestoreLibrary" : @"comb-firestore",
@"FIRCombineFunctionsLibrary" : @"comb-functions",
@"FIRCombineStorageLibrary" : @"comb-storage",
@"FIRFunctions" : @"fire-fun",
@"FIRStorage" : @"fire-str",
@"FIRVertexAIComponent" : @"fire-vertex",
@"FIRDataConnectComponent" : @"fire-dc",
};
for (NSString *className in swiftLibraries.allKeys) {
Class klass = NSClassFromString(className);
if (klass) {
[FIRApp registerLibrary:swiftLibraries[className] withVersion:FIRFirebaseVersion()];
NSString *version = FIRFirebaseVersion();
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
SEL sdkVersionSelector = @selector(sdkVersion);
#pragma clang diagnostic pop
if ([klass respondsToSelector:sdkVersionSelector]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
NSString *sdkVersion = (NSString *)[klass performSelector:sdkVersionSelector];
if (sdkVersion) version = sdkVersion;
#pragma clang diagnostic pop
}
[FIRApp registerLibrary:swiftLibraries[className] withVersion:version];
}
}
}
@@ -855,7 +847,7 @@ static FIRApp *sDefaultApp;
#pragma mark - App Life Cycle
- (void)subscribeForAppDidBecomeActiveNotifications {
#if TARGET_OS_IOS || TARGET_OS_TV || (defined(TARGET_OS_VISION) && TARGET_OS_VISION)
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION
NSNotificationName notificationName = UIApplicationDidBecomeActiveNotification;
#elif TARGET_OS_OSX
NSNotificationName notificationName = NSApplicationDidBecomeActiveNotification;

View File

@@ -17,13 +17,11 @@
#import "FirebaseCore/Extension/FIRComponent.h"
#import "FirebaseCore/Extension/FIRComponentContainer.h"
#import "FirebaseCore/Extension/FIRDependency.h"
@interface FIRComponent ()
- (instancetype)initWithProtocol:(Protocol *)protocol
instantiationTiming:(FIRInstantiationTiming)instantiationTiming
dependencies:(NSArray<FIRDependency *> *)dependencies
creationBlock:(FIRComponentCreationBlock)creationBlock;
@end
@@ -34,29 +32,24 @@
creationBlock:(FIRComponentCreationBlock)creationBlock {
return [[FIRComponent alloc] initWithProtocol:protocol
instantiationTiming:FIRInstantiationTimingLazy
dependencies:@[]
creationBlock:creationBlock];
}
+ (instancetype)componentWithProtocol:(Protocol *)protocol
instantiationTiming:(FIRInstantiationTiming)instantiationTiming
dependencies:(NSArray<FIRDependency *> *)dependencies
creationBlock:(FIRComponentCreationBlock)creationBlock {
return [[FIRComponent alloc] initWithProtocol:protocol
instantiationTiming:instantiationTiming
dependencies:dependencies
creationBlock:creationBlock];
}
- (instancetype)initWithProtocol:(Protocol *)protocol
instantiationTiming:(FIRInstantiationTiming)instantiationTiming
dependencies:(NSArray<FIRDependency *> *)dependencies
creationBlock:(FIRComponentCreationBlock)creationBlock {
self = [super init];
if (self) {
_protocol = protocol;
_instantiationTiming = instantiationTiming;
_dependencies = [dependencies copy];
_creationBlock = creationBlock;
}
return self;

View File

@@ -20,7 +20,8 @@
#import "FirebaseCore/Extension/FIRComponent.h"
#import "FirebaseCore/Extension/FIRLibrary.h"
#import "FirebaseCore/Extension/FIRLogger.h"
#import "FirebaseCore/Extension/FIROptionsInternal.h"
#import "FirebaseCore/Sources/FIROptionsInternal.h"
#import "FirebaseCore/Sources/Public/FirebaseCore/FIROptions.h"
NS_ASSUME_NONNULL_BEGIN
@@ -148,7 +149,7 @@ static NSMutableSet<Class> *sFIRComponentRegistrants;
/// - Validate that the instance returned conforms to the protocol it claims to,
/// - Cache the instance if the block requests it
///
/// Note that this method assumes the caller already has @sychronized on self.
/// Note that this method assumes the caller already has @synchronized on self.
- (nullable id)instantiateInstanceForProtocol:(Protocol *)protocol
withBlock:(FIRComponentCreationBlock)creationBlock {
if (!creationBlock) {

View File

@@ -17,6 +17,7 @@
#import "FirebaseCore/Sources/FIRAnalyticsConfiguration.h"
extern void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel);
extern FIRLoggerLevel FIRGetLoggerLevel(void);
@implementation FIRConfiguration
@@ -40,7 +41,15 @@ extern void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel);
- (void)setLoggerLevel:(FIRLoggerLevel)loggerLevel {
NSAssert(loggerLevel <= FIRLoggerLevelMax && loggerLevel >= FIRLoggerLevelMin,
@"Invalid logger level, %ld", (long)loggerLevel);
FIRSetLoggerLevel(loggerLevel);
@synchronized(self) {
FIRSetLoggerLevel(loggerLevel);
}
}
- (FIRLoggerLevel)loggerLevel {
@synchronized(self) {
return FIRGetLoggerLevel();
}
}
@end

View File

@@ -1,44 +0,0 @@
/*
* 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 "FirebaseCore/Extension/FIRDependency.h"
@interface FIRDependency ()
- (instancetype)initWithProtocol:(Protocol *)protocol isRequired:(BOOL)required;
@end
@implementation FIRDependency
+ (instancetype)dependencyWithProtocol:(Protocol *)protocol {
return [[self alloc] initWithProtocol:protocol isRequired:YES];
}
+ (instancetype)dependencyWithProtocol:(Protocol *)protocol isRequired:(BOOL)required {
return [[self alloc] initWithProtocol:protocol isRequired:required];
}
- (instancetype)initWithProtocol:(Protocol *)protocol isRequired:(BOOL)required {
self = [super init];
if (self) {
_protocol = protocol;
_isRequired = required;
}
return self;
}
@end

View File

@@ -70,10 +70,29 @@ NSString *_Nullable FIRHeaderValueFromHeartbeatsPayload(FIRHeartbeatsPayload *he
}
#ifndef FIREBASE_BUILD_CMAKE
- (NSString *_Nullable)headerValue {
return FIRHeaderValueFromHeartbeatsPayload([self flushHeartbeatsIntoPayload]);
}
- (void)asyncHeaderValueWithCompletionHandler:(void (^)(NSString *_Nullable))completionHandler
API_AVAILABLE(ios(13.0), macosx(10.15), macCatalyst(13.0), tvos(13.0), watchos(6.0)) {
[self flushHeartbeatsIntoPayloadWithCompletionHandler:^(FIRHeartbeatsPayload *payload) {
completionHandler(FIRHeaderValueFromHeartbeatsPayload(payload));
}];
}
- (FIRHeartbeatsPayload *)flushHeartbeatsIntoPayload {
FIRHeartbeatsPayload *payload = [_heartbeatController flush];
return payload;
}
- (void)flushHeartbeatsIntoPayloadWithCompletionHandler:
(void (^)(FIRHeartbeatsPayload *))completionHandler
API_AVAILABLE(ios(13.0), macosx(10.15), macCatalyst(13.0), tvos(13.0), watchos(6.0)) {
[_heartbeatController flushAsyncWithCompletionHandler:^(FIRHeartbeatsPayload *payload) {
completionHandler(payload);
}];
}
#endif // FIREBASE_BUILD_CMAKE
- (FIRDailyHeartbeatCode)heartbeatCodeForToday {

View File

@@ -20,17 +20,18 @@
#import "FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h"
FIRLoggerService kFIRLoggerCore = @"[FirebaseCore]";
NSString *const kFIRLoggerSubsystem = @"com.google.firebase";
NSString *const kFIRLoggerCore = @"[FirebaseCore]";
// All the FIRLoggerService definitions should be migrated to clients. Do not add new ones!
FIRLoggerService kFIRLoggerAnalytics = @"[FirebaseAnalytics]";
FIRLoggerService kFIRLoggerCrash = @"[FirebaseCrash]";
FIRLoggerService kFIRLoggerRemoteConfig = @"[FirebaseRemoteConfig]";
NSString *const kFIRLoggerAnalytics = @"[FirebaseAnalytics]";
NSString *const kFIRLoggerCrash = @"[FirebaseCrash]";
NSString *const kFIRLoggerRemoteConfig = @"[FirebaseRemoteConfig]";
/// Arguments passed on launch.
NSString *const kFIRDisableDebugModeApplicationArgument = @"-FIRDebugDisabled";
NSString *const kFIREnableDebugModeApplicationArgument = @"-FIRDebugEnabled";
NSString *const kFIRLoggerForceSDTERRApplicationArgument = @"-FIRLoggerForceSTDERR";
/// Key for the debug mode bit in NSUserDefaults.
NSString *const kFIRPersistedDebugModeKey = @"/google/firebase/debug_mode";
@@ -53,14 +54,12 @@ static NSString *const kMessageCodePattern = @"^I-[A-Z]{3}[0-9]{6}$";
static NSRegularExpression *sMessageCodeRegex;
#endif
void FIRLoggerInitializeASL(void) {
void FIRLoggerInitialize(void) {
dispatch_once(&sFIRLoggerOnceToken, ^{
// Register Firebase Version with GULLogger.
GULLoggerRegisterVersion(FIRFirebaseVersion());
// Override the aslOptions to ASL_OPT_STDERR if the override argument is passed in.
NSArray *arguments = [NSProcessInfo processInfo].arguments;
BOOL overrideSTDERR = [arguments containsObject:kFIRLoggerForceSDTERRApplicationArgument];
// Use the standard NSUserDefaults if it hasn't been explicitly set.
if (sFIRLoggerUserDefaults == nil) {
@@ -76,10 +75,7 @@ void FIRLoggerInitializeASL(void) {
[sFIRLoggerUserDefaults setBool:YES forKey:kFIRPersistedDebugModeKey];
forceDebugMode = YES;
}
GULLoggerInitializeASL();
if (overrideSTDERR) {
GULLoggerEnableSTDERR();
}
GULLoggerInitialize();
if (forceDebugMode) {
GULLoggerForceDebug();
}
@@ -91,14 +87,35 @@ __attribute__((no_sanitize("thread"))) void FIRSetAnalyticsDebugMode(BOOL analyt
}
FIRLoggerLevel FIRGetLoggerLevel(void) {
FIRLoggerInitialize();
return (FIRLoggerLevel)GULGetLoggerLevel();
}
void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel) {
FIRLoggerInitializeASL();
FIRLoggerInitialize();
GULSetLoggerLevel((GULLoggerLevel)loggerLevel);
}
void FIRSetLoggerLevelNotice(void) {
FIRLoggerInitialize();
GULSetLoggerLevel(GULLoggerLevelNotice);
}
void FIRSetLoggerLevelWarning(void) {
FIRLoggerInitialize();
GULSetLoggerLevel(GULLoggerLevelWarning);
}
void FIRSetLoggerLevelError(void) {
FIRLoggerInitialize();
GULSetLoggerLevel(GULLoggerLevelError);
}
void FIRSetLoggerLevelDebug(void) {
FIRLoggerInitialize();
GULSetLoggerLevel(GULLoggerLevelDebug);
}
#ifdef DEBUG
void FIRResetLogger(void) {
extern void GULResetLogger(void);
@@ -121,24 +138,52 @@ void FIRSetLoggerUserDefaults(NSUserDefaults *defaults) {
*/
__attribute__((no_sanitize("thread"))) BOOL FIRIsLoggableLevel(FIRLoggerLevel loggerLevel,
BOOL analyticsComponent) {
FIRLoggerInitializeASL();
FIRLoggerInitialize();
if (sFIRAnalyticsDebugMode && analyticsComponent) {
return YES;
}
return GULIsLoggableLevel((GULLoggerLevel)loggerLevel);
}
BOOL FIRIsLoggableLevelNotice(void) {
return FIRIsLoggableLevel(FIRLoggerLevelNotice, NO);
}
BOOL FIRIsLoggableLevelWarning(void) {
return FIRIsLoggableLevel(FIRLoggerLevelWarning, NO);
}
BOOL FIRIsLoggableLevelError(void) {
return FIRIsLoggableLevel(FIRLoggerLevelError, NO);
}
BOOL FIRIsLoggableLevelDebug(void) {
return FIRIsLoggableLevel(FIRLoggerLevelDebug, NO);
}
void FIRLogBasic(FIRLoggerLevel level,
FIRLoggerService service,
NSString *category,
NSString *messageCode,
NSString *message,
va_list args_ptr) {
FIRLoggerInitializeASL();
GULLogBasic((GULLoggerLevel)level, service,
sFIRAnalyticsDebugMode && [kFIRLoggerAnalytics isEqualToString:service], messageCode,
message, args_ptr);
FIRLoggerInitialize();
GULOSLogBasic((GULLoggerLevel)level, kFIRLoggerSubsystem, category,
sFIRAnalyticsDebugMode && [kFIRLoggerAnalytics isEqualToString:category],
messageCode, message, args_ptr);
}
#define FIR_LOGGING_FUNCTION_BASIC(level) \
void FIRLogBasic##level(NSString *category, NSString *messageCode, NSString *message, \
va_list args_ptr) { \
FIRLogBasic(FIRLoggerLevel##level, category, messageCode, message, args_ptr); \
}
FIR_LOGGING_FUNCTION_BASIC(Error)
FIR_LOGGING_FUNCTION_BASIC(Warning)
FIR_LOGGING_FUNCTION_BASIC(Notice)
FIR_LOGGING_FUNCTION_BASIC(Info)
FIR_LOGGING_FUNCTION_BASIC(Debug)
/**
* Generates the logging functions using macros.
*
@@ -147,12 +192,12 @@ void FIRLogBasic(FIRLoggerLevel level,
* Calling FIRLogDebug(kFIRLoggerCore, @"I-COR000001", @"Configure succeed.") shows:
* yyyy-mm-dd hh:mm:ss.SSS sender[PID] <Debug> [Firebase/Core][I-COR000001] Configure succeed.
*/
#define FIR_LOGGING_FUNCTION(level) \
void FIRLog##level(FIRLoggerService service, NSString *messageCode, NSString *message, ...) { \
va_list args_ptr; \
va_start(args_ptr, message); \
FIRLogBasic(FIRLoggerLevel##level, service, messageCode, message, args_ptr); \
va_end(args_ptr); \
#define FIR_LOGGING_FUNCTION(level) \
void FIRLog##level(NSString *category, NSString *messageCode, NSString *message, ...) { \
va_list args_ptr; \
va_start(args_ptr, message); \
FIRLogBasic(FIRLoggerLevel##level, category, messageCode, message, args_ptr); \
va_end(args_ptr); \
}
FIR_LOGGING_FUNCTION(Error)
@@ -161,22 +206,14 @@ FIR_LOGGING_FUNCTION(Notice)
FIR_LOGGING_FUNCTION(Info)
FIR_LOGGING_FUNCTION(Debug)
#undef FIR_MAKE_LOGGER
#undef FIR_LOGGING_FUNCTION
#pragma mark - FIRLoggerWrapper
@implementation FIRLoggerWrapper
+ (void)logWithLevel:(FIRLoggerLevel)level
withService:(FIRLoggerService)service
withCode:(NSString *)messageCode
withMessage:(NSString *)message
withArgs:(va_list)args {
FIRLogBasic(level, service, messageCode, message, args);
}
+ (void)logWithLevel:(FIRLoggerLevel)level
service:(FIRLoggerService)service
service:(NSString *)service
code:(NSString *)code
message:(NSString *)message {
FIRLogBasic(level, service, code, message, NULL);

View File

@@ -14,8 +14,8 @@
#import "FirebaseCore/Extension/FIRAppInternal.h"
#import "FirebaseCore/Extension/FIRLogger.h"
#import "FirebaseCore/Extension/FIROptionsInternal.h"
#import "FirebaseCore/Sources/FIRBundleUtil.h"
#import "FirebaseCore/Sources/FIROptionsInternal.h"
#import "FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h"
// Keys for the strings in the plist file.
@@ -160,7 +160,7 @@ static dispatch_once_t sDefaultOptionsDictionaryOnceToken;
FIROptions *newOptions = [(FIROptions *)[[self class] allocWithZone:zone]
initInternalWithOptionsDictionary:self.optionsDictionary];
if (newOptions) {
newOptions.deepLinkURLScheme = self.deepLinkURLScheme;
newOptions->_deepLinkURLScheme = self->_deepLinkURLScheme;
newOptions.appGroupID = self.appGroupID;
newOptions.editingLocked = self.isEditingLocked;
newOptions.usingOptionsFromDefaultPlist = self.usingOptionsFromDefaultPlist;
@@ -284,7 +284,7 @@ static dispatch_once_t sDefaultOptionsDictionaryOnceToken;
// The unit tests are set up to catch anything that does not properly convert.
NSString *version = FIRFirebaseVersion();
NSArray *components = [version componentsSeparatedByString:@"."];
NSString *major = [components objectAtIndex:0];
NSString *major = [NSString stringWithFormat:@"%02d", [[components objectAtIndex:0] intValue]];
NSString *minor = [NSString stringWithFormat:@"%02d", [[components objectAtIndex:1] intValue]];
NSString *patch = [NSString stringWithFormat:@"%02d", [[components objectAtIndex:2] intValue]];
kFIRLibraryVersionID = [NSString stringWithFormat:@"%@%@%@000", major, minor, patch];
@@ -357,8 +357,8 @@ static dispatch_once_t sDefaultOptionsDictionaryOnceToken;
// Validate extra properties not contained in the dictionary. Only validate it if one of the
// objects has the property set.
if ((options.deepLinkURLScheme != nil || self.deepLinkURLScheme != nil) &&
![options.deepLinkURLScheme isEqualToString:self.deepLinkURLScheme]) {
if ((options->_deepLinkURLScheme != nil || self->_deepLinkURLScheme != nil) &&
![options->_deepLinkURLScheme isEqualToString:self->_deepLinkURLScheme]) {
return NO;
}
@@ -384,7 +384,7 @@ static dispatch_once_t sDefaultOptionsDictionaryOnceToken;
// Note: `self.analyticsOptionsDictionary` was left out here since it solely relies on the
// contents of the main bundle's `Info.plist`. We should avoid reading that file and the contents
// should be identical.
return self.optionsDictionary.hash ^ self.deepLinkURLScheme.hash ^ self.appGroupID.hash;
return self.optionsDictionary.hash ^ self->_deepLinkURLScheme.hash ^ self.appGroupID.hash;
}
#pragma mark - Internal instance methods
@@ -441,8 +441,8 @@ static dispatch_once_t sDefaultOptionsDictionaryOnceToken;
}
- (BOOL)isAnalyticsCollectionExplicitlySet {
// If it's de-activated, it classifies as explicity set. If not, it's not a good enough indication
// that the developer wants FirebaseAnalytics enabled so continue checking.
// If it's de-activated, it classifies as explicitly set. If not, it's not a good enough
// indication that the developer wants FirebaseAnalytics enabled so continue checking.
if (self.isAnalyticsCollectionDeactivated) {
return YES;
}

View File

@@ -16,27 +16,6 @@
#import <FirebaseCore/FIROptions.h>
/**
* Keys for the strings in the plist file.
*/
extern NSString *const kFIRAPIKey;
extern NSString *const kFIRTrackingID;
extern NSString *const kFIRGoogleAppID;
extern NSString *const kFIRClientID;
extern NSString *const kFIRGCMSenderID;
extern NSString *const kFIRAndroidClientID;
extern NSString *const kFIRDatabaseURL;
extern NSString *const kFIRStorageBucket;
extern NSString *const kFIRBundleID;
extern NSString *const kFIRProjectID;
/**
* Keys for the plist file name
*/
extern NSString *const kServiceInfoFileName;
extern NSString *const kServiceInfoFileType;
/**
* This header file exposes the initialization of FirebaseOptions to internal use.
*/

View File

@@ -0,0 +1,152 @@
/*
* 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 "FirebaseCore/Sources/FIRTimestampInternal.h"
NS_ASSUME_NONNULL_BEGIN
static const int kNanosPerSecond = 1000000000;
@implementation FIRTimestamp (Internal)
#pragma mark - Internal public methods
- (NSString *)ISO8601String {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss";
formatter.timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
NSDate *secondsDate = [NSDate dateWithTimeIntervalSince1970:self.seconds];
NSString *secondsString = [formatter stringFromDate:secondsDate];
if (secondsString.length != 19) {
[NSException raise:@"Invalid ISO string" format:@"Invalid ISO string: %@", secondsString];
}
NSString *nanosString = [NSString stringWithFormat:@"%09d", self.nanoseconds];
return [NSString stringWithFormat:@"%@.%@Z", secondsString, nanosString];
}
@end
@implementation FIRTimestamp
#pragma mark - Constructors
+ (instancetype)timestampWithDate:(NSDate *)date {
double secondsDouble;
double fraction = modf(date.timeIntervalSince1970, &secondsDouble);
// GCP Timestamps always have non-negative nanos.
if (fraction < 0) {
fraction += 1.0;
secondsDouble -= 1.0;
}
int64_t seconds = (int64_t)secondsDouble;
int32_t nanos = (int32_t)(fraction * kNanosPerSecond);
return [[FIRTimestamp alloc] initWithSeconds:seconds nanoseconds:nanos];
}
+ (instancetype)timestampWithSeconds:(int64_t)seconds nanoseconds:(int32_t)nanoseconds {
return [[FIRTimestamp alloc] initWithSeconds:seconds nanoseconds:nanoseconds];
}
+ (instancetype)timestamp {
return [FIRTimestamp timestampWithDate:[NSDate date]];
}
- (instancetype)initWithSeconds:(int64_t)seconds nanoseconds:(int32_t)nanoseconds {
self = [super init];
if (self) {
if (nanoseconds < 0) {
[NSException raise:@"Invalid timestamp"
format:@"Timestamp nanoseconds out of range: %d", nanoseconds];
}
if (nanoseconds >= 1e9) {
[NSException raise:@"Invalid timestamp"
format:@"Timestamp nanoseconds out of range: %d", nanoseconds];
}
// Midnight at the beginning of 1/1/1 is the earliest timestamp supported.
if (seconds < -62135596800L) {
[NSException raise:@"Invalid timestamp"
format:@"Timestamp seconds out of range: %lld", seconds];
}
// This will break in the year 10,000.
if (seconds >= 253402300800L) {
[NSException raise:@"Invalid timestamp"
format:@"Timestamp seconds out of range: %lld", seconds];
}
_seconds = seconds;
_nanoseconds = nanoseconds;
}
return self;
}
#pragma mark - NSObject methods
- (BOOL)isEqual:(id)object {
if (self == object) {
return YES;
}
if (![object isKindOfClass:[FIRTimestamp class]]) {
return NO;
}
return [self isEqualToTimestamp:(FIRTimestamp *)object];
}
- (NSUInteger)hash {
return (NSUInteger)((self.seconds >> 32) ^ self.seconds ^ self.nanoseconds);
}
- (NSString *)description {
return [NSString stringWithFormat:@"<FIRTimestamp: seconds=%lld nanoseconds=%d>", self.seconds,
self.nanoseconds];
}
/** Implements NSCopying without actually copying because timestamps are immutable. */
- (id)copyWithZone:(__unused NSZone *_Nullable)zone {
return self;
}
#pragma mark - Public methods
- (NSDate *)dateValue {
NSTimeInterval interval = (NSTimeInterval)self.seconds + ((NSTimeInterval)self.nanoseconds) / 1e9;
return [NSDate dateWithTimeIntervalSince1970:interval];
}
- (NSComparisonResult)compare:(FIRTimestamp *)other {
if (self.seconds < other.seconds) {
return NSOrderedAscending;
} else if (self.seconds > other.seconds) {
return NSOrderedDescending;
}
if (self.nanoseconds < other.nanoseconds) {
return NSOrderedAscending;
} else if (self.nanoseconds > other.nanoseconds) {
return NSOrderedDescending;
}
return NSOrderedSame;
}
#pragma mark - Private methods
- (BOOL)isEqualToTimestamp:(FIRTimestamp *)other {
return [self compare:other] == NSOrderedSame;
}
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,35 @@
/*
* 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 "FirebaseCore/Sources/Public/FirebaseCore/FIRTimestamp.h"
NS_ASSUME_NONNULL_BEGIN
/** Internal FIRTimestamp API we don't want exposed in our public header files. */
@interface FIRTimestamp (Internal)
/**
* Converts the given date to an ISO 8601 timestamp string, useful for rendering in JSON.
*
* ISO 8601 dates times in UTC look like this: "1912-04-14T23:40:00.000000000Z".
*
* @see http://www.ecma-international.org/ecma-262/6.0/#sec-date-time-string-format
*/
- (NSString *)ISO8601String;
@end
NS_ASSUME_NONNULL_END

View File

@@ -40,6 +40,9 @@ NS_SWIFT_NAME(FirebaseConfiguration)
*/
- (void)setLoggerLevel:(FIRLoggerLevel)loggerLevel;
/// Returns the logging level for internal Firebase logging.
- (FIRLoggerLevel)loggerLevel;
@end
NS_ASSUME_NONNULL_END

View File

@@ -83,7 +83,7 @@ NS_SWIFT_NAME(FirebaseOptions)
/**
* The URL scheme used to set up Durable Deep Link service.
*/
@property(nonatomic, copy, nullable) NSString *deepLinkURLScheme;
@property(nonatomic, copy, nullable) NSString *deepLinkURLScheme DEPRECATED_ATTRIBUTE;
/**
* The Google Cloud Storage bucket name, e.g. @"abc-xyz-123.storage.firebase.com".
@@ -102,12 +102,12 @@ NS_SWIFT_NAME(FirebaseOptions)
* This will read the file synchronously from disk.
* For example:
* ```swift
* if let path = Bundle.main.path(forResource:"GoogleServices-Info", ofType:"plist") {
* if let path = Bundle.main.path(forResource:"GoogleService-Info", ofType:"plist") {
* let options = FirebaseOptions(contentsOfFile: path)
* }
* ```
* Note that it is not possible to customize `FirebaseOptions` for Firebase Analytics which expects
* a static file named `GoogleServices-Info.plist` -
* a static file named `GoogleService-Info.plist` -
* https://github.com/firebase/firebase-ios-sdk/issues/230.
* Returns `nil` if the plist file does not exist or is invalid.
*/

View File

@@ -0,0 +1,90 @@
/*
* 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 Timestamp represents a point in time independent of any time zone or calendar, represented as
* seconds and fractions of seconds at nanosecond resolution in UTC Epoch time. It is encoded using
* the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It
* is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no
* leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to
* 9999-12-31T23:59:59.999999999Z. By restricting to that range, we ensure that we can convert to
* and from RFC 3339 date strings.
*
* @see https://github.com/google/protobuf/blob/main/src/google/protobuf/timestamp.proto for the
* reference timestamp definition.
*/
NS_SWIFT_SENDABLE
NS_SWIFT_NAME(Timestamp)
@interface FIRTimestamp : NSObject <NSCopying>
/** :nodoc: */
- (instancetype)init NS_UNAVAILABLE;
/**
* Creates a new timestamp.
*
* @param seconds the number of seconds since epoch.
* @param nanoseconds the number of nanoseconds after the seconds.
*/
- (instancetype)initWithSeconds:(int64_t)seconds
nanoseconds:(int32_t)nanoseconds NS_DESIGNATED_INITIALIZER;
/**
* Creates a new timestamp.
*
* @param seconds the number of seconds since epoch.
* @param nanoseconds the number of nanoseconds after the seconds.
*/
+ (instancetype)timestampWithSeconds:(int64_t)seconds nanoseconds:(int32_t)nanoseconds;
/** Creates a new timestamp from the given date. */
+ (instancetype)timestampWithDate:(NSDate *)date;
/** Creates a new timestamp with the current date / time. */
+ (instancetype)timestamp;
/** Returns a new `Date` corresponding to this timestamp. This may lose precision. */
- (NSDate *)dateValue;
/**
* Returns the result of comparing the receiver with another timestamp.
* @param other the other timestamp to compare.
* @return `orderedAscending` if `other` is chronologically following self,
* `orderedDescending` if `other` is chronologically preceding self,
* `orderedSame` otherwise.
*/
- (NSComparisonResult)compare:(FIRTimestamp *)other;
/**
* Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
* Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.
*/
@property(nonatomic, assign, readonly) int64_t seconds;
/**
* Non-negative fractions of a second at nanosecond resolution. Negative second values with
* fractions must still have non-negative nanos values that count forward in time.
* Must be from 0 to 999,999,999 inclusive.
*/
@property(nonatomic, assign, readonly) int32_t nanoseconds;
@end
NS_ASSUME_NONNULL_END

View File

@@ -18,4 +18,5 @@
#import "FIRConfiguration.h"
#import "FIRLoggerLevel.h"
#import "FIROptions.h"
#import "FIRTimestamp.h"
#import "FIRVersion.h"

View File

@@ -86,7 +86,7 @@ For details on using Firebase from a Framework or a library, refer to [firebase_
To develop Firebase software in this repository, ensure that you have at least
the following software:
* Xcode 14.1 (or later)
* Xcode 16.2 (or later)
CocoaPods is still the canonical way to develop, but much of the repo now supports
development with Swift Package Manager.
@@ -137,7 +137,7 @@ Alternatively, disable signing in each target:
### Adding a New Firebase Pod
Refer to [AddNewPod](AddNewPod.md) Markdown file for details.
Refer to [AddNewPod](docs/AddNewPod.md) Markdown file for details.
### Managing Headers and Imports
@@ -153,7 +153,7 @@ GitHub Actions will verify that any code changes are done in a style-compliant
way. Install `clang-format` and `mint`:
```console
brew install clang-format@18
brew install clang-format@20
brew install mint
```
@@ -235,6 +235,11 @@ at **Project Settings > Cloud Messaging > [Your Firebase App]**.
The iOS Simulator cannot register for remote notifications and will not receive push notifications.
To receive push notifications, follow the steps above and run the app on a physical device.
### Vertex AI for Firebase
See the [Vertex AI for Firebase README](FirebaseVertexAI#development) for
instructions about building and testing the SDK.
## Building with Firebase on Apple platforms
Firebase provides official beta support for macOS, Catalyst, and tvOS. visionOS and watchOS