diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index 090f144cc6eaf..97229ee4d6eea 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -70,6 +70,7 @@ source_set("flutter_framework_source_arc") { "framework/Source/FlutterDartVMServicePublisher.mm", "framework/Source/FlutterEmbedderKeyResponder.h", "framework/Source/FlutterEmbedderKeyResponder.mm", + "framework/Source/FlutterEngineGroup.mm", "framework/Source/FlutterHeadlessDartRunner.mm", "framework/Source/FlutterKeyPrimaryResponder.h", "framework/Source/FlutterKeySecondaryResponder.h", @@ -182,7 +183,6 @@ source_set("flutter_framework_source") { # New files are highly encouraged to be in ARC. # To add new files in ARC, add them to the `flutter_framework_source_arc` target. "framework/Source/FlutterEngine.mm", - "framework/Source/FlutterEngineGroup.mm", "framework/Source/FlutterEngine_Internal.h", "framework/Source/FlutterPlatformPlugin.h", "framework/Source/FlutterPlatformPlugin.mm", diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterEngineGroup.h b/shell/platform/darwin/ios/framework/Headers/FlutterEngineGroup.h index fe77b318fe956..47cdc07537fe7 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterEngineGroup.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterEngineGroup.h @@ -38,7 +38,7 @@ FLUTTER_DARWIN_EXPORT /** * Arguments passed as a list of string to Dart's entrypoint function. */ -@property(nonatomic, retain, nullable) NSArray* entrypointArgs; +@property(nonatomic, copy, nullable) NSArray* entrypointArgs; @end /** diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngineGroup.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngineGroup.mm index b0eca94e44096..b274475f7ed14 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngineGroup.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngineGroup.mm @@ -5,45 +5,30 @@ #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngineGroup.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h" -@implementation FlutterEngineGroupOptions - -- (void)dealloc { - [_entrypoint release]; - [_libraryURI release]; - [_initialRoute release]; - [_entrypointArgs release]; - [super dealloc]; -} +FLUTTER_ASSERT_ARC +@implementation FlutterEngineGroupOptions @end @interface FlutterEngineGroup () @property(nonatomic, copy) NSString* name; -@property(nonatomic, retain) NSMutableArray* engines; -@property(nonatomic, retain) FlutterDartProject* project; +@property(nonatomic, strong) NSMutableArray* engines; +@property(nonatomic, copy) FlutterDartProject* project; +@property(nonatomic, assign) NSUInteger enginesCreatedCount; @end -@implementation FlutterEngineGroup { - int _enginesCreatedCount; -} +@implementation FlutterEngineGroup - (instancetype)initWithName:(NSString*)name project:(nullable FlutterDartProject*)project { self = [super init]; if (self) { _name = [name copy]; _engines = [[NSMutableArray alloc] init]; - _project = [project retain]; + _project = project; } return self; } -- (void)dealloc { - [_name release]; - [_engines release]; - [_project release]; - [super dealloc]; -} - - (FlutterEngine*)makeEngineWithEntrypoint:(nullable NSString*)entrypoint libraryURI:(nullable NSString*)libraryURI { return [self makeEngineWithEntrypoint:entrypoint libraryURI:libraryURI initialRoute:nil]; @@ -52,7 +37,7 @@ - (FlutterEngine*)makeEngineWithEntrypoint:(nullable NSString*)entrypoint - (FlutterEngine*)makeEngineWithEntrypoint:(nullable NSString*)entrypoint libraryURI:(nullable NSString*)libraryURI initialRoute:(nullable NSString*)initialRoute { - FlutterEngineGroupOptions* options = [[[FlutterEngineGroupOptions alloc] init] autorelease]; + FlutterEngineGroupOptions* options = [[FlutterEngineGroupOptions alloc] init]; options.entrypoint = entrypoint; options.libraryURI = libraryURI; options.initialRoute = initialRoute; @@ -79,7 +64,8 @@ - (FlutterEngine*)makeEngineWithOptions:(nullable FlutterEngineGroupOptions*)opt initialRoute:initialRoute entrypointArgs:entrypointArgs]; } - [_engines addObject:[NSValue valueWithPointer:engine]]; + // TODO(cbracken): https://github.com/flutter/flutter/issues/155943 + [self.engines addObject:[NSValue valueWithPointer:(__bridge void*)engine]]; NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; [center addObserver:self @@ -91,13 +77,14 @@ - (FlutterEngine*)makeEngineWithOptions:(nullable FlutterEngineGroupOptions*)opt } - (FlutterEngine*)makeEngine { - NSString* engineName = [NSString stringWithFormat:@"%@.%d", self.name, ++_enginesCreatedCount]; - FlutterEngine* result = [[FlutterEngine alloc] initWithName:engineName project:self.project]; - return [result autorelease]; + NSString* engineName = + [NSString stringWithFormat:@"%@.%lu", self.name, ++self.enginesCreatedCount]; + return [[FlutterEngine alloc] initWithName:engineName project:self.project]; } - (void)onEngineWillBeDealloced:(NSNotification*)notification { - [_engines removeObject:[NSValue valueWithPointer:notification.object]]; + // TODO(cbracken): https://github.com/flutter/flutter/issues/155943 + [self.engines removeObject:[NSValue valueWithPointer:(__bridge void*)notification.object]]; } @end