From 72449ec4506d8f966fd840f551906e3ea231d59b Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Wed, 14 Feb 2024 16:14:02 -0500 Subject: [PATCH 1/4] Make `instanceForProtocol:inContainer:` return `nullable T` --- FirebaseCore/Extension/FIRComponentType.h | 3 ++- FirebaseCore/Sources/FIRComponentType.m | 3 ++- FirebaseStorage/Sources/Storage.swift | 12 ++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/FirebaseCore/Extension/FIRComponentType.h b/FirebaseCore/Extension/FIRComponentType.h index 6f2aca7b863..c69085d1983 100644 --- a/FirebaseCore/Extension/FIRComponentType.h +++ b/FirebaseCore/Extension/FIRComponentType.h @@ -27,7 +27,8 @@ NS_SWIFT_NAME(ComponentType) /// Do not use directly. A factory method to retrieve an instance that provides a specific /// functionality. -+ (T)instanceForProtocol:(Protocol *)protocol inContainer:(FIRComponentContainer *)container; ++ (nullable T)instanceForProtocol:(Protocol *)protocol + inContainer:(FIRComponentContainer *)container; @end diff --git a/FirebaseCore/Sources/FIRComponentType.m b/FirebaseCore/Sources/FIRComponentType.m index c9cd2ad2c2c..2204fd65b32 100644 --- a/FirebaseCore/Sources/FIRComponentType.m +++ b/FirebaseCore/Sources/FIRComponentType.m @@ -20,7 +20,8 @@ @implementation FIRComponentType -+ (id)instanceForProtocol:(Protocol *)protocol inContainer:(FIRComponentContainer *)container { ++ (nullable id)instanceForProtocol:(Protocol *)protocol + inContainer:(FIRComponentContainer *)container { // Forward the call to the container. return [container instanceForProtocol:protocol]; } diff --git a/FirebaseStorage/Sources/Storage.swift b/FirebaseStorage/Sources/Storage.swift index 79d18dfa4f6..16792fd1d80 100644 --- a/FirebaseStorage/Sources/Storage.swift +++ b/FirebaseStorage/Sources/Storage.swift @@ -61,8 +61,10 @@ import FirebaseCore /// - Parameter app: The custom `FirebaseApp` used for initialization. /// - Returns: A `Storage` instance, configured with the custom `FirebaseApp`. @objc(storageForApp:) open class func storage(app: FirebaseApp) -> Storage { - let provider = ComponentType.instance(for: StorageProvider.self, - in: app.container) + guard let provider = ComponentType.instance(for: StorageProvider.self, + in: app.container) else { + fatalError("No \(StorageProvider.self) instance found for Firebase app: \(app.name)") + } return provider.storage(for: Storage.bucket(for: app)) } @@ -75,8 +77,10 @@ import FirebaseCore /// URL. @objc(storageForApp:URL:) open class func storage(app: FirebaseApp, url: String) -> Storage { - let provider = ComponentType.instance(for: StorageProvider.self, - in: app.container) + guard let provider = ComponentType.instance(for: StorageProvider.self, + in: app.container) else { + fatalError("No \(StorageProvider.self) instance found for Firebase app: \(app.name)") + } return provider.storage(for: Storage.bucket(for: app, urlString: url)) } From a77549887771212c90fa964384bedf34108518ac Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Wed, 14 Feb 2024 16:39:40 -0500 Subject: [PATCH 2/4] Fix StorageComponentTests --- FirebaseStorage/Tests/Unit/StorageComponentTests.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FirebaseStorage/Tests/Unit/StorageComponentTests.swift b/FirebaseStorage/Tests/Unit/StorageComponentTests.swift index dce5d75fe0d..a7851fb9479 100644 --- a/FirebaseStorage/Tests/Unit/StorageComponentTests.swift +++ b/FirebaseStorage/Tests/Unit/StorageComponentTests.swift @@ -70,14 +70,14 @@ class StorageComponentTests: StorageTestHelpers { in: container) XCTAssertNotNil(provider) - let storage1 = provider.storage(for: "randomBucket") - let storage2 = provider.storage(for: "randomBucket") + let storage1 = provider?.storage(for: "randomBucket") + let storage2 = provider?.storage(for: "randomBucket") XCTAssertNotNil(storage1) // Ensure they're the same instance. XCTAssert(storage1 === storage2) - let storage3 = provider.storage(for: "differentBucket") + let storage3 = provider?.storage(for: "differentBucket") XCTAssertNotNil(storage3) XCTAssert(storage1 !== storage3) From da2434fba63572968936bf2e062ab6335098d6e1 Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Wed, 14 Feb 2024 17:49:56 -0500 Subject: [PATCH 3/4] Touch `Gemfile` --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 662939268b3..1caca509997 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,8 @@ source 'https://rubygems.org' # gem 'cocoapods-core', git: "https://github.com/CocoaPods/Core.git", ref: "f7cf05720eab935d7d50e35224d263952176fb53" # gem 'xcodeproj', git: "https://github.com/CocoaPods/Xcodeproj.git", ref: "eeccae7275645753cbaf45d96fc4b23e4b8b3b9f" +# TODO: Remove this comment after testing + gem 'cocoapods', '1.15.2' gem 'cocoapods-generate', '2.2.5' gem 'danger', '8.4.5' From 115c8726d68857b4c7dae7dedf2dd62634e98f81 Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Thu, 15 Feb 2024 14:24:37 -0500 Subject: [PATCH 4/4] Revert "Touch `Gemfile`" This reverts commit da2434fba63572968936bf2e062ab6335098d6e1. --- Gemfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Gemfile b/Gemfile index 1caca509997..662939268b3 100644 --- a/Gemfile +++ b/Gemfile @@ -12,8 +12,6 @@ source 'https://rubygems.org' # gem 'cocoapods-core', git: "https://github.com/CocoaPods/Core.git", ref: "f7cf05720eab935d7d50e35224d263952176fb53" # gem 'xcodeproj', git: "https://github.com/CocoaPods/Xcodeproj.git", ref: "eeccae7275645753cbaf45d96fc4b23e4b8b3b9f" -# TODO: Remove this comment after testing - gem 'cocoapods', '1.15.2' gem 'cocoapods-generate', '2.2.5' gem 'danger', '8.4.5'