Skip to content

Commit

Permalink
feat: Bump Firebase iOS SDK to 9.2.0 (#8594)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Jun 30, 2022
1 parent 4338b7c commit 7961016
Show file tree
Hide file tree
Showing 18 changed files with 206 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e_tests.yaml
Expand Up @@ -114,7 +114,7 @@ jobs:


ios:
runs-on: macos-latest
runs-on: macos-12
timeout-minutes: 45
steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion packages/cloud_firestore/cloud_firestore/example/ios/Podfile
Expand Up @@ -51,7 +51,8 @@ target 'Runner' do
end
end

pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => "#{firebase_sdk_version}"
# TODO - replace with #{firebase_sdk_version} once it has been released on: https://github.com/invertase/firestore-ios-sdk-frameworks.git
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :branch => 'main'
end

post_install do |installer|
Expand Down
Expand Up @@ -50,7 +50,8 @@ target 'Runner' do
end
end

pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => "#{firebase_sdk_version}"
# TODO - replace with #{firebase_sdk_version} once it has been released on: https://github.com/invertase/firestore-ios-sdk-frameworks.git
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :branch => 'main'
end

post_install do |installer|
Expand Down
Expand Up @@ -50,10 +50,17 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)flutter
NSMutableDictionary *httpsErrorDetails = [NSMutableDictionary dictionary];
NSString *httpsErrorCode = [NSString stringWithFormat:@"%ld", error.code];
NSString *httpsErrorMessage = error.localizedDescription;
if (error.domain == FIRFunctionsErrorDomain) {
// FIRFunctionsErrorDomain has been removed and replaced with Swift implementation
// https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseFunctions/Sources/FunctionsError.swift#L18
NSString *errorDomain = @"com.firebase.functions";
// FIRFunctionsErrorDetailsKey has been deprecated and replaced with Swift implementation
// https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseFunctions/Sources/FunctionsError.swift#L21
NSString *detailsKey = @"details";
// See also https://github.com/firebase/firebase-ios-sdk/pull/9569
if ([error.domain isEqualToString:errorDomain]) {
httpsErrorCode = [self mapFunctionsErrorCodes:error.code];
if (error.userInfo[FIRFunctionsErrorDetailsKey] != nil) {
httpsErrorDetails[@"additionalData"] = error.userInfo[FIRFunctionsErrorDetailsKey];
if (error.userInfo[detailsKey] != nil) {
httpsErrorDetails[@"additionalData"] = error.userInfo[detailsKey];
}
}
httpsErrorDetails[@"code"] = httpsErrorCode;
Expand Down Expand Up @@ -82,7 +89,8 @@ - (void)httpsFunctionCall:(id)arguments withMethodCallResult:(FLTFirebaseMethodC
FIRApp *app = [FLTFirebasePlugin firebaseAppNamed:appName];
FIRFunctions *functions = [FIRFunctions functionsForApp:app region:region];
if (origin != nil && origin != (id)[NSNull null]) {
[functions useFunctionsEmulatorOrigin:origin];
NSURL *url = [NSURL URLWithString:origin];
[functions useEmulatorWithHost:[url host] port:[[url port] intValue]];
}

FIRHTTPSCallable *function = [functions HTTPSCallableWithName:functionName];
Expand Down
Expand Up @@ -112,7 +112,8 @@ public class FirebaseInstallationsPluginSwift: FLTFirebasePlugin, FlutterPlugin
}

internal func mapInstallationsErrorCodes(code: UInt) -> NSString {
let error = InstallationsErrorCode(rawValue: code) ?? InstallationsErrorCode.unknown
let error = InstallationsErrorCode(InstallationsErrorCode
.Code(rawValue: Int(code)) ?? InstallationsErrorCode.unknown)

switch error {
case InstallationsErrorCode.invalidConfiguration:
Expand Down
Expand Up @@ -3,7 +3,14 @@
// found in the LICENSE file.

#import "FLTFirebasePluginRegistry.h"

#if __has_include(<FirebaseCore/FIRAppInternal.h>)
#import <FirebaseCore/FIRAppInternal.h>
#define REGISTER_LIB
#elif __has_include(<FirebaseCoreExtension/FIRAppInternal.h>)
#import <FirebaseCoreExtension/FIRAppInternal.h>
#define REGISTER_LIB
#endif

@implementation FLTFirebasePluginRegistry {
NSMutableDictionary<NSString *, id<FLTFirebasePlugin>> *registeredPlugins;
Expand All @@ -30,9 +37,10 @@ + (instancetype)sharedInstance {

- (void)registerFirebasePlugin:(id<FLTFirebasePlugin>)firebasePlugin {
// Register the library with the Firebase backend.
#ifdef REGISTER_LIB
[FIRApp registerLibrary:[firebasePlugin firebaseLibraryName]
withVersion:[firebasePlugin firebaseLibraryVersion]];

#endif
// Store the plugin delegate for later usage.
registeredPlugins[[firebasePlugin flutterChannelName]] = firebasePlugin;
}
Expand Down
@@ -1,4 +1,4 @@
# https://firebase.google.com/support/release-notes/ios
def firebase_sdk_version!()
'8.15.0'
'9.2.0'
end
Expand Up @@ -128,6 +128,17 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
code = errorDetails[kCode];
message = errorDetails[kMessage];
details = errorDetails;

if (errorDetails[@"additionalData"][NSLocalizedFailureReasonErrorKey] != nil) {
// This stops an uncaught type cast exception in dart
NSMutableDictionary *temp = [errorDetails[@"additionalData"] mutableCopy];
[temp removeObjectForKey:NSLocalizedFailureReasonErrorKey];
details = temp;
// provides a useful message to the user. e.g. "Universal link URL could not be parsed".
if ([message containsString:@"unknown error"]) {
message = errorDetails[@"additionalData"][NSLocalizedFailureReasonErrorKey];
}
}
} else {
details = @{
kCode : code,
Expand Down
Expand Up @@ -52,9 +52,7 @@ Pod::Spec.new do |s|

# Firebase dependencies
s.dependency 'Firebase/CoreOnly', "~> #{firebase_sdk_version}"
# TODO(Salakar): Direct pod depency here instead of the Firebase subspec due to:
# https://github.com/firebase/firebase-ios-sdk/pull/9186 (pending acceptance / merge)
s.dependency 'FirebaseMLModelDownloader', '~> 8.10.0-beta'
s.dependency 'Firebase/MLModelDownloader', firebase_sdk_version
s.static_framework = true
s.swift_version = '5.0'
s.pod_target_xcconfig = {
Expand Down
@@ -0,0 +1,41 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
Expand Up @@ -4,8 +4,8 @@
#import <TargetConditionals.h>

#import <Firebase/Firebase.h>
#import <FirebaseStorage/FIRStorageTypedefs.h>
#import <firebase_core/FLTFirebasePluginRegistry.h>

#import "FLTFirebaseStoragePlugin.h"

static NSString *const kFLTFirebaseStorageChannelName = @"plugins.flutter.io/firebase_storage";
Expand Down
3 changes: 2 additions & 1 deletion tests/ios/Podfile
Expand Up @@ -47,7 +47,8 @@ target 'Runner' do
end
end

pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => "#{firebase_sdk_version}"
# TODO - replace with #{firebase_sdk_version} once it has been released on: https://github.com/invertase/firestore-ios-sdk-frameworks.git
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :branch => 'main'
end

post_install do |installer|
Expand Down
44 changes: 26 additions & 18 deletions tests/ios/Runner.xcodeproj/project.pbxproj
Expand Up @@ -34,6 +34,7 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
29DCF5BB48C5B80F2EE02483 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
46682439286310F7005ADD39 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
56B65A6814148F63F80E1BCD /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -112,6 +113,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
46682439286310F7005ADD39 /* Runner.entitlements */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -139,8 +141,8 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
AC660AAB7696B4DD121B84D0 /* [CP] Embed Pods Frameworks */,
AFACAC31EEE064D50881C495 /* [CP] Copy Pods Resources */,
5F39B4E393588B005ADEE74A /* [firebase_crashlytics] Crashlytics Upload Symbols */,
570B63470F19A77487B49310 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -213,6 +215,23 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
570B63470F19A77487B49310 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
5F39B4E393588B005ADEE74A /* [firebase_crashlytics] Crashlytics Upload Symbols */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -286,23 +305,6 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
AFACAC31EEE064D50881C495 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -393,7 +395,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YYX2P3XVJ7;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -521,7 +525,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YYX2P3XVJ7;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -543,7 +549,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YYX2P3XVJ7;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
4 changes: 4 additions & 0 deletions tests/ios/Runner/Info.plist
Expand Up @@ -63,5 +63,9 @@
</array>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://flutterfiretests.page.link/**</string>
</array>
</dict>
</plist>
10 changes: 10 additions & 0 deletions tests/ios/Runner/Runner.entitlements
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:flutterfiretests.page.link</string>
</array>
</dict>
</plist>
3 changes: 2 additions & 1 deletion tests/macos/Podfile
Expand Up @@ -46,7 +46,8 @@ target 'Runner' do
end
end

pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => "#{firebase_sdk_version}"
# TODO - replace with #{firebase_sdk_version} once it has been released on: https://github.com/invertase/firestore-ios-sdk-frameworks.git
pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :branch => 'main'
end

post_install do |installer|
Expand Down
Expand Up @@ -134,12 +134,40 @@ void setupTests() {
});

group('getDynamicLink', () {
test('dynamic link using uri', () async {
Uri uri = Uri.parse('');
test('dynamic link using uri created on Firebase console', () async {
// Link created in Firebase console
Uri uri = Uri.parse('https://flutterfiretests.page.link/iho8');
PendingDynamicLinkData? pendingLink =
await FirebaseDynamicLinks.instance.getDynamicLink(uri);
expect(pendingLink, isNull);
expect(pendingLink, isA<PendingDynamicLinkData>());
expect(pendingLink?.link.toString(), 'https://example/helloworld');
});

test(
'Universal link error for URL that cannot be parsed',
() async {
Uri uri = Uri.parse('');
if (defaultTargetPlatform == TargetPlatform.iOS) {
await expectLater(
FirebaseDynamicLinks.instance.getDynamicLink(uri),
throwsA(
isA<FirebaseException>().having(
(e) => e.message,
'message',
contains('could not be parsed'),
),
),
);
} else if (defaultTargetPlatform == TargetPlatform.android) {
// TODO - android returns normally. Throw error to keep consistent with iOS or catch on iOS and return `null`.
// Internal ticket created: https://linear.app/invertase/issue/FF-44/dynamic-link-univeral-link-cannot-be-parsed
await expectLater(
FirebaseDynamicLinks.instance.getDynamicLink(uri),
completes,
);
}
},
);
});

group('onLink', () {
Expand Down

0 comments on commit 7961016

Please sign in to comment.