From d303314801b9be33b2598a85017fa55abd229115 Mon Sep 17 00:00:00 2001 From: Xilai Zhang Date: Tue, 29 Aug 2023 15:20:41 -0700 Subject: [PATCH] Revert "ios: remove shared_application and support app extension build (#44732)" This reverts commit 6ef35bb053149e573519b7e33ca9a660e10623f6. --- .../framework/Source/FlutterNSBundleUtils.h | 21 ++------- .../framework/Source/FlutterNSBundleUtils.mm | 47 ++++--------------- shell/platform/darwin/ios/BUILD.gn | 20 +------- .../ios/framework/Headers/FlutterPlugin.h | 3 +- .../framework/Source/FlutterDartProject.mm | 30 ++++++++---- .../Source/FlutterDartProjectTest.mm | 14 ------ .../ios/framework/Source/FlutterEngine.mm | 3 +- .../framework/Source/FlutterPlatformPlugin.mm | 33 ++----------- .../Source/FlutterPlatformPluginTest.mm | 4 -- .../FlutterPluginAppLifeCycleDelegate.mm | 32 ++++--------- .../FlutterPluginAppLifeCycleDelegateTest.mm | 2 - .../framework/Source/FlutterViewController.mm | 13 +---- 12 files changed, 53 insertions(+), 169 deletions(-) diff --git a/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h b/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h index 4f4735f0daae7..569b551cfa951 100644 --- a/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h +++ b/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h @@ -9,12 +9,12 @@ NS_ASSUME_NONNULL_BEGIN -// Finds a bundle with the named `flutterFrameworkBundleID` within `searchURL`. +// Finds a bundle with the named `bundleID` within `searchURL`. // // Returns `nil` if the bundle cannot be found or if errors are encountered. -NSBundle* FLTFrameworkBundleInternal(NSString* flutterFrameworkBundleID, NSURL* searchURL); +NSBundle* FLTFrameworkBundleInternal(NSString* bundleID, NSURL* searchURL); -// Finds a bundle with the named `flutterFrameworkBundleID`. +// Finds a bundle with the named `bundleID`. // // `+[NSBundle bundleWithIdentifier:]` is slow, and can take in the order of // tens of milliseconds in a minimal flutter app, and closer to 100 milliseconds @@ -28,20 +28,7 @@ NSBundle* FLTFrameworkBundleInternal(NSString* flutterFrameworkBundleID, NSURL* // frameworks used by this file are placed. If the desired bundle cannot be // found here, the implementation falls back to // `+[NSBundle bundleWithIdentifier:]`. -NSBundle* FLTFrameworkBundleWithIdentifier(NSString* flutterFrameworkBundleID); - -// Finds the bundle of the application. -// -// Returns [NSBundle mainBundle] if the current running process is the application. -NSBundle* FLTGetApplicationBundle(); - -// Finds the Flutter asset directory from `bundle`. -// -// The raw path can be set by the application via info.plist's `FLTAssetsPath` key. -// If the key is not set, `flutter_assets` is used as the raw path value. -// -// If no valid asset is found under the raw path, returns nil. -NSURL* FLTAssetsURLFromBundle(NSBundle* bundle); +NSBundle* FLTFrameworkBundleWithIdentifier(NSString* bundleID); NS_ASSUME_NONNULL_END diff --git a/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.mm b/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.mm index b2c718a9d8848..ab403f9b8d52b 100644 --- a/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.mm +++ b/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.mm @@ -8,7 +8,7 @@ FLUTTER_ASSERT_ARC -NSBundle* FLTFrameworkBundleInternal(NSString* flutterFrameworkBundleID, NSURL* searchURL) { +NSBundle* FLTFrameworkBundleInternal(NSString* bundleID, NSURL* searchURL) { NSDirectoryEnumerator* frameworkEnumerator = [NSFileManager.defaultManager enumeratorAtURL:searchURL includingPropertiesForKeys:nil @@ -18,46 +18,19 @@ errorHandler:nil]; for (NSURL* candidate in frameworkEnumerator) { - NSBundle* flutterFrameworkBundle = [NSBundle bundleWithURL:candidate]; - if ([flutterFrameworkBundle.bundleIdentifier isEqualToString:flutterFrameworkBundleID]) { - return flutterFrameworkBundle; + NSBundle* bundle = [NSBundle bundleWithURL:candidate]; + if ([bundle.bundleIdentifier isEqualToString:bundleID]) { + return bundle; } } return nil; } -NSBundle* FLTGetApplicationBundle() { - NSBundle* mainBundle = [NSBundle mainBundle]; - // App extension bundle is in .app/PlugIns/Extension.appex. - if ([mainBundle.bundleURL.pathExtension isEqualToString:@"appex"]) { - // Up two levels. - return [NSBundle bundleWithURL:mainBundle.bundleURL.URLByDeletingLastPathComponent - .URLByDeletingLastPathComponent]; +NSBundle* FLTFrameworkBundleWithIdentifier(NSString* bundleID) { + NSBundle* bundle = FLTFrameworkBundleInternal(bundleID, NSBundle.mainBundle.privateFrameworksURL); + if (bundle != nil) { + return bundle; } - return mainBundle; -} - -NSBundle* FLTFrameworkBundleWithIdentifier(NSString* flutterFrameworkBundleID) { - NSBundle* appBundle = FLTGetApplicationBundle(); - NSBundle* flutterFrameworkBundle = - FLTFrameworkBundleInternal(flutterFrameworkBundleID, appBundle.privateFrameworksURL); - if (flutterFrameworkBundle == nil) { - // Fallback to slow implementation. - flutterFrameworkBundle = [NSBundle bundleWithIdentifier:flutterFrameworkBundleID]; - } - if (flutterFrameworkBundle == nil) { - flutterFrameworkBundle = [NSBundle mainBundle]; - } - return flutterFrameworkBundle; -} - -NSURL* FLTAssetsURLFromBundle(NSBundle* bundle) { - NSString* assetsPathFromInfoPlist = [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"]; - NSString* flutterAssetsPath = assetsPathFromInfoPlist ?: @"flutter_assets"; - NSURL* assets = [bundle URLForResource:flutterAssetsPath withExtension:nil]; - - if ([assets checkResourceIsReachableAndReturnError:NULL]) { - return assets; - } - return nil; + // Fallback to slow implementation. + return [NSBundle bundleWithIdentifier:bundleID]; } diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index f726f41f23a95..8aa967ae6ca55 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -348,10 +348,6 @@ shared_library("create_flutter_framework_dylib") { ldflags = [ "-Wl,-install_name,@rpath/Flutter.framework/Flutter" ] - if (darwin_extension_safe) { - ldflags += [ "-fapplication-extension" ] - } - public = _flutter_framework_headers deps = [ @@ -442,10 +438,7 @@ copy("copy_license") { shared_library("copy_and_verify_framework_module") { framework_search_path = rebase_path("$root_out_dir") visibility = [ ":*" ] - cflags_objc = [ - "-F$framework_search_path", - "-fapplication-extension", - ] + cflags_objc = [ "-F$framework_search_path" ] sources = [ "framework/Source/FlutterUmbrellaImport.m" ] deps = [ @@ -453,17 +446,6 @@ shared_library("copy_and_verify_framework_module") { ":copy_framework_info_plist", ":copy_framework_module_map", ] - - if (darwin_extension_safe) { - ldflags = [ - "-F$framework_search_path", - "-fapplication-extension", - "-Xlinker", - "-fatal_warnings", - ] - deps += [ ":copy_dylib" ] - frameworks = [ "Flutter.framework" ] - } } group("universal_flutter_framework") { diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h b/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h index 524e68293c95a..b270414900692 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h @@ -353,8 +353,7 @@ typedef enum { * * @param delegate The receiving object, such as the plugin's main class. */ -- (void)addApplicationDelegate:(NSObject*)delegate - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in plugins used in app extensions"); +- (void)addApplicationDelegate:(NSObject*)delegate; /** * Returns the file name for the given asset. diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index 56bca603a0469..4873102e7222f 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -41,13 +41,16 @@ // 3. Settings from the NSBundle with the default bundle ID. // 4. Settings from the main NSBundle and default values. - NSBundle* mainBundle = FLTGetApplicationBundle(); + NSBundle* mainBundle = [NSBundle mainBundle]; NSBundle* engineBundle = [NSBundle bundleForClass:[FlutterViewController class]]; bool hasExplicitBundle = bundle != nil; if (bundle == nil) { bundle = FLTFrameworkBundleWithIdentifier([FlutterDartProject defaultBundleIdentifier]); } + if (bundle == nil) { + bundle = mainBundle; + } auto settings = flutter::SettingsFromCommandLine(command_line); @@ -119,24 +122,29 @@ // Checks to see if the flutter assets directory is already present. if (settings.assets_path.empty()) { - NSURL* assetsURL = FLTAssetsURLFromBundle(bundle); + NSString* assetsName = [FlutterDartProject flutterAssetsName:bundle]; + NSString* assetsPath = [bundle pathForResource:assetsName ofType:@""]; + + if (assetsPath.length == 0) { + assetsPath = [mainBundle pathForResource:assetsName ofType:@""]; + } - if (!assetsURL) { - NSLog(@"Failed to find assets path for 1\"%@\"", bundle); + if (assetsPath.length == 0) { + NSLog(@"Failed to find assets path for \"%@\"", assetsName); } else { - settings.assets_path = assetsURL.path.UTF8String; + settings.assets_path = assetsPath.UTF8String; // Check if there is an application kernel snapshot in the assets directory we could // potentially use. Looking for the snapshot makes sense only if we have a VM that can use // it. if (!flutter::DartVM::IsRunningPrecompiledCode()) { NSURL* applicationKernelSnapshotURL = - [assetsURL URLByAppendingPathComponent:@(kApplicationKernelSnapshotFileName)]; - NSError* error; - if ([applicationKernelSnapshotURL checkResourceIsReachableAndReturnError:&error]) { + [NSURL URLWithString:@(kApplicationKernelSnapshotFileName) + relativeToURL:[NSURL fileURLWithPath:assetsPath]]; + if ([[NSFileManager defaultManager] fileExistsAtPath:applicationKernelSnapshotURL.path]) { settings.application_kernel_asset = applicationKernelSnapshotURL.path.UTF8String; } else { - NSLog(@"Failed to find snapshot at %@: %@", applicationKernelSnapshotURL.path, error); + NSLog(@"Failed to find snapshot: %@", applicationKernelSnapshotURL.path); } } } @@ -331,7 +339,9 @@ + (NSString*)flutterAssetsName:(NSBundle*)bundle { if (bundle == nil) { bundle = FLTFrameworkBundleWithIdentifier([FlutterDartProject defaultBundleIdentifier]); } - + if (bundle == nil) { + bundle = [NSBundle mainBundle]; + } NSString* flutterAssetsName = [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"]; if (flutterAssetsName == nil) { flutterAssetsName = @"Frameworks/App.framework/flutter_assets"; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm index ab9061a1ab82e..7e180603a0a1a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm @@ -73,20 +73,6 @@ - (void)testFLTFrameworkBundleInternalWhenBundleIsPresent { XCTAssertNotNil(found); } -- (void)testFLTGetApplicationBundleWhenCurrentTargetIsNotExtension { - NSBundle* bundle = FLTGetApplicationBundle(); - XCTAssertEqual(bundle, [NSBundle mainBundle]); -} - -- (void)testFLTGetApplicationBundleWhenCurrentTargetIsExtension { - id mockMainBundle = OCMPartialMock([NSBundle mainBundle]); - NSURL* url = [[NSBundle mainBundle].bundleURL URLByAppendingPathComponent:@"foo/ext.appex"]; - OCMStub([mockMainBundle bundleURL]).andReturn(url); - NSBundle* bundle = FLTGetApplicationBundle(); - [mockMainBundle stopMocking]; - XCTAssertEqualObjects(bundle.bundleURL, [NSBundle mainBundle].bundleURL); -} - - (void)testDisableImpellerSettingIsCorrectlyParsed { id mockMainBundle = OCMPartialMock([NSBundle mainBundle]); OCMStub([mockMainBundle objectForInfoDictionaryKey:@"FLTEnableImpeller"]).andReturn(@"NO"); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index df4bd038036a5..b300714f166ad 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -1515,8 +1515,7 @@ - (void)addMethodCallDelegate:(NSObject*)delegate }]; } -- (void)addApplicationDelegate:(NSObject*)delegate - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in plugins used in app extensions") { +- (void)addApplicationDelegate:(NSObject*)delegate { id appDelegate = [[UIApplication sharedApplication] delegate]; if ([appDelegate conformsToProtocol:@protocol(FlutterAppLifeCycleProvider)]) { id lifeCycleProvider = diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm index 722571bda0a03..ef454d0d44012 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm @@ -17,10 +17,7 @@ constexpr char kTextPlainFormat[] = "text/plain"; const UInt32 kKeyPressClickSoundId = 1306; - -#if not APPLICATION_EXTENSION_API_ONLY const NSString* searchURLPrefix = @"x-web-search://?"; -#endif } // namespace @@ -40,24 +37,6 @@ using namespace flutter; -static void SetStatusBarHiddenForSharedApplication(BOOL hidden) { -#if APPLICATION_EXTENSION_API_ONLY - [UIApplication sharedApplication].statusBarHidden = hidden; -#else - FML_LOG(WARNING) << "Application based status bar styling is not available in app extension."; -#endif -} - -static void SetStatusBarStyleForSharedApplication(UIStatusBarStyle style) { -#if APPLICATION_EXTENSION_API_ONLY - // Note: -[UIApplication setStatusBarStyle] is deprecated in iOS9 - // in favor of delegating to the view controller. - [[UIApplication sharedApplication] setStatusBarStyle:style]; -#else - FML_LOG(WARNING) << "Application based status bar styling is not available in app extension."; -#endif -} - @interface FlutterPlatformPlugin () /** @@ -162,9 +141,6 @@ - (void)showShareViewController:(NSString*)content { } - (void)searchWeb:(NSString*)searchTerm { -#if APPLICATION_EXTENSION_API_ONLY - FML_LOG(WARNING) << "SearchWeb.invoke is not availabe in app extension."; -#else NSString* escapedText = [searchTerm stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]; @@ -173,7 +149,6 @@ - (void)searchWeb:(NSString*)searchTerm { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:searchURL] options:@{} completionHandler:nil]; -#endif } - (void)playSystemSound:(NSString*)soundType { @@ -256,7 +231,7 @@ - (void)setSystemChromeEnabledSystemUIOverlays:(NSArray*)overlays { // We opt out of view controller based status bar visibility since we want // to be able to modify this on the fly. The key used is // UIViewControllerBasedStatusBarAppearance. - SetStatusBarHiddenForSharedApplication(statusBarShouldBeHidden); + [UIApplication sharedApplication].statusBarHidden = statusBarShouldBeHidden; } } @@ -271,7 +246,7 @@ - (void)setSystemChromeEnabledSystemUIMode:(NSString*)mode { // We opt out of view controller based status bar visibility since we want // to be able to modify this on the fly. The key used is // UIViewControllerBasedStatusBarAppearance. - SetStatusBarHiddenForSharedApplication(!edgeToEdge); + [UIApplication sharedApplication].statusBarHidden = !edgeToEdge; } [[NSNotificationCenter defaultCenter] postNotificationName:edgeToEdge ? FlutterViewControllerShowHomeIndicator @@ -309,7 +284,9 @@ - (void)setSystemChromeSystemUIOverlayStyle:(NSDictionary*)message { object:nil userInfo:@{@(kOverlayStyleUpdateNotificationKey) : @(statusBarStyle)}]; } else { - SetStatusBarStyleForSharedApplication(statusBarStyle); + // Note: -[UIApplication setStatusBarStyle] is deprecated in iOS9 + // in favor of delegating to the view controller. + [[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle]; } } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm index 05764102a8e67..3e19665973e96 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm @@ -50,11 +50,9 @@ - (void)testSearchWebInvokedWithEscapedTerm { FlutterResult result = ^(id result) { OCMVerify([mockPlugin searchWeb:@"Testing Word!"]); -#if not APPLICATION_EXTENSION_API_ONLY OCMVerify([mockApplication openURL:[NSURL URLWithString:@"x-web-search://?Testing%20Word!"] options:@{} completionHandler:nil]); -#endif [invokeExpectation fulfill]; }; @@ -84,11 +82,9 @@ - (void)testSearchWebInvokedWithNonEscapedTerm { FlutterResult result = ^(id result) { OCMVerify([mockPlugin searchWeb:@"Test"]); -#if not APPLICATION_EXTENSION_API_ONLY OCMVerify([mockApplication openURL:[NSURL URLWithString:@"x-web-search://?Test"] options:@{} completionHandler:nil]); -#endif [invokeExpectation fulfill]; }; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm b/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm index def41bbca43cc..d493f30d11feb 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm @@ -17,16 +17,11 @@ @selector(application:performFetchWithCompletionHandler:)}; @interface FlutterPluginAppLifeCycleDelegate () -- (void)handleDidEnterBackground:(NSNotification*)notification - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in app extensions"); -- (void)handleWillEnterForeground:(NSNotification*)notification - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in app extensions"); -- (void)handleWillResignActive:(NSNotification*)notification - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in app extensions"); -- (void)handleDidBecomeActive:(NSNotification*)notification - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in app extensions"); -- (void)handleWillTerminate:(NSNotification*)notification - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in app extensions"); +- (void)handleDidEnterBackground:(NSNotification*)notification; +- (void)handleWillEnterForeground:(NSNotification*)notification; +- (void)handleWillResignActive:(NSNotification*)notification; +- (void)handleDidBecomeActive:(NSNotification*)notification; +- (void)handleWillTerminate:(NSNotification*)notification; @end @implementation FlutterPluginAppLifeCycleDelegate { @@ -51,7 +46,6 @@ - (instancetype)init { _notificationUnsubscribers = [[NSMutableArray alloc] init]; std::string cachePath = fml::paths::JoinPaths({getenv("HOME"), kCallbackCacheSubDir}); [FlutterCallbackCache setCachePath:[NSString stringWithUTF8String:cachePath.c_str()]]; -#if not APPLICATION_EXTENSION_API_ONLY [self addObserverFor:UIApplicationDidEnterBackgroundNotification selector:@selector(handleDidEnterBackground:)]; [self addObserverFor:UIApplicationWillEnterForegroundNotification @@ -62,7 +56,6 @@ - (instancetype)init { selector:@selector(handleDidBecomeActive:)]; [self addObserverFor:UIApplicationWillTerminateNotification selector:@selector(handleWillTerminate:)]; -#endif _delegates = [[NSPointerArray weakObjectsPointerArray] retain]; _debugBackgroundTask = UIBackgroundTaskInvalid; } @@ -141,8 +134,7 @@ - (BOOL)application:(UIApplication*)application return YES; } -- (void)handleDidEnterBackground:(NSNotification*)notification - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in app extensions") { +- (void)handleDidEnterBackground:(NSNotification*)notification { UIApplication* application = [UIApplication sharedApplication]; #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG // The following keeps the Flutter session alive when the device screen locks @@ -174,8 +166,7 @@ - (void)handleDidEnterBackground:(NSNotification*)notification } } -- (void)handleWillEnterForeground:(NSNotification*)notification - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in app extensions") { +- (void)handleWillEnterForeground:(NSNotification*)notification { UIApplication* application = [UIApplication sharedApplication]; #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG if (_debugBackgroundTask != UIBackgroundTaskInvalid) { @@ -193,8 +184,7 @@ - (void)handleWillEnterForeground:(NSNotification*)notification } } -- (void)handleWillResignActive:(NSNotification*)notification - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in app extensions") { +- (void)handleWillResignActive:(NSNotification*)notification { UIApplication* application = [UIApplication sharedApplication]; for (NSObject* delegate in _delegates) { if (!delegate) { @@ -206,8 +196,7 @@ - (void)handleWillResignActive:(NSNotification*)notification } } -- (void)handleDidBecomeActive:(NSNotification*)notification - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in app extensions") { +- (void)handleDidBecomeActive:(NSNotification*)notification { UIApplication* application = [UIApplication sharedApplication]; for (NSObject* delegate in _delegates) { if (!delegate) { @@ -219,8 +208,7 @@ - (void)handleDidBecomeActive:(NSNotification*)notification } } -- (void)handleWillTerminate:(NSNotification*)notification - NS_EXTENSION_UNAVAILABLE_IOS("Disallowed in app extensions") { +- (void)handleWillTerminate:(NSNotification*)notification { UIApplication* application = [UIApplication sharedApplication]; for (NSObject* delegate in _delegates) { if (!delegate) { diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegateTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegateTest.mm index 9fcc645575f29..9891f52cf8c0c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegateTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegateTest.mm @@ -20,7 +20,6 @@ - (void)testCreate { XCTAssertNotNil(delegate); } -#if not APPLICATION_EXTENSION_API_ONLY - (void)testDidEnterBackground { XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc] initWithName:UIApplicationDidEnterBackgroundNotification]; @@ -89,6 +88,5 @@ - (void)testWillTerminate { [self waitForExpectations:@[ expectation ] timeout:5.0]; OCMVerify([plugin applicationWillTerminate:[UIApplication sharedApplication]]); } -#endif @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index f78ca85f79ee4..f5a647195648f 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -1973,7 +1973,7 @@ - (void)performOrientationUpdate:(UIInterfaceOrientationMask)new_preferences { #endif [self requestGeometryUpdateForWindowScenes:scenes]; } else { - UIInterfaceOrientationMask currentInterfaceOrientation = 0; + UIInterfaceOrientationMask currentInterfaceOrientation; if (@available(iOS 13.0, *)) { UIWindowScene* windowScene = [self flutterWindowSceneIfViewLoaded]; if (!windowScene) { @@ -1983,13 +1983,7 @@ - (void)performOrientationUpdate:(UIInterfaceOrientationMask)new_preferences { } currentInterfaceOrientation = 1 << windowScene.interfaceOrientation; } else { -#if APPLICATION_EXTENSION_API_ONLY - FML_LOG(ERROR) << "Application based status bar orentiation update is not supported in " - "app extension. Orientation: " - << currentInterfaceOrientation; -#else currentInterfaceOrientation = 1 << [[UIApplication sharedApplication] statusBarOrientation]; -#endif } if (!(_orientationPreferences & currentInterfaceOrientation)) { [UIViewController attemptRotationToDeviceOrientation]; @@ -2114,10 +2108,6 @@ - (void)onUserSettingsChanged:(NSNotification*)notification { } - (CGFloat)textScaleFactor { -#if APPLICATION_EXTENSION_API_ONLY - FML_LOG(WARNING) << "Dynamic content size update is not supported in app extension."; - return 1.0; -#else UIContentSizeCategory category = [UIApplication sharedApplication].preferredContentSizeCategory; // The delta is computed by approximating Apple's typography guidelines: // https://developer.apple.com/ios/human-interface-guidelines/visual-design/typography/ @@ -2168,7 +2158,6 @@ - (CGFloat)textScaleFactor { } else { return 1.0; } -#endif } - (BOOL)isAlwaysUse24HourFormat {