diff --git a/AddNewPod.md b/AddNewPod.md index 6f9d544b14..8c0d0ce576 100644 --- a/AddNewPod.md +++ b/AddNewPod.md @@ -13,8 +13,6 @@ detailed instructions. Some Firebase specific guidance below: * `s.deployment_target` - Ideally should include ios, osx, and tvos. See [FirebaseCore.podspec](FirebaseCore.podspec) for the current Firebase minimum version settings. -* `s.static_framework` - By default, Firebase pods should be static frameworks. - * `s.dependency` - Dependencies on other Firebase pods and pods in this repo should specify a version and allow minor version updates - like `s.dependency 'FirebaseCore', '~> 6.6'`. When initially defined, choose the most recently released minor version of the dependency. diff --git a/FirebaseABTesting.podspec b/FirebaseABTesting.podspec index 18b327a8cf..dd4b84adfa 100644 --- a/FirebaseABTesting.podspec +++ b/FirebaseABTesting.podspec @@ -25,7 +25,6 @@ Firebase Cloud Messaging and Firebase Remote Config in your app. s.tvos.deployment_target = '10.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false base_dir = "FirebaseABTesting/Sources/" diff --git a/FirebaseAppDistribution.podspec b/FirebaseAppDistribution.podspec index 2d04b22ad8..16f56d867a 100644 --- a/FirebaseAppDistribution.podspec +++ b/FirebaseAppDistribution.podspec @@ -18,7 +18,6 @@ iOS SDK for App Distribution for Firebase. s.ios.deployment_target = '10.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false base_dir = "FirebaseAppDistribution/Sources/" diff --git a/FirebaseAuth.podspec b/FirebaseAuth.podspec index 35f07b97d3..adea669079 100644 --- a/FirebaseAuth.podspec +++ b/FirebaseAuth.podspec @@ -23,7 +23,6 @@ supports email and password accounts, as well as several 3rd party authenticatio s.watchos.deployment_target = '6.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false source = 'FirebaseAuth/Sources/' diff --git a/FirebaseCore.podspec b/FirebaseCore.podspec index eb327f0a86..cc24878cbd 100644 --- a/FirebaseCore.podspec +++ b/FirebaseCore.podspec @@ -22,7 +22,6 @@ Firebase Core includes FIRApp and FIROptions which provide central configuration s.watchos.deployment_target = '6.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false s.source_files = [ @@ -54,7 +53,10 @@ Firebase Core includes FIRApp and FIROptions which provide central configuration } s.test_spec 'unit' do |unit_tests| unit_tests.platforms = {:ios => '8.0', :osx => '10.11', :tvos => '10.0'} - unit_tests.source_files = 'FirebaseCore/Tests/Unit/**/*.[mh]' + unit_tests.source_files = [ + 'FirebaseCore/Tests/Unit/**/*.[mh]', + 'SharedTestUtilities/FIROptionsMock.[mh]', + ] unit_tests.requires_app_host = true unit_tests.dependency 'OCMock' unit_tests.resources = 'FirebaseCore/Tests/Unit/Resources/GoogleService-Info.plist' @@ -62,12 +64,16 @@ Firebase Core includes FIRApp and FIROptions which provide central configuration s.test_spec 'swift-unit' do |swift_unit_tests| swift_unit_tests.platforms = {:ios => '8.0', :osx => '10.11', :tvos => '10.0'} - swift_unit_tests.source_files = 'FirebaseCore/Tests/SwiftUnit/**/*.swift', - 'FirebaseCore/Tests/SwiftUnit/**/*.h', - 'FirebaseCore/Tests/SwiftUnit/SwiftTestingUtilities/*' - swift_unit_tests.resources = 'FirebaseCore/Tests/Unit/Resources/GoogleService-Info.plist' + swift_unit_tests.source_files = [ + 'FirebaseCore/Tests/SwiftUnit/**/*.swift', + 'FirebaseCore/Tests/SwiftUnit/**/*.h', + 'FirebaseCore/Tests/SwiftUnit/SwiftTestingUtilities/*', + 'SharedTestUtilities/FIROptionsMock.[mh]', + ] swift_unit_tests.pod_target_xcconfig = { 'SWIFT_OBJC_BRIDGING_HEADER' => '$(PODS_TARGET_SRCROOT)/FirebaseCore/Tests/SwiftUnit/FirebaseCore-unit-Bridging-Header.h' } + swift_unit_tests.dependency 'OCMock' + swift_unit_tests.resources = 'FirebaseCore/Tests/Unit/Resources/GoogleService-Info.plist' end end diff --git a/FirebaseCore/CHANGELOG.md b/FirebaseCore/CHANGELOG.md index 5180fb0d88..47b65a2272 100644 --- a/FirebaseCore/CHANGELOG.md +++ b/FirebaseCore/CHANGELOG.md @@ -2,6 +2,9 @@ - [changed] Update minimum iOS version to iOS 10 except for Analytics which is now iOS 9. (#4847) - [changed] Update minimum macOS version to 10.12. - [added] Swift Package Manager support for Firebase Messaging. (#5641) +- [changed] The pods developed in this repo are no longer hard coded to be built as static + frameworks. Instead, their linkage will be controlled by the Podfile. Use the Podfile + option `use_frameworks! :linkage => :static` to get the Firebase 6.x linkage behavior. (#2022) # Firebase 6.33.0 - [fixed] Swift Package Manager - Define system framework and system library dependencies. This diff --git a/FirebaseCore/Tests/SwiftUnit/FirebaseAppTests.swift b/FirebaseCore/Tests/SwiftUnit/FirebaseAppTests.swift index 5fecaa6cb2..d90af3aba3 100644 --- a/FirebaseCore/Tests/SwiftUnit/FirebaseAppTests.swift +++ b/FirebaseCore/Tests/SwiftUnit/FirebaseAppTests.swift @@ -23,6 +23,7 @@ private extension Constants { class FirebaseAppTests: XCTestCase { override func setUp() { super.setUp() + FIROptionsMock.mockFIROptions() } override func tearDown() { diff --git a/FirebaseCore/Tests/SwiftUnit/FirebaseCore-unit-Bridging-Header.h b/FirebaseCore/Tests/SwiftUnit/FirebaseCore-unit-Bridging-Header.h index d4acabe095..4816efda40 100644 --- a/FirebaseCore/Tests/SwiftUnit/FirebaseCore-unit-Bridging-Header.h +++ b/FirebaseCore/Tests/SwiftUnit/FirebaseCore-unit-Bridging-Header.h @@ -14,3 +14,4 @@ #import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h" #import "FirebaseCore/Tests/SwiftUnit/SwiftTestingUtilities/ExceptionCatcher.h" +#import "SharedTestUtilities/FIROptionsMock.h" diff --git a/FirebaseCore/Tests/Unit/FIRAppTest.m b/FirebaseCore/Tests/Unit/FIRAppTest.m index 17a0aef3d8..7be2cf2773 100644 --- a/FirebaseCore/Tests/Unit/FIRAppTest.m +++ b/FirebaseCore/Tests/Unit/FIRAppTest.m @@ -19,8 +19,8 @@ #import "FirebaseCore/Sources/Private/FIRAppInternal.h" #import "FirebaseCore/Sources/Private/FIRCoreDiagnosticsConnector.h" #import "FirebaseCore/Sources/Private/FIROptionsInternal.h" - #import "GoogleUtilities/Environment/Private/GULAppEnvironmentUtil.h" +#import "SharedTestUtilities/FIROptionsMock.h" NSString *const kFIRTestAppName1 = @"test_app_name_1"; NSString *const kFIRTestAppName2 = @"test-app-name-2"; @@ -68,9 +68,7 @@ NSString *const kFIRTestAppName2 = @"test-app-name-2"; _observerMock = OCMObserverMock(); _mockCoreDiagnosticsConnector = OCMClassMock([FIRCoreDiagnosticsConnector class]); -#if SWIFT_PACKAGE - [self mockFIROptions]; -#endif + [FIROptionsMock mockFIROptions]; OCMStub(ClassMethod([self.mockCoreDiagnosticsConnector logCoreTelemetryWithOptions:[OCMArg any]])) .andDo(^(NSInvocation *invocation){ diff --git a/FirebaseCore/Tests/Unit/FIRBundleUtilTest.m b/FirebaseCore/Tests/Unit/FIRBundleUtilTest.m index 5b8c652ceb..b0e414c88d 100644 --- a/FirebaseCore/Tests/Unit/FIRBundleUtilTest.m +++ b/FirebaseCore/Tests/Unit/FIRBundleUtilTest.m @@ -16,6 +16,7 @@ #import "FirebaseCore/Sources/FIRBundleUtil.h" #import "GoogleUtilities/Environment/Private/GULAppEnvironmentUtil.h" +#import "SharedTestUtilities/FIROptionsMock.h" static NSString *const kResultPath = @"resultPath"; static NSString *const kResourceName = @"resourceName"; diff --git a/FirebaseCore/Tests/Unit/FIRComponentContainerTest.m b/FirebaseCore/Tests/Unit/FIRComponentContainerTest.m index cedb2d6fdd..86e492ac16 100644 --- a/FirebaseCore/Tests/Unit/FIRComponentContainerTest.m +++ b/FirebaseCore/Tests/Unit/FIRComponentContainerTest.m @@ -16,8 +16,8 @@ #import "FirebaseCore/Sources/FIRComponentContainerInternal.h" #import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h" - #import "FirebaseCore/Tests/Unit/FIRTestComponents.h" +#import "SharedTestUtilities/FIROptionsMock.h" /// Internally exposed methods and properties for testing. @interface FIRComponentContainer (TestInternal) diff --git a/FirebaseCore/Tests/Unit/FIROptionsTest.m b/FirebaseCore/Tests/Unit/FIROptionsTest.m index 0ad93652d8..23c924d73a 100644 --- a/FirebaseCore/Tests/Unit/FIROptionsTest.m +++ b/FirebaseCore/Tests/Unit/FIROptionsTest.m @@ -18,6 +18,7 @@ #import "FirebaseCore/Sources/FIRVersion.h" #import "FirebaseCore/Sources/Private/FIRAppInternal.h" #import "FirebaseCore/Sources/Private/FIROptionsInternal.h" +#import "SharedTestUtilities/FIROptionsMock.h" extern NSString *const kFIRIsMeasurementEnabled; extern NSString *const kFIRIsAnalyticsCollectionEnabled; @@ -43,9 +44,7 @@ extern NSString *const kFIRLibraryVersionID; } - (void)testInit { -#if SWIFT_PACKAGE - [self mockFIROptions]; -#endif + [FIROptionsMock mockFIROptions]; NSDictionary *optionsDictionary = [FIROptions defaultOptionsDictionary]; FIROptions *options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary]; [self assertOptionsMatchDefaults:options andProjectID:YES]; @@ -75,9 +74,7 @@ extern NSString *const kFIRLibraryVersionID; } - (void)testDefaultOptions { -#if SWIFT_PACKAGE - [self mockFIROptions]; -#endif + [FIROptionsMock mockFIROptions]; FIROptions *options = [FIROptions defaultOptions]; [self assertOptionsMatchDefaults:options andProjectID:YES]; XCTAssertNil(options.deepLinkURLScheme); @@ -242,9 +239,7 @@ extern NSString *const kFIRLibraryVersionID; } - (void)testCopyWithZone { -#if SWIFT_PACKAGE - [self mockFIROptions]; -#endif + [FIROptionsMock mockFIROptions]; // default options FIROptions *options = [FIROptions defaultOptions]; options.deepLinkURLScheme = kDeepLinkURLScheme; diff --git a/FirebaseCore/Tests/Unit/FIRTestCase.h b/FirebaseCore/Tests/Unit/FIRTestCase.h index 616f277144..052f918c81 100644 --- a/FirebaseCore/Tests/Unit/FIRTestCase.h +++ b/FirebaseCore/Tests/Unit/FIRTestCase.h @@ -17,29 +17,8 @@ #import #import "OCMock.h" -NS_ASSUME_NONNULL_BEGIN - -extern NSString *const kAPIKey; -extern NSString *const kCustomizedAPIKey; -extern NSString *const kClientID; -extern NSString *const kTrackingID; -extern NSString *const kGCMSenderID; -extern NSString *const kAndroidClientID; -extern NSString *const kGoogleAppID; -extern NSString *const kDatabaseURL; -extern NSString *const kStorageBucket; - -extern NSString *const kDeepLinkURLScheme; -extern NSString *const kNewDeepLinkURLScheme; - -extern NSString *const kBundleID; -extern NSString *const kProjectID; - /** * Base test case for Firebase Core SDK tests. */ @interface FIRTestCase : XCTestCase -- (void)mockFIROptions; @end - -NS_ASSUME_NONNULL_END diff --git a/FirebaseCore/Tests/Unit/FIRTestCase.m b/FirebaseCore/Tests/Unit/FIRTestCase.m index 69b908949c..3c17ef1e43 100644 --- a/FirebaseCore/Tests/Unit/FIRTestCase.m +++ b/FirebaseCore/Tests/Unit/FIRTestCase.m @@ -14,24 +14,6 @@ #import "FirebaseCore/Tests/Unit/FIRTestCase.h" -#import "FirebaseCore/Sources/Private/FIROptionsInternal.h" - -NSString *const kAndroidClientID = @"correct_android_client_id"; -NSString *const kAPIKey = @"correct_api_key"; -NSString *const kCustomizedAPIKey = @"customized_api_key"; -NSString *const kClientID = @"correct_client_id"; -NSString *const kTrackingID = @"correct_tracking_id"; -NSString *const kGCMSenderID = @"correct_gcm_sender_id"; -NSString *const kGoogleAppID = @"1:123:ios:123abc"; -NSString *const kDatabaseURL = @"https://abc-xyz-123.firebaseio.com"; -NSString *const kStorageBucket = @"project-id-123.storage.firebase.com"; - -NSString *const kDeepLinkURLScheme = @"comgoogledeeplinkurl"; -NSString *const kNewDeepLinkURLScheme = @"newdeeplinkurlfortest"; - -NSString *const kBundleID = @"com.google.FirebaseSDKTests"; -NSString *const kProjectID = @"abc-xyz-123"; - @interface FIRTestCase () @end @@ -42,34 +24,6 @@ NSString *const kProjectID = @"abc-xyz-123"; [super setUp]; } -// Swift Package manager does not allow a test project to override a bundle in an app (or library). -- (void)mockFIROptions { - // Keys for the strings in the plist file. - NSString *const kFIRAPIKey = @"API_KEY"; - NSString *const kFIRTrackingID = @"TRACKING_ID"; - NSString *const kFIRGoogleAppID = @"GOOGLE_APP_ID"; - NSString *const kFIRClientID = @"CLIENT_ID"; - NSString *const kFIRGCMSenderID = @"GCM_SENDER_ID"; - NSString *const kFIRDatabaseURL = @"DATABASE_URL"; - NSString *const kFIRStorageBucket = @"STORAGE_BUCKET"; - NSString *const kFIRBundleID = @"BUNDLE_ID"; - NSString *const kFIRProjectID = @"PROJECT_ID"; - - NSDictionary *mockDictionary = @{ - kFIRAPIKey : kAPIKey, - kFIRBundleID : kBundleID, - kFIRClientID : kClientID, - kFIRDatabaseURL : kDatabaseURL, - kFIRGCMSenderID : kGCMSenderID, - kFIRGoogleAppID : kGoogleAppID, - kFIRProjectID : kProjectID, - kFIRStorageBucket : kStorageBucket, - kFIRTrackingID : kTrackingID, - }; - id optionsClassMock = OCMClassMock([FIROptions class]); - OCMStub([optionsClassMock defaultOptionsDictionary]).andReturn(mockDictionary); -} - - (void)tearDown { [super tearDown]; } diff --git a/FirebaseCoreDiagnostics.podspec b/FirebaseCoreDiagnostics.podspec index 2a6699e081..93ef641948 100644 --- a/FirebaseCoreDiagnostics.podspec +++ b/FirebaseCoreDiagnostics.podspec @@ -24,7 +24,6 @@ non-Cocoapod integration. This library also respects the Firebase global data co s.watchos.deployment_target = '6.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false header_search_paths = { diff --git a/FirebaseCrashlytics.podspec b/FirebaseCrashlytics.podspec index f6baf1e929..f04bd22ef4 100644 --- a/FirebaseCrashlytics.podspec +++ b/FirebaseCrashlytics.podspec @@ -17,7 +17,6 @@ Pod::Spec.new do |s| s.watchos.deployment_target = '6.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false s.source_files = [ diff --git a/FirebaseDatabase.podspec b/FirebaseDatabase.podspec index ad2dde955f..318b98ecba 100644 --- a/FirebaseDatabase.podspec +++ b/FirebaseDatabase.podspec @@ -21,7 +21,6 @@ Simplify your iOS development, grow your user base, and monetize more effectivel s.tvos.deployment_target = '10.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false base_dir = "FirebaseDatabase/Sources/" @@ -44,19 +43,27 @@ Simplify your iOS development, grow your user base, and monetize more effectivel } s.test_spec 'unit' do |unit_tests| - unit_tests.source_files = 'FirebaseDatabase/Tests/Unit/*.[mh]', - 'FirebaseDatabase/Tests/Helpers/*.[mh]', - 'FirebaseDatabase/Tests/third_party/*.[mh]', - 'SharedTestUtilities/FIRAuthInteropFake.[mh]', - 'SharedTestUtilities/FIRComponentTestUtilities.h' + unit_tests.source_files = [ + 'FirebaseDatabase/Tests/Unit/*.[mh]', + 'FirebaseDatabase/Tests/Helpers/*.[mh]', + 'FirebaseDatabase/Tests/third_party/*.[mh]', + 'SharedTestUtilities/FIRAuthInteropFake.[mh]', + 'SharedTestUtilities/FIRComponentTestUtilities.h', + 'SharedTestUtilities/FIROptionsMock.[mh]', + ] + unit_tests.dependency 'OCMock' unit_tests.resources = 'FirebaseDatabase/Tests/Resources/syncPointSpec.json', 'FirebaseDatabase/Tests/Resources/GoogleService-Info.plist' end s.test_spec 'integration' do |int_tests| - int_tests.source_files = 'FirebaseDatabase/Tests/Integration/*.[mh]', - 'FirebaseDatabase/Tests/Helpers/*.[mh]', - 'SharedTestUtilities/FIRAuthInteropFake.[mh]' + int_tests.source_files = [ + 'FirebaseDatabase/Tests/Integration/*.[mh]', + 'FirebaseDatabase/Tests/Helpers/*.[mh]', + 'SharedTestUtilities/FIRAuthInteropFake.[mh]', + 'SharedTestUtilities/FIROptionsMock.[mh]', + ] + int_tests.dependency 'OCMock' int_tests.resources = 'FirebaseDatabase/Tests/Resources/GoogleService-Info.plist' end end diff --git a/FirebaseDatabase/Tests/Helpers/FTestBase.m b/FirebaseDatabase/Tests/Helpers/FTestBase.m index 51e7b17592..26349d485a 100644 --- a/FirebaseDatabase/Tests/Helpers/FTestBase.m +++ b/FirebaseDatabase/Tests/Helpers/FTestBase.m @@ -20,16 +20,15 @@ #import "FirebaseDatabase/Tests/Helpers/FIRTestAuthTokenProvider.h" #import "FirebaseDatabase/Tests/Helpers/FTestAuthTokenGenerator.h" #import "FirebaseDatabase/Tests/Helpers/FTestBase.h" +#import "SharedTestUtilities/FIROptionsMock.h" @implementation FTestBase + (void)setUp { static dispatch_once_t once; dispatch_once(&once, ^{ -#if !SWIFT_PACKAGE - // Disabled for now with SPM. configure is not needed for the unit tests. + [FIROptionsMock mockFIROptions]; [FIRApp configure]; -#endif }); } diff --git a/FirebaseDynamicLinks.podspec b/FirebaseDynamicLinks.podspec index 681fc2b2ac..d9c8a74ea9 100644 --- a/FirebaseDynamicLinks.podspec +++ b/FirebaseDynamicLinks.podspec @@ -19,7 +19,6 @@ Firebase Dynamic Links are deep links that enhance user experience and increase s.ios.deployment_target = '10.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false s.source_files = [ diff --git a/FirebaseFirestore.podspec b/FirebaseFirestore.podspec index 75844917b1..589b14b170 100644 --- a/FirebaseFirestore.podspec +++ b/FirebaseFirestore.podspec @@ -21,7 +21,6 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, s.tvos.deployment_target = '10.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false s.source_files = [ diff --git a/FirebaseFirestoreSwift.podspec b/FirebaseFirestoreSwift.podspec index 276ae0a05a..725ebd7f3e 100644 --- a/FirebaseFirestoreSwift.podspec +++ b/FirebaseFirestoreSwift.podspec @@ -27,7 +27,6 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling, s.tvos.deployment_target = '10.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false s.requires_arc = true diff --git a/FirebaseFunctions.podspec b/FirebaseFunctions.podspec index f1c1664da0..be2832f886 100644 --- a/FirebaseFunctions.podspec +++ b/FirebaseFunctions.podspec @@ -20,7 +20,6 @@ Cloud Functions for Firebase. s.tvos.deployment_target = '10.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false s.source_files = [ diff --git a/FirebaseInAppMessaging.podspec b/FirebaseInAppMessaging.podspec index 694d64bccc..4afd0ee5a0 100644 --- a/FirebaseInAppMessaging.podspec +++ b/FirebaseInAppMessaging.podspec @@ -20,7 +20,6 @@ See more product details at https://firebase.google.com/products/in-app-messagin s.ios.deployment_target = '10.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false base_dir = "FirebaseInAppMessaging/" diff --git a/FirebaseInAppMessaging/Sources/DefaultUI/FIRIAMDefaultDisplayImpl.m b/FirebaseInAppMessaging/Sources/DefaultUI/FIRIAMDefaultDisplayImpl.m index d58091bc7d..656c493f2a 100644 --- a/FirebaseInAppMessaging/Sources/DefaultUI/FIRIAMDefaultDisplayImpl.m +++ b/FirebaseInAppMessaging/Sources/DefaultUI/FIRIAMDefaultDisplayImpl.m @@ -53,14 +53,17 @@ + (NSBundle *)getViewResourceBundle { static NSBundle *resourceBundle; static dispatch_once_t onceToken; + Class myClass = [self class]; dispatch_once(&onceToken, ^{ - // TODO. This logic of finding the resource bundle may need to change once it's open - // sourced - NSBundle *containingBundle = [NSBundle mainBundle]; - // This is assuming the display resource bundle is contained in the main bundle - NSURL *bundleURL = [containingBundle URLForResource:@"InAppMessagingDisplayResources" - withExtension:@"bundle"]; + NSBundle *containingBundle; + NSURL *bundleURL; + // The containing bundle is different whether FIAM is statically or dynamically linked. + for (containingBundle in @[ [NSBundle mainBundle], [NSBundle bundleForClass:myClass] ]) { + bundleURL = [containingBundle URLForResource:@"InAppMessagingDisplayResources" + withExtension:@"bundle"]; + if (bundleURL != nil) break; + } if (bundleURL == nil) { FIRLogWarning(kFIRLoggerInAppMessagingDisplay, @"I-FID100007", @"FIAM Display Resource bundle " diff --git a/FirebaseInstallations.podspec b/FirebaseInstallations.podspec index 8c1e681b66..8153e10824 100644 --- a/FirebaseInstallations.podspec +++ b/FirebaseInstallations.podspec @@ -22,7 +22,6 @@ Pod::Spec.new do |s| s.watchos.deployment_target = '6.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false base_dir = "FirebaseInstallations/Source/" diff --git a/FirebaseInstanceID.podspec b/FirebaseInstanceID.podspec index edc10219d7..6cc4eedb03 100644 --- a/FirebaseInstanceID.podspec +++ b/FirebaseInstanceID.podspec @@ -24,7 +24,6 @@ services. s.watchos.deployment_target = '6.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false base_dir = "Firebase/InstanceID/" diff --git a/FirebaseMessaging.podspec b/FirebaseMessaging.podspec index 7fa7926a65..44effb298a 100644 --- a/FirebaseMessaging.podspec +++ b/FirebaseMessaging.podspec @@ -25,7 +25,6 @@ device, and it is completely free. s.watchos.deployment_target = '6.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false base_dir = "FirebaseMessaging/" diff --git a/FirebaseRemoteConfig.podspec b/FirebaseRemoteConfig.podspec index cefdcca934..226d1f9f16 100644 --- a/FirebaseRemoteConfig.podspec +++ b/FirebaseRemoteConfig.podspec @@ -23,7 +23,6 @@ app update. s.tvos.deployment_target = '10.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false base_dir = "FirebaseRemoteConfig/Sources/" diff --git a/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m b/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m index 4a7967230b..6b7a09193c 100644 --- a/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m +++ b/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m @@ -1143,22 +1143,42 @@ static NSString *UTCToLocal(NSString *utcTime) { return [dateFormatter stringFromDate:date]; } +// Manage different bundle locations for Swift Package Manager, CocoaPods static, CocoaPods dynamic. +- (void)setDefaultsFor:(FIRRemoteConfig *)config namespace:(NSString *)namespace { #if SWIFT_PACKAGE -- (NSDictionary *)getSPMDefaults { NSBundle *bundle = Firebase_RemoteConfigUnit_SWIFTPM_MODULE_BUNDLE(); NSString *plistFile = [bundle pathForResource:@"Defaults-testInfo" ofType:@"plist"]; - return [[NSDictionary alloc] initWithContentsOfFile:plistFile]; -} +#else + NSBundle *bundle = [NSBundle mainBundle]; + NSString *plistFile = [bundle pathForResource:@"Defaults-testInfo" ofType:@"plist"]; + if (plistFile != nil) { + if (namespace) { + [config setDefaultsFromPlistFileName:@"Defaults-testInfo" namespace:namespace]; + } else { + [config setDefaultsFromPlistFileName:@"Defaults-testInfo"]; + } + return; + } + // We've linked dynamically and the plist file is in the test's bundle. + for (bundle in [NSBundle allBundles]) { + plistFile = [bundle pathForResource:@"Defaults-testInfo" ofType:@"plist"]; + if (plistFile != nil) { + break; + } + } #endif + NSDictionary *defaults = [[NSDictionary alloc] initWithContentsOfFile:plistFile]; + if (namespace) { + [config setDefaults:defaults namespace:namespace]; + } else { + [config setDefaults:defaults]; + } +} - (void)testSetDefaultsFromPlist { for (int i = 0; i < RCNTestRCNumTotalInstances; i++) { FIRRemoteConfig *config = _configInstances[i]; -#if SWIFT_PACKAGE - [config setDefaults:[self getSPMDefaults]]; -#else - [config setDefaultsFromPlistFileName:@"Defaults-testInfo"]; -#endif + [self setDefaultsFor:config namespace:nil]; XCTAssertEqualObjects(_configInstances[i][@"lastCheckTime"].stringValue, UTCToLocal(@"2016-02-28 18:33:31")); XCTAssertEqual(_configInstances[i][@"isPaidUser"].boolValue, YES); @@ -1185,12 +1205,7 @@ static NSString *UTCToLocal(NSString *utcTime) { - (void)testSetDefaultsAndNamespaceFromPlist { for (int i = 0; i < RCNTestRCNumTotalInstances; i++) { if (i == RCNTestRCInstanceDefault) { -#if SWIFT_PACKAGE - [_configInstances[i] setDefaults:[self getSPMDefaults] namespace:RCNTestsPerfNamespace]; -#else - [_configInstances[i] setDefaultsFromPlistFileName:@"Defaults-testInfo" - namespace:RCNTestsPerfNamespace]; -#endif + [self setDefaultsFor:_configInstances[i] namespace:RCNTestsPerfNamespace]; XCTAssertEqualObjects([_configInstances[i] configValueForKey:@"lastCheckTime" namespace:RCNTestsPerfNamespace] .stringValue, diff --git a/FirebaseStorage.podspec b/FirebaseStorage.podspec index 5428aae1cb..3829e14a39 100644 --- a/FirebaseStorage.podspec +++ b/FirebaseStorage.podspec @@ -22,7 +22,6 @@ Firebase Storage provides robust, secure file uploads and downloads from Firebas s.watchos.deployment_target = '6.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false s.source_files = [ diff --git a/FirebaseStorageSwift.podspec b/FirebaseStorageSwift.podspec index 77230de35a..6a85d8f68b 100644 --- a/FirebaseStorageSwift.podspec +++ b/FirebaseStorageSwift.podspec @@ -24,7 +24,6 @@ Firebase Storage provides robust, secure file uploads and downloads from Firebas s.watchos.deployment_target = '6.0' s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false s.source_files = [ diff --git a/GoogleDataTransport.podspec b/GoogleDataTransport.podspec index a1d4d512ec..bc54dcb2cb 100644 --- a/GoogleDataTransport.podspec +++ b/GoogleDataTransport.podspec @@ -23,7 +23,6 @@ Shared library for iOS SDK data transport needs. # To develop or run the tests, >= 1.8.0 must be installed. s.cocoapods_version = '>= 1.4.0' - s.static_framework = true s.prefix_header_file = false s.source_files = ['GoogleDataTransport/GDTCORLibrary/**/*', diff --git a/GoogleUtilitiesComponents.podspec b/GoogleUtilitiesComponents.podspec index 964a0b9547..6cfb6528f2 100644 --- a/GoogleUtilitiesComponents.podspec +++ b/GoogleUtilitiesComponents.podspec @@ -24,7 +24,6 @@ Not intended for direct public usage. s.cocoapods_version = '>= 1.4.0' s.prefix_header_file = false - s.static_framework = true s.source_files = 'GoogleUtilitiesComponents/Sources/**/*.[mh]' s.public_header_files = 'GoogleUtilitiesComponents/Sources/Public/*.h', 'GoogleUtilitiesComponents/Sources/Private/*.h' diff --git a/Package.swift b/Package.swift index 299bb87c82..c68be59a68 100644 --- a/Package.swift +++ b/Package.swift @@ -156,7 +156,7 @@ let package = Package( ), .testTarget( name: "CoreUnit", - dependencies: ["FirebaseCore", "OCMock"], + dependencies: ["FirebaseCore", "SharedTestUtilities", "OCMock"], path: "FirebaseCore/Tests/Unit", exclude: ["Resources/GoogleService-Info.plist"], cSettings: [ @@ -555,7 +555,7 @@ let package = Package( .target( name: "SharedTestUtilities", - dependencies: ["FirebaseCore"], + dependencies: ["FirebaseCore", "OCMock"], path: "SharedTestUtilities", publicHeadersPath: "./", cSettings: [ diff --git a/SharedTestUtilities/FIROptionsMock.h b/SharedTestUtilities/FIROptionsMock.h new file mode 100644 index 0000000000..e31b92659e --- /dev/null +++ b/SharedTestUtilities/FIROptionsMock.h @@ -0,0 +1,45 @@ +/* + * 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 +#import "OCMock.h" + +NS_ASSUME_NONNULL_BEGIN + +extern NSString *const kAPIKey; +extern NSString *const kCustomizedAPIKey; +extern NSString *const kClientID; +extern NSString *const kTrackingID; +extern NSString *const kGCMSenderID; +extern NSString *const kAndroidClientID; +extern NSString *const kGoogleAppID; +extern NSString *const kDatabaseURL; +extern NSString *const kStorageBucket; + +extern NSString *const kDeepLinkURLScheme; +extern NSString *const kNewDeepLinkURLScheme; + +extern NSString *const kBundleID; +extern NSString *const kProjectID; + +/** + * Base test case for Firebase Core SDK tests. + */ +@interface FIROptionsMock : NSObject ++ (void)mockFIROptions; +@end + +NS_ASSUME_NONNULL_END diff --git a/SharedTestUtilities/FIROptionsMock.m b/SharedTestUtilities/FIROptionsMock.m new file mode 100644 index 0000000000..53642e15e2 --- /dev/null +++ b/SharedTestUtilities/FIROptionsMock.m @@ -0,0 +1,59 @@ +// 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 "OCMock.h" + +#import "FirebaseCore/Sources/Private/FIROptionsInternal.h" +#import "SharedTestUtilities/FIROptionsMock.h" + +NSString *const kAndroidClientID = @"correct_android_client_id"; +NSString *const kAPIKey = @"correct_api_key"; +NSString *const kCustomizedAPIKey = @"customized_api_key"; +NSString *const kClientID = @"correct_client_id"; +NSString *const kTrackingID = @"correct_tracking_id"; +NSString *const kGCMSenderID = @"correct_gcm_sender_id"; +NSString *const kGoogleAppID = @"1:123:ios:123abc"; +NSString *const kDatabaseURL = @"https://abc-xyz-123.firebaseio.com"; +NSString *const kStorageBucket = @"project-id-123.storage.firebase.com"; + +NSString *const kDeepLinkURLScheme = @"comgoogledeeplinkurl"; +NSString *const kNewDeepLinkURLScheme = @"newdeeplinkurlfortest"; + +NSString *const kBundleID = @"com.google.FirebaseSDKTests"; +NSString *const kProjectID = @"abc-xyz-123"; + +@interface FIROptionsMock () + +@end + +@implementation FIROptionsMock + +// Swift Package manager does not allow a test project to override a bundle in an app (or library). ++ (void)mockFIROptions { + NSDictionary *mockDictionary = @{ + kFIRAPIKey : kAPIKey, + kFIRBundleID : kBundleID, + kFIRClientID : kClientID, + kFIRDatabaseURL : kDatabaseURL, + kFIRGCMSenderID : kGCMSenderID, + kFIRGoogleAppID : kGoogleAppID, + kFIRProjectID : kProjectID, + kFIRStorageBucket : kStorageBucket, + kFIRTrackingID : kTrackingID, + }; + id optionsClassMock = OCMClassMock([FIROptions class]); + OCMStub([optionsClassMock defaultOptionsDictionary]).andReturn(mockDictionary); +} + +@end diff --git a/docs/firebase_in_libraries.md b/docs/firebase_in_libraries.md index 2345c3511a..d936df5222 100644 --- a/docs/firebase_in_libraries.md +++ b/docs/firebase_in_libraries.md @@ -1,7 +1,18 @@ +# Introduction + +Before the 7.0 release, all source code and binary Firebase SDKs are compiled as static frameworks. +With Firebase 7.0, CocoaPods developers can control whether Firebase is linked statically or +dynamically from the `Podfile`. Use the Podfile option `use_frameworks! :linkage => :static` to get +the Firebase 6.x linkage behavior. + +The zip and Carthage distributions continue to only be built for static linking. + +The Swift Package Manager distribution follows the Swift Package Manager defaults which is +currently static linking. + # Using Firebase from a framework or a library -Currently all source code and binary Firebase SDKs are compiled as static frameworks. Most -of the time you’ll link these frameworks directly to your app targets, but in some cases + Most of the time you’ll link Firebase frameworks directly to your app targets, but in some cases it makes sense to link Firebase frameworks to your app indirectly, from another library or another framework. This note talks about some of the pitfalls of this technique, almost always hard-to-debug undefined behaviors, that all come down to code duplication and how