From cc1ec72179c12f85790cd5335aad856594b885eb Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 13 Jun 2023 15:26:59 -0700 Subject: [PATCH] Remove some trivial deprecated symbol usages in iOS Embedder (flutter/engine#42711) stringWithCString was deprecated in iOS 2.0 UIAccessibilityVoiceOverStatusChanged was deprecated in iOS 11.0 fixes: https://github.com/flutter/flutter/issues/128732 https://github.com/flutter/flutter/issues/128736 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../platform/darwin/ios/framework/Source/FlutterEngine.mm | 5 ++--- .../darwin/ios/framework/Source/FlutterViewController.mm | 2 +- .../ios/Scenarios/ScenariosUITests/GoldenImage.m | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index 0633a78211..52e6af116b 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -678,7 +678,7 @@ static constexpr int kNumProfilerSamplesPerSec = 5; // TODO(gaaclarke): Find way to eliminate this data copy. NSData* data = [NSData dataWithBytes:screenshot.data->writable_data() length:screenshot.data->size()]; - NSString* format = [NSString stringWithCString:screenshot.format.c_str()]; + NSString* format = [NSString stringWithUTF8String:screenshot.format.c_str()]; NSNumber* width = @(screenshot.frame_size.fWidth); NSNumber* height = @(screenshot.frame_size.fHeight); return result(@[ width, height, format, data ]); @@ -821,8 +821,7 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS if (initialRoute != nil) { self.initialRoute = initialRoute; } else if (settings.route.empty() == false) { - self.initialRoute = [NSString stringWithCString:settings.route.c_str() - encoding:NSUTF8StringEncoding]; + self.initialRoute = [NSString stringWithUTF8String:settings.route.c_str()]; } FlutterView.forceSoftwareRendering = settings.enable_software_rendering; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index c88366b669..67c7211b3e 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -342,7 +342,7 @@ typedef struct MouseState { [center addObserver:self selector:@selector(onAccessibilityStatusChanged:) - name:UIAccessibilityVoiceOverStatusChanged + name:UIAccessibilityVoiceOverStatusDidChangeNotification object:nil]; [center addObserver:self diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m index 3a0d429b86..698207aa68 100644 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m +++ b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m @@ -114,7 +114,7 @@ NS_INLINE NSString* _platformName() { char* answer = malloc(size); sysctlbyname("hw.model", answer, &size, NULL, 0); - NSString* results = [NSString stringWithCString:answer encoding:NSUTF8StringEncoding]; + NSString* results = [NSString stringWithUTF8String:answer]; free(answer); return results; }