diff --git a/.github/workflows/auth.yml b/.github/workflows/auth.yml index 12c71aad8c..aebe3ba858 100644 --- a/.github/workflows/auth.yml +++ b/.github/workflows/auth.yml @@ -4,7 +4,7 @@ on: pull_request: paths: - 'FirebaseAuth**' - - 'Interop/Auth/Public/*.h' + - 'FirebaseAuth/Interop/*.h' - '.github/workflows/auth.yml' - 'Gemfile*' schedule: diff --git a/.github/workflows/database.yml b/.github/workflows/database.yml index 3eaa9cf17c..d9ee330219 100644 --- a/.github/workflows/database.yml +++ b/.github/workflows/database.yml @@ -7,7 +7,7 @@ on: - 'Firebase/Database/**' - 'FirebaseSharedSwift**' - 'Example/Database/**' - - 'Interop/Auth/Public/*.h' + - 'FirebaseAuth/Interop/*.h' - '.github/workflows/database.yml' - 'Gemfile*' - 'scripts/run_database_emulator.sh' diff --git a/.github/workflows/firestore.yml b/.github/workflows/firestore.yml index 9cacb286e2..ced6fee8a6 100644 --- a/.github/workflows/firestore.yml +++ b/.github/workflows/firestore.yml @@ -21,7 +21,7 @@ on: - 'Firestore/**' # Interop headers - - 'Interop/Auth/Public/*.h' + - 'FirebaseAuth/Interop/*.h' # FirebaseCore header change - 'FirebaseCore/Internal' diff --git a/.github/workflows/functions.yml b/.github/workflows/functions.yml index fb3d7c6d66..fec2f68ead 100644 --- a/.github/workflows/functions.yml +++ b/.github/workflows/functions.yml @@ -6,8 +6,8 @@ on: - 'FirebaseFunctions**' - 'FirebaseSharedSwift**' - '.github/workflows/functions.yml' - - 'Interop/Auth/Public/*.h' - - 'FirebaseMessaging/Sources/Interop/*.h' + - 'FirebaseAuth/Interop/*.h' + - 'FirebaseMessaging/Interop/*.h' - 'FirebaseTestingSupport/Functions/**' - 'FirebaseCombineSwift/Sources/Functions/**' - 'scripts/setup_quickstart.sh' diff --git a/.github/workflows/storage.yml b/.github/workflows/storage.yml index 6ffb5437ac..ce6ca70f7c 100644 --- a/.github/workflows/storage.yml +++ b/.github/workflows/storage.yml @@ -4,7 +4,7 @@ on: pull_request: paths: - 'FirebaseStorage**' - - 'Interop/Auth/Public/*.h' + - 'FirebaseAuth/Interop/*.h' - '.github/workflows/storage.yml' - 'scripts/**' # Rebuild on Ruby infrastructure changes. diff --git a/CMakeLists.txt b/CMakeLists.txt index 6255235101..fa81ec2cee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -261,8 +261,8 @@ if(FIREBASE_IOS_BUILD_TESTS) enable_testing() endif() -add_subdirectory(FirebaseAppCheck/Interop/) +add_subdirectory(FirebaseAppCheck/Interop) add_subdirectory(FirebaseCore) add_subdirectory(Firestore) -add_subdirectory(Interop/Auth) +add_subdirectory(FirebaseAuth/Interop) add_subdirectory(Interop/CoreDiagnostics) diff --git a/FirebaseAppCheckInterop.podspec b/FirebaseAppCheckInterop.podspec index 7471feb178..2312fb3546 100644 --- a/FirebaseAppCheckInterop.podspec +++ b/FirebaseAppCheckInterop.podspec @@ -27,4 +27,4 @@ Pod::Spec.new do |s| s.source_files = 'FirebaseAppCheck/Interop/*.[hm]' s.public_header_files = 'FirebaseAppCheck/Interop/*.h' -end \ No newline at end of file +end diff --git a/FirebaseAuth.podspec b/FirebaseAuth.podspec index 6a7f67b821..d5887ca97b 100644 --- a/FirebaseAuth.podspec +++ b/FirebaseAuth.podspec @@ -36,7 +36,7 @@ supports email and password accounts, as well as several 3rd party authenticatio s.source_files = [ source + '**/*.[mh]', 'FirebaseCore/Internal/*.h', - 'Interop/Auth/Public/*.h', + 'FirebaseAuth/Interop/*.h', ] s.public_header_files = source + 'Public/FirebaseAuth/*.h' s.preserve_paths = [ diff --git a/Interop/Auth/CMakeLists.txt b/FirebaseAuth/Interop/CMakeLists.txt similarity index 100% rename from Interop/Auth/CMakeLists.txt rename to FirebaseAuth/Interop/CMakeLists.txt diff --git a/Interop/Auth/Public/FIRAuthInterop.h b/FirebaseAuth/Interop/FIRAuthInterop.h similarity index 88% rename from Interop/Auth/Public/FIRAuthInterop.h rename to FirebaseAuth/Interop/FIRAuthInterop.h index a33da7c9f4..296740782a 100644 --- a/Interop/Auth/Public/FIRAuthInterop.h +++ b/FirebaseAuth/Interop/FIRAuthInterop.h @@ -32,7 +32,9 @@ NS_SWIFT_NAME(AuthInterop) @protocol FIRAuthInterop /// Retrieves the Firebase authentication token, possibly refreshing it if it has expired. -- (void)getTokenForcingRefresh:(BOOL)forceRefresh withCallback:(FIRTokenCallback)callback; +- (void)getTokenForcingRefresh:(BOOL)forceRefresh + withCallback:(FIRTokenCallback)callback + NS_SWIFT_NAME(getToken(forcingRefresh:completion:)); /// Get the current Auth user's UID. Returns nil if there is no user signed in. - (nullable NSString *)getUserID; diff --git a/FirebaseAuth/Interop/dummy.m b/FirebaseAuth/Interop/dummy.m new file mode 100644 index 0000000000..2e503fe69d --- /dev/null +++ b/FirebaseAuth/Interop/dummy.m @@ -0,0 +1,17 @@ +/* + * 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. + */ + +// Swift Package Manager needs at least one source file. diff --git a/FirebaseAuth/Sources/Auth/FIRAuth_Internal.h b/FirebaseAuth/Sources/Auth/FIRAuth_Internal.h index 5d3182bcad..14d8dcf05e 100644 --- a/FirebaseAuth/Sources/Auth/FIRAuth_Internal.h +++ b/FirebaseAuth/Sources/Auth/FIRAuth_Internal.h @@ -15,9 +15,9 @@ */ #import +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h" #import "FirebaseCore/Internal/FIRLogger.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" @class FIRAuthRequestConfiguration; @class FIRAuthURLPresenter; diff --git a/FirebaseAuth/Tests/Unit/FIRAuthLifeCycleTests.m b/FirebaseAuth/Tests/Unit/FIRAuthLifeCycleTests.m index 5b757a46c5..21b25255bc 100644 --- a/FirebaseAuth/Tests/Unit/FIRAuthLifeCycleTests.m +++ b/FirebaseAuth/Tests/Unit/FIRAuthLifeCycleTests.m @@ -16,8 +16,8 @@ #import +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseCore/Internal/FirebaseCoreInternal.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" #import "FirebaseAuth/Sources/Auth/FIRAuth_Internal.h" #import "FirebaseAuth/Sources/Backend/FIRAuthRequestConfiguration.h" diff --git a/FirebaseAuth/Tests/Unit/FIRAuthTests.m b/FirebaseAuth/Tests/Unit/FIRAuthTests.m index 936716bb37..6110457664 100644 --- a/FirebaseAuth/Tests/Unit/FIRAuthTests.m +++ b/FirebaseAuth/Tests/Unit/FIRAuthTests.m @@ -19,6 +19,7 @@ #import #import +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRActionCodeSettings.h" #import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAdditionalUserInfo.h" #import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuthSettings.h" @@ -27,7 +28,6 @@ #import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRGoogleAuthProvider.h" #import "FirebaseAuth/Sources/Public/FirebaseAuth/FIROAuthProvider.h" #import "FirebaseCore/Internal/FirebaseCoreInternal.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" #import "FirebaseAuth/Sources/Auth/FIRAuthDispatcher.h" #import "FirebaseAuth/Sources/Auth/FIRAuthGlobalWorkQueue.h" diff --git a/FirebaseAuthInterop.podspec b/FirebaseAuthInterop.podspec new file mode 100644 index 0000000000..a7eef21a81 --- /dev/null +++ b/FirebaseAuthInterop.podspec @@ -0,0 +1,30 @@ +Pod::Spec.new do |s| + s.name = 'FirebaseAuthInterop' + s.version = '8.12.0' + s.summary = 'Interfaces that allow other Firebase SDKs to use Auth functionality.' + + s.description = <<-DESC + Not for public use. + A set of protocols that other Firebase SDKs can use to interoperate with FirebaseAuth in a safe + and reliable manner. + DESC + + s.homepage = 'https://firebase.google.com' + s.license = { :type => 'Apache', :file => 'LICENSE' } + s.authors = 'Google, Inc.' + + # NOTE that these should not be used externally, this is for Firebase pods to depend on each + # other. + s.source = { + :git => 'https://github.com/firebase/firebase-ios-sdk.git', + :tag => 'CocoaPods-' + s.version.to_s + } + s.social_media_url = 'https://twitter.com/Firebase' + s.ios.deployment_target = '10.0' + s.osx.deployment_target = '10.12' + s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '6.0' + + s.source_files = 'FirebaseAuth/Interop/*.[hm]' + s.public_header_files = 'FirebaseAuth/Interop/*.h' +end diff --git a/FirebaseDatabase.podspec b/FirebaseDatabase.podspec index 92c3ccd6ac..c6e37e5c45 100644 --- a/FirebaseDatabase.podspec +++ b/FirebaseDatabase.podspec @@ -35,7 +35,7 @@ Simplify your iOS development, grow your user base, and monetize more effectivel base_dir + '**/*.[mh]', base_dir + 'third_party/Wrap-leveldb/APLevelDB.mm', base_dir + 'third_party/SocketRocket/fbase64.c', - 'Interop/Auth/Public/*.h', + 'FirebaseAuth/Interop/*.h', 'FirebaseAppCheck/Interop/*.h', 'FirebaseCore/Internal/*.h', ] diff --git a/FirebaseDatabase/Sources/Api/FIRDatabase.m b/FirebaseDatabase/Sources/Api/FIRDatabase.m index a1b04cbf56..0e670da365 100644 --- a/FirebaseDatabase/Sources/Api/FIRDatabase.m +++ b/FirebaseDatabase/Sources/Api/FIRDatabase.m @@ -16,8 +16,8 @@ #import +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseCore/Internal/FirebaseCoreInternal.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" #import "FirebaseDatabase/Sources/Api/FIRDatabaseComponent.h" #import "FirebaseDatabase/Sources/Api/Private/FIRDatabaseQuery_Private.h" diff --git a/FirebaseDatabase/Sources/Api/FIRDatabaseComponent.m b/FirebaseDatabase/Sources/Api/FIRDatabaseComponent.m index be8a127aaa..524f929f92 100644 --- a/FirebaseDatabase/Sources/Api/FIRDatabaseComponent.m +++ b/FirebaseDatabase/Sources/Api/FIRDatabaseComponent.m @@ -21,8 +21,8 @@ #import "FirebaseDatabase/Sources/FIRDatabaseConfig_Private.h" #import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseCore/Internal/FirebaseCoreInternal.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" NS_ASSUME_NONNULL_BEGIN diff --git a/FirebaseDatabase/Sources/Login/FIRDatabaseConnectionContextProvider.m b/FirebaseDatabase/Sources/Login/FIRDatabaseConnectionContextProvider.m index 15429db5ed..0d4f35427a 100644 --- a/FirebaseDatabase/Sources/Login/FIRDatabaseConnectionContextProvider.m +++ b/FirebaseDatabase/Sources/Login/FIRDatabaseConnectionContextProvider.m @@ -20,7 +20,7 @@ #import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h" #import "FirebaseAppCheck/Interop/FIRAppCheckTokenResultInterop.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseDatabase/Sources/Api/Private/FIRDatabaseQuery_Private.h" #import "FirebaseDatabase/Sources/Utilities/FUtilities.h" diff --git a/FirebaseDatabase/Tests/Helpers/FTestHelpers.m b/FirebaseDatabase/Tests/Helpers/FTestHelpers.m index 5a224a6df1..1eb515ab97 100644 --- a/FirebaseDatabase/Tests/Helpers/FTestHelpers.m +++ b/FirebaseDatabase/Tests/Helpers/FTestHelpers.m @@ -16,8 +16,8 @@ #import "FirebaseDatabase/Tests/Helpers/FTestHelpers.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseCore/Internal/FirebaseCoreInternal.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" #import "FirebaseDatabase/Sources/Api/Private/FIRDatabase_Private.h" #import "FirebaseDatabase/Sources/Constants/FConstants.h" diff --git a/FirebaseDatabase/Tests/Integration/FIRAuthTests.m b/FirebaseDatabase/Tests/Integration/FIRAuthTests.m index 81e7a976d3..2bb248330c 100644 --- a/FirebaseDatabase/Tests/Integration/FIRAuthTests.m +++ b/FirebaseDatabase/Tests/Integration/FIRAuthTests.m @@ -16,8 +16,8 @@ #import +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseCore/Internal/FirebaseCoreInternal.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" #import "FirebaseDatabase/Sources/FIRDatabaseConfig_Private.h" #import "FirebaseDatabase/Tests/Helpers/FTestBase.h" diff --git a/FirebaseFirestore.podspec b/FirebaseFirestore.podspec index 82ed282d2c..ca364dffa2 100644 --- a/FirebaseFirestore.podspec +++ b/FirebaseFirestore.podspec @@ -49,7 +49,7 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, 'Firestore/Protos/nanopb/**/*.cc', 'Firestore/core/include/**/*.{cc,mm}', 'Firestore/core/src/**/*.{cc,mm}', - 'Interop/Auth/Public/*.h', + 'FirebaseAuth/Interop/*.h', ] # Internal headers that aren't necessarily globally unique. Most C++ internal diff --git a/FirebaseFunctions.podspec b/FirebaseFunctions.podspec index 9484e780a8..6f8ce1666e 100644 --- a/FirebaseFunctions.podspec +++ b/FirebaseFunctions.podspec @@ -25,10 +25,10 @@ Cloud Functions for Firebase. s.source_files = [ 'FirebaseFunctions/Sources/**/*', - 'Interop/Auth/Public/*.h', + 'FirebaseAuth/Interop/*.h', 'FirebaseAppCheck/Interop/*.h', 'FirebaseCore/Internal/*.h', - 'FirebaseMessaging/Sources/Interop/FIRMessagingInterop.h', + 'FirebaseMessaging/Interop/FIRMessagingInterop.h', ] s.public_header_files = 'FirebaseFunctions/Sources/Public/FirebaseFunctions/*.h' diff --git a/FirebaseFunctions/Sources/FIRFunctions.m b/FirebaseFunctions/Sources/FIRFunctions.m index 2b84834859..3f6a34f119 100644 --- a/FirebaseFunctions/Sources/FIRFunctions.m +++ b/FirebaseFunctions/Sources/FIRFunctions.m @@ -18,9 +18,9 @@ #import "FirebaseFunctions/Sources/Public/FirebaseFunctions/FIRFunctions.h" #import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseFunctions/Sources/FIRFunctionsComponent.h" -#import "FirebaseMessaging/Sources/Interop/FIRMessagingInterop.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" +#import "FirebaseMessaging/Interop/FIRMessagingInterop.h" #import "FirebaseFunctions/Sources/FIRHTTPSCallable+Internal.h" #import "FirebaseFunctions/Sources/FUNContext.h" diff --git a/FirebaseFunctions/Sources/FIRFunctionsComponent.m b/FirebaseFunctions/Sources/FIRFunctionsComponent.m index 6930ab4ab2..6724db8f69 100644 --- a/FirebaseFunctions/Sources/FIRFunctionsComponent.m +++ b/FirebaseFunctions/Sources/FIRFunctionsComponent.m @@ -21,8 +21,8 @@ #import "FirebaseCore/Internal/FirebaseCoreInternal.h" #import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h" -#import "FirebaseMessaging/Sources/Interop/FIRMessagingInterop.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" +#import "FirebaseMessaging/Interop/FIRMessagingInterop.h" @interface FIRFunctionsComponent () diff --git a/FirebaseFunctions/Sources/FUNContext.m b/FirebaseFunctions/Sources/FUNContext.m index c7a4bfc6fc..a7743281b8 100644 --- a/FirebaseFunctions/Sources/FUNContext.m +++ b/FirebaseFunctions/Sources/FUNContext.m @@ -17,8 +17,8 @@ #import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h" #import "FirebaseAppCheck/Interop/FIRAppCheckTokenResultInterop.h" -#import "FirebaseMessaging/Sources/Interop/FIRMessagingInterop.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" +#import "FirebaseMessaging/Interop/FIRMessagingInterop.h" NS_ASSUME_NONNULL_BEGIN diff --git a/FirebaseFunctionsSwift.podspec b/FirebaseFunctionsSwift.podspec index 00fe201600..33753c2798 100644 --- a/FirebaseFunctionsSwift.podspec +++ b/FirebaseFunctionsSwift.podspec @@ -38,6 +38,8 @@ Swift SDK Extensions for Cloud Functions for Firebase. s.dependency 'FirebaseCore', '~> 8.12' s.dependency 'FirebaseCoreInternal', '~> 8.12' s.dependency 'FirebaseAppCheckInterop', '~> 8.12' + s.dependency 'FirebaseAuthInterop', '~> 8.12' + s.dependency 'FirebaseMessagingInterop', '~> 8.12' s.dependency 'FirebaseSharedSwift', '~> 8.12' s.dependency 'GTMSessionFetcher/Core', '~> 1.5' diff --git a/FirebaseFunctionsSwift/Sources/Functions.swift b/FirebaseFunctionsSwift/Sources/Functions.swift index 279db14870..1377179d96 100644 --- a/FirebaseFunctionsSwift/Sources/Functions.swift +++ b/FirebaseFunctionsSwift/Sources/Functions.swift @@ -14,8 +14,10 @@ import Foundation import FirebaseAppCheckInterop +import FirebaseAuthInterop import FirebaseCore import FirebaseCoreInternal +import FirebaseMessagingInterop import FirebaseSharedSwift #if COCOAPODS import GTMSessionFetcher @@ -23,17 +25,6 @@ import FirebaseSharedSwift import GTMSessionFetcherCore #endif -// PLACEHOLDERS -@objc public protocol AuthInterop { - func getToken(forcingRefresh: Bool, callback: (String?, Error?) -> Void) -} - -@objc public protocol MessagingInterop { - var fcmToken: String { get } -} - -// END PLACEHOLDERS - /// File specific constants. private enum Constants { static let appCheckTokenHeader = "X-Firebase-AppCheck" diff --git a/FirebaseFunctionsSwift/Sources/FunctionsContext.swift b/FirebaseFunctionsSwift/Sources/FunctionsContext.swift index ba30bbcb9a..06f0ba91b9 100644 --- a/FirebaseFunctionsSwift/Sources/FunctionsContext.swift +++ b/FirebaseFunctionsSwift/Sources/FunctionsContext.swift @@ -14,6 +14,8 @@ import Foundation import FirebaseAppCheckInterop +import FirebaseAuthInterop +import FirebaseMessagingInterop /// FunctionsContext is a helper class for gathering metadata for a function call. internal class FunctionsContext: NSObject { @@ -67,7 +69,10 @@ internal class FunctionsContextProvider: NSObject { dispatchGroup.enter() appCheck.getToken(forcingRefresh: false) { tokenResult in - appCheckToken = tokenResult.token + // Send only valid token to functions. + if tokenResult.error == nil { + appCheckToken = tokenResult.token + } dispatchGroup.leave() } } diff --git a/FirebaseFunctionsSwift/Tests/Integration/IntegrationTests.swift b/FirebaseFunctionsSwift/Tests/Integration/IntegrationTests.swift index 31b4d3a686..ba7ed53158 100644 --- a/FirebaseFunctionsSwift/Tests/Integration/IntegrationTests.swift +++ b/FirebaseFunctionsSwift/Tests/Integration/IntegrationTests.swift @@ -15,6 +15,8 @@ import Foundation @testable import FirebaseFunctionsSwift +import FirebaseAuthInterop +import FirebaseMessagingInterop import XCTest /// This file was intitialized as a direct port of `FirebaseFunctionsSwift/Tests/IntegrationTests.swift` @@ -658,17 +660,21 @@ class IntegrationTests: XCTestCase { } private class AuthTokenProvider: AuthInterop { + func getUserID() -> String? { + return "fake user" + } + let token: String init(token: String) { self.token = token } - func getToken(forcingRefresh: Bool, callback: (String?, Error?) -> Void) { - callback(token, nil) + func getToken(forcingRefresh: Bool, completion: (String?, Error?) -> Void) { + completion(token, nil) } } -private class MessagingTokenProvider: MessagingInterop { - var fcmToken: String { return "fakeFCMToken" } +private class MessagingTokenProvider: NSObject, MessagingInterop { + var fcmToken: String? { return "fakeFCMToken" } } diff --git a/FirebaseFunctionsSwift/Tests/ObjCIntegration/FIRIntegrationTests.m b/FirebaseFunctionsSwift/Tests/ObjCIntegration/FIRIntegrationTests.m index ff37f89cc0..6c61a0944c 100644 --- a/FirebaseFunctionsSwift/Tests/ObjCIntegration/FIRIntegrationTests.m +++ b/FirebaseFunctionsSwift/Tests/ObjCIntegration/FIRIntegrationTests.m @@ -18,21 +18,19 @@ #import "FirebaseFunctionsSwift/Tests/ObjCIntegration/FIRFunctions+Internal.h" @import FirebaseFunctionsSwift; +@import FirebaseMessagingInterop; @import GTMSessionFetcherCore; -//#import "SharedTestUtilities/FIRAuthInteropFake.h" -//#import "SharedTestUtilities/FIRMessagingInteropFake.h" - // Project ID used by these tests. static NSString *const kDefaultProjectID = @"functions-integration-test"; -@interface MessagingTokenProvider : NSObject +@interface MessagingTokenProvider : NSObject @end @implementation MessagingTokenProvider -@synthesize fcmToken; +@synthesize FCMToken; - (instancetype)init { - fcmToken = @"abc"; + FCMToken = @"abc"; } @end diff --git a/FirebaseFunctionsSwift/Tests/Unit/ContextProviderTests.swift b/FirebaseFunctionsSwift/Tests/Unit/ContextProviderTests.swift index 0e319fdccd..8b2c01c9aa 100644 --- a/FirebaseFunctionsSwift/Tests/Unit/ContextProviderTests.swift +++ b/FirebaseFunctionsSwift/Tests/Unit/ContextProviderTests.swift @@ -12,181 +12,140 @@ // See the License for the specific language governing permissions and // limitations under the License. -// #import -// -// #import "FirebaseFunctions/Sources/FUNContext.h" -// -// #import "SharedTestUtilities/AppCheckFake/FIRAppCheckFake.h" -// #import "SharedTestUtilities/AppCheckFake/FIRAppCheckTokenResultFake.h" -// #import "SharedTestUtilities/FIRAuthInteropFake.h" -// #import "SharedTestUtilities/FIRMessagingInteropFake.h" -// -// @interface FUNContextProviderTests : XCTestCase -// -// @property(nonatomic) FIRMessagingInteropFake *messagingFake; -// -// @property(nonatomic) FIRAppCheckFake *appCheckFake; -// @property(strong, nonatomic) FIRAppCheckTokenResultFake *appCheckTokenSuccess; -// @property(strong, nonatomic) FIRAppCheckTokenResultFake *appCheckTokenError; -// -// @end -// -// @implementation FUNContextProviderTests -// -// - (void)setUp { -// self.messagingFake = [[FIRMessagingInteropFake alloc] init]; -// self.appCheckFake = [[FIRAppCheckFake alloc] init]; -// -// self.appCheckTokenSuccess = [[FIRAppCheckTokenResultFake alloc] initWithToken:@"valid_token" -// error:nil]; -// self.appCheckTokenError = [[FIRAppCheckTokenResultFake alloc] -// initWithToken:@"dummy token" -// error:[NSError errorWithDomain:@"testAppCheckError" code:-1 userInfo:nil]]; -// } -// -// - (void)testContextWithAuth { -// FIRAuthInteropFake *auth = [[FIRAuthInteropFake alloc] initWithToken:@"token" -// userID:@"userID" -// error:nil]; -// FUNContextProvider *provider = [[FUNContextProvider alloc] initWithAuth:(id)auth -// messaging:self.messagingFake -// appCheck:nil]; -// XCTestExpectation *expectation = -// [self expectationWithDescription:@"Context should have auth keys."]; -// [provider getContext:^(FUNContext *context, NSError *_Nullable error) { -// XCTAssertNotNil(context); -// XCTAssert([context.authToken isEqualToString:@"token"]); -// XCTAssert([context.FCMToken isEqualToString:self.messagingFake.FCMToken]); -// XCTAssertNil(error); -// [expectation fulfill]; -// }]; -// -// [self waitForExpectations:@[ expectation ] timeout:0.1]; -// } -// -// - (void)testContextWithAuthError { -// NSError *authError = [[NSError alloc] initWithDomain:@"com.functions.tests" code:4 userInfo:nil]; -// FIRAuthInteropFake *auth = [[FIRAuthInteropFake alloc] initWithToken:nil -// userID:nil -// error:authError]; -// FUNContextProvider *provider = [[FUNContextProvider alloc] initWithAuth:(id)auth -// messaging:self.messagingFake -// appCheck:nil]; -// XCTestExpectation *expectation = -// [self expectationWithDescription:@"Completion handler should fail with Auth error."]; -// [provider getContext:^(FUNContext *context, NSError *_Nullable error) { -// XCTAssertNotNil(context); -// XCTAssertNil(context.authToken); -// XCTAssertEqual(error, auth.error); -// [expectation fulfill]; -// }]; -// -// [self waitForExpectations:@[ expectation ] timeout:0.1]; -// } -// -// - (void)testContextWithoutAuth { -// FUNContextProvider *provider = [[FUNContextProvider alloc] initWithAuth:nil -// messaging:nil -// appCheck:nil]; -// XCTestExpectation *expectation = -// [self expectationWithDescription:@"Completion handler should succeed without Auth."]; -// [provider getContext:^(FUNContext *context, NSError *_Nullable error) { -// XCTAssertNotNil(context); -// XCTAssertNil(error); -// XCTAssertNil(context.authToken); -// XCTAssertNil(context.FCMToken); -// [expectation fulfill]; -// }]; -// -// [self waitForExpectations:@[ expectation ] timeout:0.1]; -// } -// -// - (void)testContextWithAppCheckOnlySuccess { -// self.appCheckFake.tokenResult = self.appCheckTokenSuccess; -// FUNContextProvider *provider = [[FUNContextProvider alloc] initWithAuth:nil -// messaging:nil -// appCheck:self.appCheckFake]; -// XCTestExpectation *expectation = -// [self expectationWithDescription:@"Completion handler should succeed without Auth."]; -// [provider getContext:^(FUNContext *context, NSError *_Nullable error) { -// XCTAssertNotNil(context); -// XCTAssertNil(error); -// XCTAssertNil(context.authToken); -// XCTAssertNil(context.FCMToken); -// XCTAssertEqualObjects(context.appCheckToken, self.appCheckTokenSuccess.token); -// [expectation fulfill]; -// }]; -// -// [self waitForExpectations:@[ expectation ] timeout:0.1]; -// } -// -// - (void)testContextWithAppCheckOnlyError { -// self.appCheckFake.tokenResult = self.appCheckTokenError; -// FUNContextProvider *provider = [[FUNContextProvider alloc] initWithAuth:nil -// messaging:nil -// appCheck:self.appCheckFake]; -// XCTestExpectation *expectation = -// [self expectationWithDescription:@"Completion handler should succeed without Auth."]; -// [provider getContext:^(FUNContext *context, NSError *_Nullable error) { -// XCTAssertNotNil(context); -// XCTAssertNil(error); -// XCTAssertNil(context.authToken); -// XCTAssertNil(context.FCMToken); -// // Don't expect any token in the case of App Check error. -// XCTAssertNil(context.appCheckToken); -// [expectation fulfill]; -// }]; -// -// [self waitForExpectations:@[ expectation ] timeout:0.1]; -// } -// -// - (void)testAllContextsAvailableSuccess { -// self.appCheckFake.tokenResult = self.appCheckTokenSuccess; -// FIRAuthInteropFake *auth = [[FIRAuthInteropFake alloc] initWithToken:@"token" -// userID:@"userID" -// error:nil]; -// FUNContextProvider *provider = [[FUNContextProvider alloc] initWithAuth:auth -// messaging:self.messagingFake -// appCheck:self.appCheckFake]; -// XCTestExpectation *expectation = -// [self expectationWithDescription:@"Completion handler should succeed without Auth."]; -// [provider getContext:^(FUNContext *context, NSError *_Nullable error) { -// XCTAssertNotNil(context); -// XCTAssertNil(error); -// XCTAssert([context.authToken isEqualToString:@"token"]); -// XCTAssert([context.FCMToken isEqualToString:self.messagingFake.FCMToken]); -// XCTAssertEqualObjects(context.appCheckToken, self.appCheckTokenSuccess.token); -// [expectation fulfill]; -// }]; -// -// [self waitForExpectations:@[ expectation ] timeout:0.1]; -// } -// -// - (void)testAllContextsAuthAndAppCheckError { -// self.appCheckFake.tokenResult = self.appCheckTokenError; -// -// NSError *authError = [[NSError alloc] initWithDomain:@"com.functions.tests" code:4 userInfo:nil]; -// FIRAuthInteropFake *auth = [[FIRAuthInteropFake alloc] initWithToken:nil -// userID:nil -// error:authError]; -// -// FUNContextProvider *provider = [[FUNContextProvider alloc] initWithAuth:auth -// messaging:self.messagingFake -// appCheck:self.appCheckFake]; -// XCTestExpectation *expectation = -// [self expectationWithDescription:@"Completion handler should succeed without Auth."]; -// [provider getContext:^(FUNContext *context, NSError *_Nullable error) { -// XCTAssertNotNil(context); -// XCTAssertEqual(error, auth.error); -// -// XCTAssertNil(context.authToken); -// XCTAssert([context.FCMToken isEqualToString:self.messagingFake.FCMToken]); -// // Don't expect any token in the case of App Check error. -// XCTAssertNil(context.appCheckToken); -// [expectation fulfill]; -// }]; -// -// [self waitForExpectations:@[ expectation ] timeout:0.1]; -// } -// -// @end +import Foundation + +import FirebaseCore +@testable import FirebaseFunctionsSwift + +import FirebaseAppCheckInterop +import FirebaseAuthInterop +import FirebaseMessagingInterop +import SharedTestUtilities + +import XCTest + +class ContextProviderTests: XCTestCase { + let appCheckFake = FIRAppCheckFake() + let appCheckTokenError = FIRAppCheckTokenResultFake(token: "dummy token", + error: NSError( + domain: "testAppCheckError", + code: -1, + userInfo: nil + )) + let appCheckTokenSuccess = FIRAppCheckTokenResultFake(token: "valid_token", error: nil) + let messagingFake = FIRMessagingInteropFake() + + func testContextWithAuth() { + let auth = FIRAuthInteropFake(token: "token", userID: "userID", error: nil) + let provider = FunctionsContextProvider(auth: auth, messaging: messagingFake, appCheck: nil) + let expectation = expectation(description: "Context should have auth keys.") + provider.getContext { context, error in + XCTAssertNotNil(context) + XCTAssertEqual(context.authToken, "token") + XCTAssertEqual(context.fcmToken, self.messagingFake.fcmToken) + XCTAssertNil(error) + expectation.fulfill() + } + waitForExpectations(timeout: 0.1) + } + + func testContextWithAuthError() { + let authError = NSError(domain: "com.functions.tests", code: 4, userInfo: nil) + let auth = FIRAuthInteropFake(token: nil, userID: "userID", error: authError) + let provider = FunctionsContextProvider(auth: auth, messaging: messagingFake, appCheck: nil) + let expectation = expectation(description: "Completion handler should fail with Auth error.") + provider.getContext { context, error in + XCTAssertNotNil(context) + XCTAssertNil(context.authToken) + XCTAssertEqual(error as NSError?, authError) + expectation.fulfill() + } + waitForExpectations(timeout: 0.1) + } + + func testContextWithoutAuth() { + let provider = FunctionsContextProvider(auth: nil, messaging: nil, appCheck: nil) + let expectation = expectation(description: "Completion handler should succeed without Auth.") + provider.getContext { context, error in + XCTAssertNotNil(context) + XCTAssertNil(error) + XCTAssertNil(context.authToken) + XCTAssertNil(context.fcmToken) + expectation.fulfill() + } + waitForExpectations(timeout: 0.1) + } + + func testContextWithAppCheckOnlySuccess() { + appCheckFake.tokenResult = appCheckTokenSuccess + let provider = FunctionsContextProvider(auth: nil, messaging: nil, appCheck: appCheckFake) + let expectation = expectation(description: "Verify app check.") + provider.getContext { context, error in + XCTAssertNotNil(context) + XCTAssertNil(error) + XCTAssertNil(context.authToken) + XCTAssertNil(context.fcmToken) + XCTAssertEqual(context.appCheckToken, self.appCheckTokenSuccess.token) + expectation.fulfill() + } + waitForExpectations(timeout: 0.1) + } + + func testContextWithAppCheckOnlyError() { + appCheckFake.tokenResult = appCheckTokenError + let provider = FunctionsContextProvider(auth: nil, messaging: nil, appCheck: appCheckFake) + let expectation = expectation(description: "Verify bad app check token") + provider.getContext { context, error in + XCTAssertNotNil(context) + XCTAssertNil(error) + XCTAssertNil(context.authToken) + XCTAssertNil(context.fcmToken) + // Don't expect any token in the case of App Check error. + XCTAssertNil(context.appCheckToken) + expectation.fulfill() + } + waitForExpectations(timeout: 0.1) + } + + func testAllContextsAvailableSuccess() { + appCheckFake.tokenResult = appCheckTokenSuccess + let auth = FIRAuthInteropFake(token: "token", userID: "userID", error: nil) + let provider = FunctionsContextProvider( + auth: auth, + messaging: messagingFake, + appCheck: appCheckFake + ) + let expectation = expectation(description: "All contexts available") + provider.getContext { context, error in + XCTAssertNotNil(context) + XCTAssertNil(error) + XCTAssertEqual(context.authToken, "token") + XCTAssertEqual(context.fcmToken, self.messagingFake.fcmToken) + XCTAssertEqual(context.appCheckToken, self.appCheckTokenSuccess.token) + expectation.fulfill() + } + waitForExpectations(timeout: 0.1) + } + + func testAllContextsAuthAndAppCheckError() { + appCheckFake.tokenResult = appCheckTokenError + let authError = NSError(domain: "com.functions.tests", code: 4, userInfo: nil) + let auth = FIRAuthInteropFake(token: nil, userID: "userID", error: authError) + let provider = FunctionsContextProvider( + auth: auth, + messaging: messagingFake, + appCheck: appCheckFake + ) + let expectation = expectation(description: "All contexts with errors") + provider.getContext { context, error in + XCTAssertNotNil(context) + XCTAssertEqual(error as NSError?, authError) + XCTAssertNil(context.authToken) + XCTAssertEqual(context.fcmToken, self.messagingFake.fcmToken) + // Don't expect any token in the case of App Check error. + XCTAssertNil(context.appCheckToken) + expectation.fulfill() + } + waitForExpectations(timeout: 0.1) + } +} diff --git a/FirebaseMessaging.podspec b/FirebaseMessaging.podspec index fc0cc26aaa..fc5941476d 100644 --- a/FirebaseMessaging.podspec +++ b/FirebaseMessaging.podspec @@ -37,6 +37,7 @@ device, and it is completely free. s.source_files = [ base_dir + 'Sources/**/*', base_dir + 'Sources/Protogen/nanopb/*.h', + base_dir + 'Interop/*.h', 'Interop/Analytics/Public/*.h', 'FirebaseCore/Internal/*.h', 'FirebaseInstallations/Source/Library/Private/*.h', diff --git a/FirebaseMessaging/Sources/Interop/FIRMessagingInterop.h b/FirebaseMessaging/Interop/FIRMessagingInterop.h similarity index 95% rename from FirebaseMessaging/Sources/Interop/FIRMessagingInterop.h rename to FirebaseMessaging/Interop/FIRMessagingInterop.h index 5e0a2556e8..5404443152 100644 --- a/FirebaseMessaging/Sources/Interop/FIRMessagingInterop.h +++ b/FirebaseMessaging/Interop/FIRMessagingInterop.h @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN /** Connector for bridging communication between Firebase SDKs and FIRMessaging API. */ -@protocol FIRMessagingInterop +NS_SWIFT_NAME(MessagingInterop) @protocol FIRMessagingInterop /** * The FCM registration token is used to identify this device so that FCM can send notifications to diff --git a/FirebaseMessaging/Interop/dummy.m b/FirebaseMessaging/Interop/dummy.m new file mode 100644 index 0000000000..2e503fe69d --- /dev/null +++ b/FirebaseMessaging/Interop/dummy.m @@ -0,0 +1,17 @@ +/* + * 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. + */ + +// Swift Package Manager needs at least one source file. diff --git a/FirebaseMessaging/Sources/FIRMessaging.m b/FirebaseMessaging/Sources/FIRMessaging.m index d9837f9df4..6918214480 100644 --- a/FirebaseMessaging/Sources/FIRMessaging.m +++ b/FirebaseMessaging/Sources/FIRMessaging.m @@ -26,6 +26,7 @@ #import #import "FirebaseCore/Internal/FirebaseCoreInternal.h" #import "FirebaseInstallations/Source/Library/Private/FirebaseInstallationsInternal.h" +#import "FirebaseMessaging/Interop/FIRMessagingInterop.h" #import "FirebaseMessaging/Sources/FIRMessagingAnalytics.h" #import "FirebaseMessaging/Sources/FIRMessagingCode.h" #import "FirebaseMessaging/Sources/FIRMessagingConstants.h" @@ -38,7 +39,6 @@ #import "FirebaseMessaging/Sources/FIRMessagingSyncMessageManager.h" #import "FirebaseMessaging/Sources/FIRMessagingUtilities.h" #import "FirebaseMessaging/Sources/FIRMessaging_Private.h" -#import "FirebaseMessaging/Sources/Interop/FIRMessagingInterop.h" #import "FirebaseMessaging/Sources/NSError+FIRMessaging.h" #import "FirebaseMessaging/Sources/Public/FirebaseMessaging/FIRMessagingExtensionHelper.h" #import "FirebaseMessaging/Sources/Token/FIRMessagingAuthService.h" diff --git a/FirebaseMessagingInterop.podspec b/FirebaseMessagingInterop.podspec new file mode 100644 index 0000000000..899dd250a4 --- /dev/null +++ b/FirebaseMessagingInterop.podspec @@ -0,0 +1,30 @@ +Pod::Spec.new do |s| + s.name = 'FirebaseMessagingInterop' + s.version = '8.12.0' + s.summary = 'Interfaces that allow other Firebase SDKs to use Messaging functionality.' + + s.description = <<-DESC + Not for public use. + A set of protocols that other Firebase SDKs can use to interoperate with FirebaseMessaging in a safe + and reliable manner. + DESC + + s.homepage = 'https://firebase.google.com' + s.license = { :type => 'Apache', :file => 'LICENSE' } + s.authors = 'Google, Inc.' + + # NOTE that these should not be used externally, this is for Firebase pods to depend on each + # other. + s.source = { + :git => 'https://github.com/firebase/firebase-ios-sdk.git', + :tag => 'CocoaPods-' + s.version.to_s + } + s.social_media_url = 'https://twitter.com/Firebase' + s.ios.deployment_target = '10.0' + s.osx.deployment_target = '10.12' + s.tvos.deployment_target = '10.0' + s.watchos.deployment_target = '6.0' + + s.source_files = 'FirebaseMessaging/Interop/*.[hm]' + s.public_header_files = 'FirebaseMessaging/Interop/*.h' +end diff --git a/FirebaseStorage.podspec b/FirebaseStorage.podspec index b2d22d7958..2ed783e2ca 100644 --- a/FirebaseStorage.podspec +++ b/FirebaseStorage.podspec @@ -32,7 +32,7 @@ Firebase Storage provides robust, secure file uploads and downloads from Firebas s.source_files = [ 'FirebaseStorage/Sources/**/*.[mh]', - 'Interop/Auth/Public/*.h', + 'FirebaseAuth/Interop/*.h', 'FirebaseCore/Internal/*.h', 'FirebaseAppCheck/Interop/*.h', ] diff --git a/FirebaseStorage/Sources/FIRStorage.m b/FirebaseStorage/Sources/FIRStorage.m index 7675a53e47..508afafc94 100644 --- a/FirebaseStorage/Sources/FIRStorage.m +++ b/FirebaseStorage/Sources/FIRStorage.m @@ -24,8 +24,8 @@ #import "FirebaseStorage/Sources/FIRStorage_Private.h" #import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseCore/Internal/FirebaseCoreInternal.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" #if SWIFT_PACKAGE @import GTMSessionFetcherCore; diff --git a/FirebaseStorage/Sources/FIRStorageComponent.m b/FirebaseStorage/Sources/FIRStorageComponent.m index 0265ade32e..7e4bf9af37 100644 --- a/FirebaseStorage/Sources/FIRStorageComponent.m +++ b/FirebaseStorage/Sources/FIRStorageComponent.m @@ -17,8 +17,8 @@ #import "FirebaseStorage/Sources/Public/FirebaseStorage/FIRStorage.h" #import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseCore/Internal/FirebaseCoreInternal.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" NS_ASSUME_NONNULL_BEGIN diff --git a/FirebaseStorage/Sources/FIRStorageTokenAuthorizer.m b/FirebaseStorage/Sources/FIRStorageTokenAuthorizer.m index 3c1aa5126e..f1f7016bc5 100644 --- a/FirebaseStorage/Sources/FIRStorageTokenAuthorizer.m +++ b/FirebaseStorage/Sources/FIRStorageTokenAuthorizer.m @@ -25,7 +25,7 @@ #import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h" #import "FirebaseAppCheck/Interop/FIRAppCheckTokenResultInterop.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" static NSString *const kAppCheckTokenHeader = @"X-Firebase-AppCheck"; static NSString *const kAuthHeader = @"Authorization"; diff --git a/Firestore/Source/API/FSTFirestoreComponent.mm b/Firestore/Source/API/FSTFirestoreComponent.mm index 1d5eec235f..cea6a8b3db 100644 --- a/Firestore/Source/API/FSTFirestoreComponent.mm +++ b/Firestore/Source/API/FSTFirestoreComponent.mm @@ -21,6 +21,7 @@ #include #import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #import "FirebaseCore/Internal/FIRAppInternal.h" #import "FirebaseCore/Internal/FIRComponent.h" #import "FirebaseCore/Internal/FIRComponentContainer.h" @@ -29,7 +30,6 @@ #import "FirebaseCore/Internal/FIRLibrary.h" #import "FirebaseCore/Internal/FIROptionsInternal.h" #import "Firestore/Source/API/FIRFirestore+Internal.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" #include "Firestore/core/include/firebase/firestore/firestore_version.h" #include "Firestore/core/src/api/firestore.h" diff --git a/Firestore/core/src/credentials/firebase_auth_credentials_provider_apple.mm b/Firestore/core/src/credentials/firebase_auth_credentials_provider_apple.mm index c9ee782ba7..aea4a273f6 100644 --- a/Firestore/core/src/credentials/firebase_auth_credentials_provider_apple.mm +++ b/Firestore/core/src/credentials/firebase_auth_credentials_provider_apple.mm @@ -18,7 +18,7 @@ #import "FirebaseCore/Internal/FIRAppInternal.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #include "Firestore/core/src/util/error_apple.h" #include "Firestore/core/src/util/hard_assert.h" diff --git a/Firestore/core/test/unit/credentials/firebase_auth_credentials_provider_test.mm b/Firestore/core/test/unit/credentials/firebase_auth_credentials_provider_test.mm index dc5162ae3f..fd735b8f72 100644 --- a/Firestore/core/test/unit/credentials/firebase_auth_credentials_provider_test.mm +++ b/Firestore/core/test/unit/credentials/firebase_auth_credentials_provider_test.mm @@ -20,7 +20,7 @@ #include // NOLINT(build/c++11) #include -#import "Interop/Auth/Public/FIRAuthInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" #include "Firestore/core/src/util/statusor.h" #include "Firestore/core/src/util/string_apple.h" diff --git a/HeadersImports.md b/HeadersImports.md index 37a2307db8..748d6a5e51 100644 --- a/HeadersImports.md +++ b/HeadersImports.md @@ -51,7 +51,7 @@ In Swift Package Manager, it's a library target. added to the podspec in the `source_files` attribute like: ``` s.source_files = [ 'FirebaseFoo/Sources/**/*.[mh]' - 'Interop/Auth/Public/*.h', + 'FirebaseAuth/Interop/*.h', 'FirebaseCore/Internal/*.h', ] ``` diff --git a/Package.swift b/Package.swift index 0bfbe40a65..ca8007c2b1 100644 --- a/Package.swift +++ b/Package.swift @@ -407,6 +407,18 @@ let package = Package( .linkedFramework("SafariServices", .when(platforms: [.iOS])), ] ), + // Internal headers only for consuming from Swift. + .target( + name: "FirebaseAuthInterop", + path: "FirebaseAuth/Interop", + exclude: [ + "CMakeLists.txt", + ], + publicHeadersPath: ".", + cSettings: [ + .headerSearchPath("../../"), + ] + ), .testTarget( name: "AuthUnit", dependencies: ["FirebaseAuth", "OCMock"], @@ -699,8 +711,10 @@ let package = Package( name: "FirebaseFunctionsSwift", dependencies: [ "FirebaseAppCheckInterop", + "FirebaseAuthInterop", "FirebaseCore", "FirebaseCoreInternal", + "FirebaseMessagingInterop", "FirebaseSharedSwift", .product(name: "GTMSessionFetcherCore", package: "GTMSessionFetcher"), ], @@ -892,6 +906,15 @@ let package = Package( .linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])), ] ), + // Internal headers only for consuming from Swift. + .target( + name: "FirebaseMessagingInterop", + path: "FirebaseMessaging/Interop", + publicHeadersPath: ".", + cSettings: [ + .headerSearchPath("../../"), + ] + ), .testTarget( name: "MessagingUnit", dependencies: ["FirebaseMessaging", "SharedTestUtilities", "OCMock"], diff --git a/SharedTestUtilities/FIRAuthInteropFake.h b/SharedTestUtilities/FIRAuthInteropFake.h index 1c15312547..dd5d0d82ab 100644 --- a/SharedTestUtilities/FIRAuthInteropFake.h +++ b/SharedTestUtilities/FIRAuthInteropFake.h @@ -16,7 +16,7 @@ #import -#import "Interop/Auth/Public/FIRAuthInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" NS_ASSUME_NONNULL_BEGIN diff --git a/SharedTestUtilities/FIRAuthInteropFake.m b/SharedTestUtilities/FIRAuthInteropFake.m index 679dd3e8be..2b66411bd8 100644 --- a/SharedTestUtilities/FIRAuthInteropFake.m +++ b/SharedTestUtilities/FIRAuthInteropFake.m @@ -16,7 +16,7 @@ #import "SharedTestUtilities/FIRAuthInteropFake.h" -#import "Interop/Auth/Public/FIRAuthInterop.h" +#import "FirebaseAuth/Interop/FIRAuthInterop.h" NS_ASSUME_NONNULL_BEGIN diff --git a/SharedTestUtilities/FIRMessagingInteropFake.h b/SharedTestUtilities/FIRMessagingInteropFake.h index b40d80469f..56ef0dd918 100644 --- a/SharedTestUtilities/FIRMessagingInteropFake.h +++ b/SharedTestUtilities/FIRMessagingInteropFake.h @@ -16,7 +16,7 @@ #import -#import "FirebaseMessaging/Sources/Interop/FIRMessagingInterop.h" +#import "FirebaseMessaging/Interop/FIRMessagingInterop.h" NS_ASSUME_NONNULL_BEGIN diff --git a/scripts/health_metrics/file_patterns.json b/scripts/health_metrics/file_patterns.json index 9f856ce437..30bcfb1617 100644 --- a/scripts/health_metrics/file_patterns.json +++ b/scripts/health_metrics/file_patterns.json @@ -36,7 +36,7 @@ "podspecs": ["FirebaseAuth.podspec"], "filePatterns": [ "^FirebaseAuth.*", - "Interop/Auth/Public/[^/]+\\.h", + "FirebaseAuth/Interop/[^/]+\\.h", "\\.github/workflows/auth\\.yml" ] }, @@ -73,7 +73,7 @@ "^FirebaseDatabase.*", "\\.github/workflows/database\\.yml", "Example/Database/", - "Interop/Auth/Public/[^/]+\\.h" + "FirebaseAuth/Interop/[^/]+\\.h" ] }, { @@ -100,7 +100,7 @@ "filePatterns": [ "^Firestore/.*", "FirebaseAppCheck/Interop/[^/]+\\.h", - "Interop/Auth/Public/[^/]+\\.h", + "FirebaseAuth/Interop/[^/]+\\.h", "FirebaseCore/Internal", "FirebaseCore/Sources/Public", "FirebaseFirestore\\.podspec", @@ -115,8 +115,8 @@ "filePatterns": [ "^Functions.*", "\\.github/workflows/functions\\.yml", - "Interop/Auth/Public/.*\\.h", - "FirebaseMessaging/Sources/Interop/[^/]+\\.h" + "FirebaseAuth/Interop/.*\\.h", + "FirebaseMessaging/Interop/[^/]+\\.h" ] }, { @@ -191,7 +191,7 @@ "podspecs": ["FirebaseStorage.podspec", "FirebaseStorageSwift.podspec"], "filePatterns": [ "^FirebaseStorage.*", - "Interop/Auth/Public/[^/]+\\.h", + "FirebaseAuth/Interop/[^/]+\\.h", "\\.github/workflows/storage\\.yml" ] }