Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 committed Oct 28, 2024
1 parent 4c44769 commit ed6aae1
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 11 deletions.
27 changes: 27 additions & 0 deletions FirebaseCore/InternalObjC/FIRComponentContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,33 @@

NS_ASSUME_NONNULL_BEGIN

@interface FIRComponentContainer (Private)

/// Initializes a container for a given app. This should only be called by the app itself.
- (instancetype)initWithApp:(FIRApp *)app
isDefaultApp:(BOOL)isDefaultApp
isAppForARCore:(BOOL)isAppForARCore;

/// Retrieves an instance that conforms to the specified protocol. This will return `nil` if the
/// protocol wasn't registered, or if the instance couldn't be instantiated for the provided app.
- (nullable id)instanceForProtocol:(Protocol *)protocol
NS_SWIFT_UNAVAILABLE("Use `instance(for:)` from the FirebaseCoreExtension module instead.");

/// Instantiates all the components that have registered as "eager" after initialization.
- (void)instantiateEagerComponents;

/// Remove all of the cached instances stored and allow them to clean up after themselves.
- (void)removeAllCachedInstances;

/// Removes all the components. After calling this method no new instances will be created.
- (void)removeAllComponents;

/// Register a class to provide components for the interoperability system. The class should conform
/// to `FIRComponentRegistrant` and provide an array of `FIRComponent` objects.
+ (void)registerAsComponentRegistrant:(Class<FIRLibrary>)klass;

@end

@interface FIRComponentContainer ()

/// The dictionary of components that are registered for a particular app. The key is an `NSString`
Expand Down
10 changes: 9 additions & 1 deletion FirebaseCore/InternalObjC/FIRComponentType.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@

#import "FirebaseCore/InternalObjC/FIRComponentType.h"

#import "FirebaseCore/InternalObjC/FIRComponentContainerInternal.h"
#import "FirebaseCore/InternalObjC/FIRComponentContainer.h"

@interface FIRComponentContainer (InstanceForProtocol)

/// Retrieves an instance that conforms to the specified protocol. This will return `nil` if the
/// protocol wasn't registered, or if the instance couldn't be instantiated for the provided app.
- (nullable id)instanceForProtocol:(Protocol *)protocol
NS_SWIFT_UNAVAILABLE("Use `instance(for:)` from the FirebaseCoreExtension module instead.");
@end

@implementation FIRComponentType

Expand Down
11 changes: 6 additions & 5 deletions FirebaseCore/Sources/FIRApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@

#import "FirebaseCore/Sources/Public/FirebaseCore/FIRApp.h"

@import FirebaseCoreInternal;
#if SWIFT_PACKAGE
@import FirebaseCoreInternalObjC;
#endif

#import "FirebaseCore/Sources/FIRAnalyticsConfiguration.h"
#import "FirebaseCore/Sources/FIRBundleUtil.h"
#import "FirebaseCore/Sources/FIRConfigurationInternal.h"
#import "FirebaseCore/Sources/FIRFirebaseUserAgent.h"

#import "FirebaseCore/Extension/FIRAppInternal.h"
#import "FirebaseCore/Extension/FIRHeartbeatLogger.h"
#import "FirebaseCore/Sources/FIRComponentContainerInternal.h"
#import "FirebaseCore/Sources/FIROptionsInternal.h"
#import "FirebaseCore/Sources/Public/FirebaseCore/FIROptions.h"
#import "FirebaseCore/Sources/Public/FirebaseCore/FIRVersion.h"

@import FirebaseCoreInternal;
#if SWIFT_PACKAGE
@import FirebaseCoreInternalObjC;
#endif

#import <GoogleUtilities/GULAppEnvironmentUtil.h>

#import <objc/runtime.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
*/
#import <Foundation/Foundation.h>

#import "FIRComponentContainer.h"
@import FirebaseCoreInternal;
#ifdef SWIFT_PACKAGE
@import FirebaseCoreInternalObjC;
#else
@import FirebaseCoreInternal;
#endif

@class FIRApp;
@protocol FIRLibrary;
Expand Down
11 changes: 10 additions & 1 deletion FirebaseCore/Tests/Unit/FIRComponentContainerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#import "FirebaseCore/Extension/FIRAppInternal.h"
#import "FirebaseCore/InternalObjC/FIRComponentContainer.h"
#import "FirebaseCore/InternalObjC/FIRComponentContainerInternal.h"
#import "FirebaseCore/InternalObjC/FIRComponentType.h"
#import "FirebaseCore/Tests/Unit/FIRTestComponents.h"
#import "SharedTestUtilities/FIROptionsMock.h"
Expand All @@ -34,6 +33,16 @@ + (void)registerAsComponentRegistrant:(Class<FIRLibrary>)klass
- (instancetype)initWithApp:(FIRApp *)app
isDefaultApp:(BOOL)isDefaultApp
registrants:(NSMutableSet<Class> *)allRegistrants;

/// Instantiates all the components that have registered as "eager" after initialization.
- (void)instantiateEagerComponents;

/// Remove all of the cached instances stored and allow them to clean up after themselves.
- (void)removeAllCachedInstances;

/// Removes all the components. After calling this method no new instances will be created.
- (void)removeAllComponents;

@end

@interface FIRComponentContainer (TestInternalImplementations)
Expand Down
10 changes: 9 additions & 1 deletion FirebaseCore/Tests/Unit/FIRComponentTypeTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@

#import "FirebaseCore/Tests/Unit/FIRTestCase.h"

#import "FirebaseCore/InternalObjC/FIRComponentContainerInternal.h"
#import "FirebaseCore/InternalObjC/FIRComponentType.h"

#import "FirebaseCore/Tests/Unit/FIRTestComponents.h"

@interface FIRComponentContainer (Private)

/// Retrieves an instance that conforms to the specified protocol. This will return `nil` if the
/// protocol wasn't registered, or if the instance couldn't be instantiated for the provided app.
- (nullable id)instanceForProtocol:(Protocol *)protocol
NS_SWIFT_UNAVAILABLE("Use `instance(for:)` from the FirebaseCoreExtension module instead.");

@end

@interface FIRComponentTypeTest : FIRTestCase

@property(nonatomic, strong) id componentContainerMock;
Expand Down
1 change: 0 additions & 1 deletion FirebaseCore/Tests/Unit/FIRTestComponents.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#import "FirebaseCore/Extension/FIRAppInternal.h"
#import "FirebaseCore/InternalObjC/FIRComponentContainer.h"
#import "FirebaseCore/InternalObjC/FIRComponentContainerInternal.h"
#import "FirebaseCore/InternalObjC/FIRComponentType.h"
#import "FirebaseCore/Tests/Unit/FIRTestComponents.h"

Expand Down
2 changes: 1 addition & 1 deletion FirebaseStorage/Tests/Unit/StorageComponentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import Foundation

import FirebaseCore
import FirebaseCoreExtension
@_implementationOnly import FirebaseCoreExtension
@testable import FirebaseStorage

import FirebaseAppCheckInterop
Expand Down

0 comments on commit ed6aae1

Please sign in to comment.