From 2d43d428eae62db033497608779671c4b4b2fb94 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Tue, 8 Nov 2022 20:02:01 +0800 Subject: [PATCH 01/15] [macOS] Add lookupKeyForAsset to FlutterPluginRegistrar --- .../framework/Headers/FlutterDartProject.h | 2 +- .../framework/Headers/FlutterDartProject.h | 48 +++++++ .../Headers/FlutterPluginRegistrarMacOS.h | 20 +++ .../framework/Headers/FlutterViewController.h | 22 +++ .../framework/Source/FlutterDartProject.mm | 34 +++++ .../macos/framework/Source/FlutterEngine.mm | 126 ++++++++++-------- .../framework/Source/FlutterEngine_Internal.h | 24 ++++ .../framework/Source/FlutterViewController.mm | 8 ++ .../Source/FlutterViewControllerTest.mm | 17 +++ 9 files changed, 245 insertions(+), 56 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h b/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h index 8f64d124a69f3..cc08cb61bc04c 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h @@ -31,7 +31,7 @@ FLUTTER_DARWIN_EXPORT * Returns the file name for the given asset. If the bundle with the identifier * "io.flutter.flutter.app" exists, it will try use that bundle; otherwise, it * will use the main bundle. To specify a different bundle, use - * `-lookupKeyForAsset:asset:fromBundle`. + * `+lookupKeyForAsset:fromBundle:`. * * @param asset The name of the asset. The name can be hierarchical. * @return the file name to be used for lookup in the main bundle. diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h b/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h index 4a83e4d3e6062..a1dfbcdc793b5 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h @@ -9,6 +9,8 @@ #import "FlutterMacros.h" +NS_ASSUME_NONNULL_BEGIN + /** * A set of Flutter and Dart assets used by a `FlutterEngine` to initialize execution. * @@ -46,6 +48,52 @@ FLUTTER_DARWIN_EXPORT */ @property(nonatomic, nullable, copy) NSArray* dartEntrypointArguments; +/** + * Returns the file name for the given asset. If the bundle with the identifier + * "io.flutter.flutter.app" exists, it will try use that bundle; otherwise, it + * will use the main bundle. To specify a different bundle, use + * `+lookupKeyForAsset:fromBundle`. + * + * @param asset The name of the asset. The name can be hierarchical. + * @return the file name to be used for lookup in the main bundle. + */ ++ (NSString*)lookupKeyForAsset:(NSString*)asset; + +/** + * Returns the file name for the given asset. + * The returned file name can be used to access the asset in the supplied bundle. + * + * @param asset The name of the asset. The name can be hierarchical. + * @param bundle The `NSBundle` to use for looking up the asset. + * @return the file name to be used for lookup in the main bundle. + */ ++ (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle; + +/** + * Returns the file name for the given asset which originates from the specified package. + * The returned file name can be used to access the asset in the application's main bundle. + * + * @param asset The name of the asset. The name can be hierarchical. + * @param package The name of the package from which the asset originates. + * @return the file name to be used for lookup in the main bundle. + */ ++ (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package; + +/** + * Returns the file name for the given asset which originates from the specified package. + * The returned file name can be used to access the asset in the specified bundle. + * + * @param asset The name of the asset. The name can be hierarchical. + * @param package The name of the package from which the asset originates. + * @param bundle The bundle to use when doing the lookup. + * @return the file name to be used for lookup in the main bundle. + */ ++ (NSString*)lookupKeyForAsset:(NSString*)asset + fromPackage:(NSString*)package + fromBundle:(nullable NSBundle*)bundle; + @end +NS_ASSUME_NONNULL_END + #endif // FLUTTER_FLUTTERDARTPROJECT_H_ diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h b/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h index 12c7f618a38e8..b0110bc8641cb 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h @@ -61,6 +61,26 @@ FLUTTER_DARWIN_EXPORT - (void)registerViewFactory:(nonnull NSObject*)factory withId:(nonnull NSString*)factoryId; +/** + * Returns the file name for the given asset. + * The returned file name can be used to access the asset in the application's main bundle. + * + * @param asset The name of the asset. The name can be hierarchical. + * @return the file name to be used for lookup in the main bundle. + */ +- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset; + +/** + * Returns the file name for the given asset which originates from the specified package. + * The returned file name can be used to access the asset in the application's main bundle. + * + * + * @param asset The name of the asset. The name can be hierarchical. + * @param package The name of the package from which the asset originates. + * @return the file name to be used for lookup in the main bundle. + */ +- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset fromPackage:(nonnull NSString*)package; + @end /** diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h b/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h index 4dea666e1262c..7ec9af1f7f84d 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h @@ -73,6 +73,28 @@ FLUTTER_DARWIN_EXPORT */ - (void)onPreEngineRestart; +/** + * Returns the file name for the given asset. + * The returned file name can be used to access the asset in the application's + * main bundle. + * + * @param asset The name of the asset. The name can be hierarchical. + * @return The file name to be used for lookup in the main bundle. + */ +- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset; + +/** + * Returns the file name for the given asset which originates from the specified + * package. + * The returned file name can be used to access the asset in the application's + * main bundle. + * + * @param asset The name of the asset. The name can be hierarchical. + * @param package The name of the package from which the asset originates. + * @return The file name to be used for lookup in the main bundle. + */ +- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset fromPackage:(nonnull NSString*)package; + /** * The contentView (FlutterView)'s background color is set to black during * its instantiation. diff --git a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm index a18690772cf2b..a556e916e3ab2 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm @@ -89,4 +89,38 @@ - (NSString*)ICUDataPath { return arguments; } ++ (NSString*)flutterAssetsName:(NSBundle*)bundle { + if (bundle == nil) { + bundle = [NSBundle bundleWithIdentifier:kAppBundleIdentifier]; + } + if (bundle == nil) { + bundle = [NSBundle mainBundle]; + } + NSString* flutterAssetsName = [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"]; + if (flutterAssetsName == nil) { + flutterAssetsName = @"Contents/Frameworks/App.framework/Resources/flutter_assets"; + } + return flutterAssetsName; +} + ++ (NSString*)lookupKeyForAsset:(NSString*)asset { + return [self lookupKeyForAsset:asset fromBundle:nil]; +} + ++ (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle { + NSString* flutterAssetsName = [FlutterDartProject flutterAssetsName:bundle]; + return [NSString stringWithFormat:@"%@/%@", flutterAssetsName, asset]; +} + ++ (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { + return [self lookupKeyForAsset:asset fromPackage:package fromBundle:nil]; +} + ++ (NSString*)lookupKeyForAsset:(NSString*)asset + fromPackage:(NSString*)package + fromBundle:(nullable NSBundle*)bundle { + return [self lookupKeyForAsset:[NSString stringWithFormat:@"packages/%@/%@", package, asset] + fromBundle:bundle]; +} + @end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 870ca4802f3d9..22219b77fc3c1 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -68,6 +68,16 @@ - (instancetype)initWithConnection:(NSNumber*)connection #pragma mark - +/** + * `FlutterPluginRegistrar` implementation handling a single plugin. + */ +@interface FlutterEngineRegistrar : NSObject +- (instancetype)initWithPlugin:(nonnull NSString*)pluginKey + flutterEngine:(nonnull FlutterEngine*)flutterEngine; +@end + +#pragma mark - + /** * Private interface declaration for FlutterEngine. */ @@ -122,61 +132,6 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result; @end -#pragma mark - - -/** - * `FlutterPluginRegistrar` implementation handling a single plugin. - */ -@interface FlutterEngineRegistrar : NSObject -- (instancetype)initWithPlugin:(nonnull NSString*)pluginKey - flutterEngine:(nonnull FlutterEngine*)flutterEngine; -@end - -@implementation FlutterEngineRegistrar { - NSString* _pluginKey; - FlutterEngine* _flutterEngine; -} - -- (instancetype)initWithPlugin:(NSString*)pluginKey flutterEngine:(FlutterEngine*)flutterEngine { - self = [super init]; - if (self) { - _pluginKey = [pluginKey copy]; - _flutterEngine = flutterEngine; - } - return self; -} - -#pragma mark - FlutterPluginRegistrar - -- (id)messenger { - return _flutterEngine.binaryMessenger; -} - -- (id)textures { - return _flutterEngine.renderer; -} - -- (NSView*)view { - if (!_flutterEngine.viewController.viewLoaded) { - [_flutterEngine.viewController loadView]; - } - return _flutterEngine.viewController.flutterView; -} - -- (void)addMethodCallDelegate:(nonnull id)delegate - channel:(nonnull FlutterMethodChannel*)channel { - [channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) { - [delegate handleMethodCall:call result:result]; - }]; -} - -- (void)registerViewFactory:(nonnull NSObject*)factory - withId:(nonnull NSString*)factoryId { - [[_flutterEngine platformViewController] registerViewFactory:factory withId:factoryId]; -} - -@end - // Callbacks provided to the engine. See the called methods for documentation. #pragma mark - Static methods provided to engine configuration @@ -801,6 +756,14 @@ - (NSPasteboard*)pasteboard { return [NSPasteboard generalPasteboard]; } +- (NSString*)lookupKeyForAsset:(NSString*)asset { + return [FlutterDartProject lookupKeyForAsset:asset]; +} + +- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { + return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; +} + #pragma mark - FlutterBinaryMessenger - (void)sendOnChannel:(nonnull NSString*)channel message:(nullable NSData*)message { @@ -980,3 +943,56 @@ - (void)postMainThreadTask:(FlutterTask)task targetTimeInNanoseconds:(uint64_t)t } @end + +@implementation FlutterEngineRegistrar { + NSString* _pluginKey; + FlutterEngine* _flutterEngine; +} + +- (instancetype)initWithPlugin:(NSString*)pluginKey flutterEngine:(FlutterEngine*)flutterEngine { + self = [super init]; + if (self) { + _pluginKey = [pluginKey copy]; + _flutterEngine = flutterEngine; + } + return self; +} + +#pragma mark - FlutterPluginRegistrar + +- (id)messenger { + return _flutterEngine.binaryMessenger; +} + +- (id)textures { + return _flutterEngine.renderer; +} + +- (NSView*)view { + if (!_flutterEngine.viewController.viewLoaded) { + [_flutterEngine.viewController loadView]; + } + return _flutterEngine.viewController.flutterView; +} + +- (void)addMethodCallDelegate:(nonnull id)delegate + channel:(nonnull FlutterMethodChannel*)channel { + [channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) { + [delegate handleMethodCall:call result:result]; + }]; +} + +- (void)registerViewFactory:(nonnull NSObject*)factory + withId:(nonnull NSString*)factoryId { + [[_flutterEngine platformViewController] registerViewFactory:factory withId:factoryId]; +} + +- (NSString*)lookupKeyForAsset:(NSString*)asset { + return [FlutterDartProject lookupKeyForAsset:asset]; +} + +- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { + return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; +} + +@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h b/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h index 3181e24077e45..9dde32a4b9879 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h @@ -93,6 +93,30 @@ toTarget:(uint16_t)target withData:(fml::MallocMapping)data; +/** + * Returns the file name for the given asset. + * The returned file name can be used to access the asset in the application's + * main bundle. + * + * @param asset The name of the asset. The name can be hierarchical. + * @return The file name to be used for lookup in the main bundle. + */ +- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset; + +/** + * Returns the file name for the given asset which originates from the specified + * package. + * The returned file name can be used to access the asset in the application's + * main bundle. + * + * @param asset The name of the asset. The name can be hierarchical. + * @param package The name of the package from which the asset originates. + * @return The file name to be used for lookup in the main bundle. + */ +- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset fromPackage:(nonnull NSString*)package; + + + @end @interface FlutterEngine (TestMethods) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm index 9034e8deaa6c1..9910e98d73b04 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm @@ -696,6 +696,14 @@ - (void)onKeyboardLayoutChanged { } } +- (NSString*)lookupKeyForAsset:(NSString*)asset { + return [_engine lookupKeyForAsset:asset]; +} + +- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { + return [_engine lookupKeyForAsset:asset fromPackage:package]; +} + #pragma mark - FlutterViewReshapeListener /** diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm index 903065731a31a..ac507323db2e0 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm @@ -24,6 +24,7 @@ - (bool)testKeyboardIsRestartedOnEngineRestart; - (bool)testTrackpadGesturesAreSentToFramework; - (bool)testViewWillAppearCalledMultipleTimes; - (bool)testFlutterViewIsConfigured; +- (bool)testLookupKeyAssets; + (void)respondFalseForSendEvent:(const FlutterKeyEvent&)event callback:(nullable FlutterKeyEventCallback)callback @@ -169,6 +170,10 @@ id MockGestureEvent(NSEventType type, NSEventPhase phase, double magnification, ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testFlutterViewIsConfigured]); } +TEST(FlutterViewControllerTest, testLookupKeyAssets) { + ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testLookupKeyAssets]); +} + } // namespace flutter::testing @implementation FlutterViewControllerTestObjC @@ -763,4 +768,16 @@ - (bool)testViewWillAppearCalledMultipleTimes { return true; } +- (bool)testLookupKeyAssets { + FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:nil]; + NSString *key = [viewController lookupKeyForAsset:@"test.png"]; + EXPECT_TRUE([key isEqualToString:@"Contents/Frameworks/App.framework/Resources/flutter_assets/test.png"]); + + NSString *packageKey = [viewController lookupKeyForAsset:@"test.png" fromPackage:@"test"]; + NSLog(@"%@",packageKey); + EXPECT_TRUE([packageKey isEqualToString:@"Contents/Frameworks/App.framework/Resources/flutter_assets/packages/test/test.png"]); + + return true; +} + @end From 754180796e27fbac6b099c45738b2568016b6f44 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Tue, 8 Nov 2022 20:07:41 +0800 Subject: [PATCH 02/15] clang tidy --- .../Headers/FlutterPluginRegistrarMacOS.h | 3 +- .../framework/Headers/FlutterViewController.h | 3 +- .../framework/Source/FlutterDartProject.mm | 34 +++++++------- .../macos/framework/Source/FlutterEngine.mm | 44 +++++++++---------- .../framework/Source/FlutterEngine_Internal.h | 5 +-- .../framework/Source/FlutterViewController.mm | 4 +- .../Source/FlutterViewControllerTest.mm | 23 +++++----- 7 files changed, 60 insertions(+), 56 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h b/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h index b0110bc8641cb..293b5f9c330d7 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h @@ -79,7 +79,8 @@ FLUTTER_DARWIN_EXPORT * @param package The name of the package from which the asset originates. * @return the file name to be used for lookup in the main bundle. */ -- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset fromPackage:(nonnull NSString*)package; +- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset + fromPackage:(nonnull NSString*)package; @end diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h b/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h index 7ec9af1f7f84d..d073c1b6bd858 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h @@ -93,7 +93,8 @@ FLUTTER_DARWIN_EXPORT * @param package The name of the package from which the asset originates. * @return The file name to be used for lookup in the main bundle. */ -- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset fromPackage:(nonnull NSString*)package; +- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset + fromPackage:(nonnull NSString*)package; /** * The contentView (FlutterView)'s background color is set to black during diff --git a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm index a556e916e3ab2..b67a4f6ba8c13 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm @@ -90,37 +90,37 @@ - (NSString*)ICUDataPath { } + (NSString*)flutterAssetsName:(NSBundle*)bundle { - if (bundle == nil) { - bundle = [NSBundle bundleWithIdentifier:kAppBundleIdentifier]; - } - if (bundle == nil) { - bundle = [NSBundle mainBundle]; - } - NSString* flutterAssetsName = [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"]; - if (flutterAssetsName == nil) { - flutterAssetsName = @"Contents/Frameworks/App.framework/Resources/flutter_assets"; - } - return flutterAssetsName; + if (bundle == nil) { + bundle = [NSBundle bundleWithIdentifier:kAppBundleIdentifier]; + } + if (bundle == nil) { + bundle = [NSBundle mainBundle]; + } + NSString* flutterAssetsName = [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"]; + if (flutterAssetsName == nil) { + flutterAssetsName = @"Contents/Frameworks/App.framework/Resources/flutter_assets"; + } + return flutterAssetsName; } + (NSString*)lookupKeyForAsset:(NSString*)asset { - return [self lookupKeyForAsset:asset fromBundle:nil]; + return [self lookupKeyForAsset:asset fromBundle:nil]; } + (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle { - NSString* flutterAssetsName = [FlutterDartProject flutterAssetsName:bundle]; - return [NSString stringWithFormat:@"%@/%@", flutterAssetsName, asset]; + NSString* flutterAssetsName = [FlutterDartProject flutterAssetsName:bundle]; + return [NSString stringWithFormat:@"%@/%@", flutterAssetsName, asset]; } + (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { - return [self lookupKeyForAsset:asset fromPackage:package fromBundle:nil]; + return [self lookupKeyForAsset:asset fromPackage:package fromBundle:nil]; } + (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package fromBundle:(nullable NSBundle*)bundle { - return [self lookupKeyForAsset:[NSString stringWithFormat:@"packages/%@/%@", package, asset] - fromBundle:bundle]; + return [self lookupKeyForAsset:[NSString stringWithFormat:@"packages/%@/%@", package, asset] + fromBundle:bundle]; } @end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 22219b77fc3c1..8ed452565ba96 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -757,11 +757,11 @@ - (NSPasteboard*)pasteboard { } - (NSString*)lookupKeyForAsset:(NSString*)asset { - return [FlutterDartProject lookupKeyForAsset:asset]; + return [FlutterDartProject lookupKeyForAsset:asset]; } - (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { - return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; + return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; } #pragma mark - FlutterBinaryMessenger @@ -945,54 +945,54 @@ - (void)postMainThreadTask:(FlutterTask)task targetTimeInNanoseconds:(uint64_t)t @end @implementation FlutterEngineRegistrar { - NSString* _pluginKey; - FlutterEngine* _flutterEngine; + NSString* _pluginKey; + FlutterEngine* _flutterEngine; } - (instancetype)initWithPlugin:(NSString*)pluginKey flutterEngine:(FlutterEngine*)flutterEngine { - self = [super init]; - if (self) { - _pluginKey = [pluginKey copy]; - _flutterEngine = flutterEngine; - } - return self; + self = [super init]; + if (self) { + _pluginKey = [pluginKey copy]; + _flutterEngine = flutterEngine; + } + return self; } #pragma mark - FlutterPluginRegistrar - (id)messenger { - return _flutterEngine.binaryMessenger; + return _flutterEngine.binaryMessenger; } - (id)textures { - return _flutterEngine.renderer; + return _flutterEngine.renderer; } - (NSView*)view { - if (!_flutterEngine.viewController.viewLoaded) { - [_flutterEngine.viewController loadView]; - } - return _flutterEngine.viewController.flutterView; + if (!_flutterEngine.viewController.viewLoaded) { + [_flutterEngine.viewController loadView]; + } + return _flutterEngine.viewController.flutterView; } - (void)addMethodCallDelegate:(nonnull id)delegate channel:(nonnull FlutterMethodChannel*)channel { - [channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) { - [delegate handleMethodCall:call result:result]; - }]; + [channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) { + [delegate handleMethodCall:call result:result]; + }]; } - (void)registerViewFactory:(nonnull NSObject*)factory withId:(nonnull NSString*)factoryId { - [[_flutterEngine platformViewController] registerViewFactory:factory withId:factoryId]; + [[_flutterEngine platformViewController] registerViewFactory:factory withId:factoryId]; } - (NSString*)lookupKeyForAsset:(NSString*)asset { - return [FlutterDartProject lookupKeyForAsset:asset]; + return [FlutterDartProject lookupKeyForAsset:asset]; } - (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { - return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; + return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; } @end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h b/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h index 9dde32a4b9879..b069b8476951d 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h @@ -113,9 +113,8 @@ * @param package The name of the package from which the asset originates. * @return The file name to be used for lookup in the main bundle. */ -- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset fromPackage:(nonnull NSString*)package; - - +- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset + fromPackage:(nonnull NSString*)package; @end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm index 9910e98d73b04..9dcd18c6a3efa 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm @@ -697,11 +697,11 @@ - (void)onKeyboardLayoutChanged { } - (NSString*)lookupKeyForAsset:(NSString*)asset { - return [_engine lookupKeyForAsset:asset]; + return [_engine lookupKeyForAsset:asset]; } - (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { - return [_engine lookupKeyForAsset:asset fromPackage:package]; + return [_engine lookupKeyForAsset:asset fromPackage:package]; } #pragma mark - FlutterViewReshapeListener diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm index ac507323db2e0..28cc01f66c41e 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm @@ -171,7 +171,7 @@ id MockGestureEvent(NSEventType type, NSEventPhase phase, double magnification, } TEST(FlutterViewControllerTest, testLookupKeyAssets) { - ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testLookupKeyAssets]); + ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testLookupKeyAssets]); } } // namespace flutter::testing @@ -769,15 +769,18 @@ - (bool)testViewWillAppearCalledMultipleTimes { } - (bool)testLookupKeyAssets { - FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:nil]; - NSString *key = [viewController lookupKeyForAsset:@"test.png"]; - EXPECT_TRUE([key isEqualToString:@"Contents/Frameworks/App.framework/Resources/flutter_assets/test.png"]); - - NSString *packageKey = [viewController lookupKeyForAsset:@"test.png" fromPackage:@"test"]; - NSLog(@"%@",packageKey); - EXPECT_TRUE([packageKey isEqualToString:@"Contents/Frameworks/App.framework/Resources/flutter_assets/packages/test/test.png"]); - - return true; + FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:nil]; + NSString* key = [viewController lookupKeyForAsset:@"test.png"]; + EXPECT_TRUE( + [key isEqualToString:@"Contents/Frameworks/App.framework/Resources/flutter_assets/test.png"]); + + NSString* packageKey = [viewController lookupKeyForAsset:@"test.png" fromPackage:@"test"]; + NSLog(@"%@", packageKey); + EXPECT_TRUE([packageKey + isEqualToString: + @"Contents/Frameworks/App.framework/Resources/flutter_assets/packages/test/test.png"]); + + return true; } @end From d1b8d0d35f2824f1a13773ea57df375e44e0124f Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Sun, 29 Jan 2023 14:57:55 +0800 Subject: [PATCH 03/15] Remove NS_ASSUME_NONNULL_BEGIN macro --- .../macos/framework/Headers/FlutterDartProject.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h b/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h index a1dfbcdc793b5..0ffe952475fdb 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h @@ -9,8 +9,6 @@ #import "FlutterMacros.h" -NS_ASSUME_NONNULL_BEGIN - /** * A set of Flutter and Dart assets used by a `FlutterEngine` to initialize execution. * @@ -57,7 +55,7 @@ FLUTTER_DARWIN_EXPORT * @param asset The name of the asset. The name can be hierarchical. * @return the file name to be used for lookup in the main bundle. */ -+ (NSString*)lookupKeyForAsset:(NSString*)asset; ++ (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset; /** * Returns the file name for the given asset. @@ -67,7 +65,7 @@ FLUTTER_DARWIN_EXPORT * @param bundle The `NSBundle` to use for looking up the asset. * @return the file name to be used for lookup in the main bundle. */ -+ (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle; ++ (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset fromBundle:(nullable NSBundle*)bundle; /** * Returns the file name for the given asset which originates from the specified package. @@ -77,7 +75,7 @@ FLUTTER_DARWIN_EXPORT * @param package The name of the package from which the asset originates. * @return the file name to be used for lookup in the main bundle. */ -+ (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package; ++ (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset fromPackage:(nonnull NSString*)package; /** * Returns the file name for the given asset which originates from the specified package. @@ -88,12 +86,11 @@ FLUTTER_DARWIN_EXPORT * @param bundle The bundle to use when doing the lookup. * @return the file name to be used for lookup in the main bundle. */ -+ (NSString*)lookupKeyForAsset:(NSString*)asset - fromPackage:(NSString*)package ++ (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset + fromPackage:(nonnull NSString*)package fromBundle:(nullable NSBundle*)bundle; @end -NS_ASSUME_NONNULL_END #endif // FLUTTER_FLUTTERDARTPROJECT_H_ From de48136b761328ad12033979677880f3e8cdcd79 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Wed, 22 Feb 2023 15:03:53 +0800 Subject: [PATCH 04/15] Fix wrong rebase --- .../framework/Source/FlutterDartProject.mm | 8 --- .../macos/framework/Source/FlutterEngine.mm | 61 +++---------------- .../framework/Source/FlutterViewController.mm | 4 +- 3 files changed, 10 insertions(+), 63 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm index b67a4f6ba8c13..5a7a036d6b967 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm @@ -81,14 +81,6 @@ - (NSString*)ICUDataPath { return path; } -- (std::vector)switches { - std::vector arguments = flutter::GetSwitchesFromEnvironment(); - if (self.enableMirrors) { - arguments.push_back("--dart-flags=--enable_mirrors=true"); - } - return arguments; -} - + (NSString*)flutterAssetsName:(NSBundle*)bundle { if (bundle == nil) { bundle = [NSBundle bundleWithIdentifier:kAppBundleIdentifier]; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 21f19955d0b05..ebd94839ee28c 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -223,6 +223,14 @@ - (void)registerViewFactory:(nonnull NSObject*)facto [[_flutterEngine platformViewController] registerViewFactory:factory withId:factoryId]; } +- (NSString*)lookupKeyForAsset:(NSString*)asset { + return [FlutterDartProject lookupKeyForAsset:asset]; +} + +- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { + return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; +} + @end // Callbacks provided to the engine. See the called methods for documentation. @@ -1089,56 +1097,3 @@ - (void)postMainThreadTask:(FlutterTask)task targetTimeInNanoseconds:(uint64_t)t } @end - -@implementation FlutterEngineRegistrar { - NSString* _pluginKey; - FlutterEngine* _flutterEngine; -} - -- (instancetype)initWithPlugin:(NSString*)pluginKey flutterEngine:(FlutterEngine*)flutterEngine { - self = [super init]; - if (self) { - _pluginKey = [pluginKey copy]; - _flutterEngine = flutterEngine; - } - return self; -} - -#pragma mark - FlutterPluginRegistrar - -- (id)messenger { - return _flutterEngine.binaryMessenger; -} - -- (id)textures { - return _flutterEngine.renderer; -} - -- (NSView*)view { - if (!_flutterEngine.viewController.viewLoaded) { - [_flutterEngine.viewController loadView]; - } - return _flutterEngine.viewController.flutterView; -} - -- (void)addMethodCallDelegate:(nonnull id)delegate - channel:(nonnull FlutterMethodChannel*)channel { - [channel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) { - [delegate handleMethodCall:call result:result]; - }]; -} - -- (void)registerViewFactory:(nonnull NSObject*)factory - withId:(nonnull NSString*)factoryId { - [[_flutterEngine platformViewController] registerViewFactory:factory withId:factoryId]; -} - -- (NSString*)lookupKeyForAsset:(NSString*)asset { - return [FlutterDartProject lookupKeyForAsset:asset]; -} - -- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { - return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; -} - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm index 4d363526a6f80..d4826eb59edd0 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm @@ -787,11 +787,11 @@ - (void)onKeyboardLayoutChanged { } - (NSString*)lookupKeyForAsset:(NSString*)asset { - return [_engine lookupKeyForAsset:asset]; + return [FlutterDartProject lookupKeyForAsset:asset]; } - (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { - return [_engine lookupKeyForAsset:asset fromPackage:package]; + return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; } #pragma mark - FlutterViewReshapeListener From 971ac3a710c373629ae2576344f4c1b461948304 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Wed, 22 Feb 2023 15:07:49 +0800 Subject: [PATCH 05/15] Fix wrong rebase --- .../darwin/macos/framework/Source/FlutterEngine.mm | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index ebd94839ee28c..ce8580ac6347b 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -71,16 +71,6 @@ - (instancetype)initWithConnection:(NSNumber*)connection #pragma mark - -/** - * `FlutterPluginRegistrar` implementation handling a single plugin. - */ -@interface FlutterEngineRegistrar : NSObject -- (instancetype)initWithPlugin:(nonnull NSString*)pluginKey - flutterEngine:(nonnull FlutterEngine*)flutterEngine; -@end - -#pragma mark - - /** * Private interface declaration for FlutterEngine. */ From 59733710c6aea80b65dc8176c0ed540200976fa2 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Wed, 22 Feb 2023 15:12:43 +0800 Subject: [PATCH 06/15] fix wrong rebase --- .../macos/framework/Source/FlutterEngine.mm | 8 ------- .../framework/Source/FlutterEngine_Internal.h | 23 ------------------- 2 files changed, 31 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index ce8580ac6347b..8afb18cf45f09 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -926,14 +926,6 @@ - (NSPasteboard*)pasteboard { return [NSPasteboard generalPasteboard]; } -- (NSString*)lookupKeyForAsset:(NSString*)asset { - return [FlutterDartProject lookupKeyForAsset:asset]; -} - -- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { - return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; -} - - (std::vector)switches { return flutter::GetSwitchesFromEnvironment(); } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h b/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h index 0430944b64eb3..c617363c66eb8 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h @@ -126,27 +126,4 @@ toTarget:(uint16_t)target withData:(fml::MallocMapping)data; -/** - * Returns the file name for the given asset. - * The returned file name can be used to access the asset in the application's - * main bundle. - * - * @param asset The name of the asset. The name can be hierarchical. - * @return The file name to be used for lookup in the main bundle. - */ -- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset; - -/** - * Returns the file name for the given asset which originates from the specified - * package. - * The returned file name can be used to access the asset in the application's - * main bundle. - * - * @param asset The name of the asset. The name can be hierarchical. - * @param package The name of the package from which the asset originates. - * @return The file name to be used for lookup in the main bundle. - */ -- (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset - fromPackage:(nonnull NSString*)package; - @end From e0c36bff744d1975fb9a0a9ba511218379051436 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 3 Apr 2023 11:17:09 +0800 Subject: [PATCH 07/15] Apply reviews --- .../framework/Headers/FlutterDartProject.h | 18 ++++ .../darwin/common/framework_shared.gni | 1 + shell/platform/darwin/ios/BUILD.gn | 1 - .../framework/Headers/FlutterDartProject.h | 84 ------------------- .../Source/FlutterDartProject_Internal.h | 2 +- shell/platform/darwin/macos/BUILD.gn | 1 - .../framework/Source/FlutterDartProject.mm | 15 +++- .../Source/FlutterDartProject_Internal.h | 2 +- 8 files changed, 33 insertions(+), 91 deletions(-) rename shell/platform/darwin/{macos => common}/framework/Headers/FlutterDartProject.h (89%) delete mode 100644 shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h b/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h similarity index 89% rename from shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h rename to shell/platform/darwin/common/framework/Headers/FlutterDartProject.h index 548286bb61613..e4ebcb14f8d2a 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h +++ b/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h @@ -6,6 +6,7 @@ #define FLUTTER_FLUTTERDARTPROJECT_H_ #import +#import #import "FlutterMacros.h" @@ -29,6 +30,22 @@ FLUTTER_DARWIN_EXPORT - (nonnull instancetype)initWithPrecompiledDartBundle:(nullable NSBundle*)bundle NS_DESIGNATED_INITIALIZER; +#if TARGET_OS_IPHONE +/** + * Unavailable - use `init` instead. + */ +- (nonnull instancetype) + initFromDefaultSourceForConfiguration FLUTTER_UNAVAILABLE("Use -init instead."); + +/** + * Returns the default identifier for the bundle where we expect to find the Flutter Dart + * application. + */ ++ (nonnull NSString*)defaultBundleIdentifier; + +#endif + +#if TARGET_OS_OSX /** * An NSArray of NSStrings to be passed as command line arguments to the Dart entrypoint. * @@ -38,6 +55,7 @@ FLUTTER_DARWIN_EXPORT * Set this to nil to pass no arguments to the Dart entrypoint. */ @property(nonatomic, nullable, copy) NSArray* dartEntrypointArguments; +#endif /** * Returns the file name for the given asset. If the bundle with the identifier diff --git a/shell/platform/darwin/common/framework_shared.gni b/shell/platform/darwin/common/framework_shared.gni index 8a679c4d6fa25..84f50a7da548e 100644 --- a/shell/platform/darwin/common/framework_shared.gni +++ b/shell/platform/darwin/common/framework_shared.gni @@ -9,5 +9,6 @@ framework_shared_headers = "framework/Headers/FlutterChannels.h", "framework/Headers/FlutterCodecs.h", "framework/Headers/FlutterTexture.h", + "framework/Headers/FlutterDartProject.h", ], "abspath") diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index 7a30a1fb16d03..4acf7e2bcf062 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -27,7 +27,6 @@ _flutter_framework_headers = [ "framework/Headers/Flutter.h", "framework/Headers/FlutterAppDelegate.h", "framework/Headers/FlutterCallbackCache.h", - "framework/Headers/FlutterDartProject.h", "framework/Headers/FlutterEngine.h", "framework/Headers/FlutterEngineGroup.h", "framework/Headers/FlutterHeadlessDartRunner.h", diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h b/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h deleted file mode 100644 index cc08cb61bc04c..0000000000000 --- a/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_FLUTTERDARTPROJECT_H_ -#define FLUTTER_FLUTTERDARTPROJECT_H_ - -#import - -#import "FlutterMacros.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - * A set of Flutter and Dart assets used by a `FlutterEngine` to initialize execution. - */ -FLUTTER_DARWIN_EXPORT -@interface FlutterDartProject : NSObject - -/** - * Initializes a Flutter Dart project from a bundle. - */ -- (instancetype)initWithPrecompiledDartBundle:(nullable NSBundle*)bundle NS_DESIGNATED_INITIALIZER; - -/** - * Unavailable - use `init` instead. - */ -- (instancetype)initFromDefaultSourceForConfiguration FLUTTER_UNAVAILABLE("Use -init instead."); - -/** - * Returns the file name for the given asset. If the bundle with the identifier - * "io.flutter.flutter.app" exists, it will try use that bundle; otherwise, it - * will use the main bundle. To specify a different bundle, use - * `+lookupKeyForAsset:fromBundle:`. - * - * @param asset The name of the asset. The name can be hierarchical. - * @return the file name to be used for lookup in the main bundle. - */ -+ (NSString*)lookupKeyForAsset:(NSString*)asset; - -/** - * Returns the file name for the given asset. - * The returned file name can be used to access the asset in the supplied bundle. - * - * @param asset The name of the asset. The name can be hierarchical. - * @param bundle The `NSBundle` to use for looking up the asset. - * @return the file name to be used for lookup in the main bundle. - */ -+ (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle; - -/** - * Returns the file name for the given asset which originates from the specified package. - * The returned file name can be used to access the asset in the application's main bundle. - * - * @param asset The name of the asset. The name can be hierarchical. - * @param package The name of the package from which the asset originates. - * @return the file name to be used for lookup in the main bundle. - */ -+ (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package; - -/** - * Returns the file name for the given asset which originates from the specified package. - * The returned file name can be used to access the asset in the specified bundle. - * - * @param asset The name of the asset. The name can be hierarchical. - * @param package The name of the package from which the asset originates. - * @param bundle The bundle to use when doing the lookup. - * @return the file name to be used for lookup in the main bundle. - */ -+ (NSString*)lookupKeyForAsset:(NSString*)asset - fromPackage:(NSString*)package - fromBundle:(nullable NSBundle*)bundle; - -/** - * Returns the default identifier for the bundle where we expect to find the Flutter Dart - * application. - */ -+ (NSString*)defaultBundleIdentifier; - -@end - -NS_ASSUME_NONNULL_END - -#endif // FLUTTER_FLUTTERDARTPROJECT_H_ diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h index 50a42fe77f318..915092b51556c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h @@ -8,7 +8,7 @@ #include "flutter/common/settings.h" #include "flutter/runtime/platform_data.h" #include "flutter/shell/common/engine.h" -#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h" +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h" NS_ASSUME_NONNULL_BEGIN diff --git a/shell/platform/darwin/macos/BUILD.gn b/shell/platform/darwin/macos/BUILD.gn index 4cbf37b8c0513..27f379718d44e 100644 --- a/shell/platform/darwin/macos/BUILD.gn +++ b/shell/platform/darwin/macos/BUILD.gn @@ -39,7 +39,6 @@ _framework_binary_subpath = "Versions/A/$_flutter_framework_name" _flutter_framework_headers = [ "framework/Headers/FlutterAppDelegate.h", "framework/Headers/FlutterApplication.h", - "framework/Headers/FlutterDartProject.h", "framework/Headers/FlutterEngine.h", "framework/Headers/FlutterMacOS.h", "framework/Headers/FlutterPlatformViews.h", diff --git a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm index 5a7a036d6b967..67bad7968566d 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h" +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h" #include @@ -12,6 +12,15 @@ static NSString* const kICUBundlePath = @"icudtl.dat"; static NSString* const kAppBundleIdentifier = @"io.flutter.flutter.app"; +#pragma mark - Private interface declaration. +@interface FlutterDartProject () +/** + Get the Flutter assets name path by pass the bundle. If bundle is nil, we use the main bundle as + default. + */ ++ (NSString*)flutterAssetsNameWithBundle:(NSBundle*)bundle; +@end + @implementation FlutterDartProject { NSBundle* _dartBundle; NSString* _assetsPath; @@ -81,7 +90,7 @@ - (NSString*)ICUDataPath { return path; } -+ (NSString*)flutterAssetsName:(NSBundle*)bundle { ++ (NSString*)flutterAssetsNameWithBundle:(NSBundle*)bundle { if (bundle == nil) { bundle = [NSBundle bundleWithIdentifier:kAppBundleIdentifier]; } @@ -100,7 +109,7 @@ + (NSString*)lookupKeyForAsset:(NSString*)asset { } + (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle { - NSString* flutterAssetsName = [FlutterDartProject flutterAssetsName:bundle]; + NSString* flutterAssetsName = [FlutterDartProject flutterAssetsNameWithBundle:bundle]; return [NSString stringWithFormat:@"%@/%@", flutterAssetsName, asset]; } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h b/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h index 214933669b039..f8f6de94ebdc8 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h @@ -5,7 +5,7 @@ #ifndef SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_ #define SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_ -#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h" +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h" #include #include From a9249a7094ad02c64d032cc9bc43f4755ae7c323 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 3 Apr 2023 11:41:15 +0800 Subject: [PATCH 08/15] License update --- ci/licenses_golden/licenses_flutter | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 387f2de9cdf6f..689d85979b4c8 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -2449,6 +2449,7 @@ ORIGIN: ../../../flutter/shell/platform/darwin/common/command_line.mm + ../../.. ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannels.mm + ../../../flutter/LICENSE @@ -2467,7 +2468,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTex ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Headers/Flutter.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterCallbackCache.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngineGroup.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterHeadlessDartRunner.h + ../../../flutter/LICENSE @@ -2604,7 +2604,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/rendering_api_selection.h + . ORIGIN: ../../../flutter/shell/platform/darwin/ios/rendering_api_selection.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterAppDelegate.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterApplication.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterMacOS.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterPlatformViews.h + ../../../flutter/LICENSE @@ -5039,6 +5038,7 @@ FILE: ../../../flutter/shell/platform/darwin/common/command_line.mm FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h +FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannels.mm @@ -5057,7 +5057,6 @@ FILE: ../../../flutter/shell/platform/darwin/graphics/FlutterDarwinExternalTextu FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/Flutter.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterCallbackCache.h -FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngineGroup.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterHeadlessDartRunner.h @@ -5196,7 +5195,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/rendering_api_selection.h FILE: ../../../flutter/shell/platform/darwin/ios/rendering_api_selection.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterAppDelegate.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterApplication.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterMacOS.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterPlatformViews.h From eddd1b1edf7ccba32f87d66ee4665459ffe7cd28 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 3 Apr 2023 15:58:23 +0800 Subject: [PATCH 09/15] Optimize bundle search time --- .../framework/Source/FlutterDartProject.mm | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm index 67bad7968566d..fc0f4aa885051 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm @@ -12,6 +12,50 @@ static NSString* const kICUBundlePath = @"icudtl.dat"; static NSString* const kAppBundleIdentifier = @"io.flutter.flutter.app"; +// 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* bundleID, NSURL* searchURL) { + NSDirectoryEnumerator* frameworkEnumerator = [NSFileManager.defaultManager + enumeratorAtURL:searchURL + includingPropertiesForKeys:nil + options:NSDirectoryEnumerationSkipsSubdirectoryDescendants | + NSDirectoryEnumerationSkipsHiddenFiles + // Skip directories where errors are encountered. + errorHandler:nil]; + + for (NSURL* candidate in frameworkEnumerator) { + NSBundle* bundle = [NSBundle bundleWithURL:candidate]; + if ([bundle.bundleIdentifier isEqualToString:bundleID]) { + return bundle; + } + } + return nil; +} + +// 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 +// in a medium sized Flutter app on an iPhone 13. It is likely that the slowness +// comes from having to traverse and load all bundles known to the process. +// Using `+[NSBundle allframeworks]` and filtering also suffers from the same +// problem. +// +// This implementation is an optimization to first limit the search space to +// `+[NSBundle privateFrameworksURL]` of the main bundle, which is usually where +// frameworks used by this file are placed. If the desired bundle cannot be +// found here, the implementation falls back to +// `+[NSBundle bundleWithIdentifier:]`. +NS_INLINE NSBundle* FLTFrameworkBundleWithIdentifier(NSString* bundleID) { + NSBundle* bundle = FLTFrameworkBundleInternal(bundleID, NSBundle.mainBundle.privateFrameworksURL); + if (bundle != nil) { + return bundle; + } + // Fallback to slow implementation. + return [NSBundle bundleWithIdentifier:bundleID]; +} + #pragma mark - Private interface declaration. @interface FlutterDartProject () /** @@ -35,7 +79,7 @@ - (instancetype)initWithPrecompiledDartBundle:(NSBundle*)bundle { self = [super init]; NSAssert(self, @"Super init cannot be nil"); - _dartBundle = bundle ?: [NSBundle bundleWithIdentifier:kAppBundleIdentifier]; + _dartBundle = bundle ?: FLTFrameworkBundleWithIdentifier(kAppBundleIdentifier); if (_dartBundle == nil) { // The bundle isn't loaded and can't be found by bundle ID. Find it by path. _dartBundle = [NSBundle bundleWithURL:[NSBundle.mainBundle.privateFrameworksURL @@ -92,7 +136,7 @@ - (NSString*)ICUDataPath { + (NSString*)flutterAssetsNameWithBundle:(NSBundle*)bundle { if (bundle == nil) { - bundle = [NSBundle bundleWithIdentifier:kAppBundleIdentifier]; + bundle = FLTFrameworkBundleWithIdentifier(kAppBundleIdentifier); } if (bundle == nil) { bundle = [NSBundle mainBundle]; From c270f94f5d7b714bf29aaf04624e6c03248ff821 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Tue, 4 Apr 2023 11:41:38 +0800 Subject: [PATCH 10/15] Reviews Applied --- shell/platform/darwin/common/BUILD.gn | 1 + .../framework/Headers/FlutterDartProject.h | 36 ++++++-------- .../Source/FlutterDartProjectHelper.mm | 49 +++++++++++++++++++ .../framework/Source/FlutterDartProject.mm | 44 ----------------- .../Source/FlutterDartProject_Internal.h | 1 + .../framework/Source/FlutterDartProject.mm | 44 ----------------- .../Source/FlutterDartProject_Internal.h | 2 + 7 files changed, 69 insertions(+), 108 deletions(-) create mode 100644 shell/platform/darwin/common/framework/Source/FlutterDartProjectHelper.mm diff --git a/shell/platform/darwin/common/BUILD.gn b/shell/platform/darwin/common/BUILD.gn index a3210bfed4d25..3e851c55f5d13 100644 --- a/shell/platform/darwin/common/BUILD.gn +++ b/shell/platform/darwin/common/BUILD.gn @@ -36,6 +36,7 @@ source_set("framework_shared") { sources = [ "framework/Source/FlutterChannels.mm", "framework/Source/FlutterCodecs.mm", + "framework/Source/FlutterDartProjectHelper.mm", "framework/Source/FlutterStandardCodec.mm", "framework/Source/FlutterStandardCodecHelper.cc", "framework/Source/FlutterStandardCodec_Internal.h", diff --git a/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h b/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h index e4ebcb14f8d2a..9b5f1366cf48a 100644 --- a/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h +++ b/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h @@ -10,6 +10,8 @@ #import "FlutterMacros.h" +NS_ASSUME_NONNULL_BEGIN + /** * A set of Flutter and Dart assets used by a `FlutterEngine` to initialize execution. * @@ -27,25 +29,19 @@ FLUTTER_DARWIN_EXPORT * @param bundle The bundle containing the Flutter assets directory. If nil, the App framework * created by Flutter will be used. */ -- (nonnull instancetype)initWithPrecompiledDartBundle:(nullable NSBundle*)bundle - NS_DESIGNATED_INITIALIZER; - -#if TARGET_OS_IPHONE +- (instancetype)initWithPrecompiledDartBundle:(nullable NSBundle*)bundle NS_DESIGNATED_INITIALIZER; /** * Unavailable - use `init` instead. */ -- (nonnull instancetype) - initFromDefaultSourceForConfiguration FLUTTER_UNAVAILABLE("Use -init instead."); +- (instancetype)initFromDefaultSourceForConfiguration API_UNAVAILABLE(macos) + FLUTTER_UNAVAILABLE("Use -init instead."); /** * Returns the default identifier for the bundle where we expect to find the Flutter Dart * application. */ -+ (nonnull NSString*)defaultBundleIdentifier; ++ (NSString*)defaultBundleIdentifier API_UNAVAILABLE(macos); -#endif - -#if TARGET_OS_OSX /** * An NSArray of NSStrings to be passed as command line arguments to the Dart entrypoint. * @@ -54,8 +50,8 @@ FLUTTER_DARWIN_EXPORT * * Set this to nil to pass no arguments to the Dart entrypoint. */ -@property(nonatomic, nullable, copy) NSArray* dartEntrypointArguments; -#endif +@property(nonatomic, nullable, copy) + NSArray* dartEntrypointArguments API_UNAVAILABLE(ios); /** * Returns the file name for the given asset. If the bundle with the identifier @@ -66,7 +62,7 @@ FLUTTER_DARWIN_EXPORT * @param asset The name of the asset. The name can be hierarchical. * @return the file name to be used for lookup in the main bundle. */ -+ (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset; ++ (NSString*)lookupKeyForAsset:(NSString*)asset; /** * Returns the file name for the given asset. @@ -76,8 +72,7 @@ FLUTTER_DARWIN_EXPORT * @param bundle The `NSBundle` to use for looking up the asset. * @return the file name to be used for lookup in the main bundle. */ -+ (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset - fromBundle:(nullable NSBundle*)bundle; ++ (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(nullable NSBundle*)bundle; /** * Returns the file name for the given asset which originates from the specified package. @@ -87,8 +82,7 @@ FLUTTER_DARWIN_EXPORT * @param package The name of the package from which the asset originates. * @return the file name to be used for lookup in the main bundle. */ -+ (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset - fromPackage:(nonnull NSString*)package; ++ (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package; /** * Returns the file name for the given asset which originates from the specified package. @@ -99,10 +93,12 @@ FLUTTER_DARWIN_EXPORT * @param bundle The bundle to use when doing the lookup. * @return the file name to be used for lookup in the main bundle. */ -+ (nonnull NSString*)lookupKeyForAsset:(nonnull NSString*)asset - fromPackage:(nonnull NSString*)package - fromBundle:(nullable NSBundle*)bundle; ++ (NSString*)lookupKeyForAsset:(NSString*)asset + fromPackage:(NSString*)package + fromBundle:(nullable NSBundle*)bundle; @end +NS_ASSUME_NONNULL_END + #endif // FLUTTER_FLUTTERDARTPROJECT_H_ diff --git a/shell/platform/darwin/common/framework/Source/FlutterDartProjectHelper.mm b/shell/platform/darwin/common/framework/Source/FlutterDartProjectHelper.mm new file mode 100644 index 0000000000000..73bfe940fc486 --- /dev/null +++ b/shell/platform/darwin/common/framework/Source/FlutterDartProjectHelper.mm @@ -0,0 +1,49 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include + +// 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* bundleID, NSURL* searchURL) { + NSDirectoryEnumerator* frameworkEnumerator = [NSFileManager.defaultManager + enumeratorAtURL:searchURL + includingPropertiesForKeys:nil + options:NSDirectoryEnumerationSkipsSubdirectoryDescendants | + NSDirectoryEnumerationSkipsHiddenFiles + // Skip directories where errors are encountered. + errorHandler:nil]; + + for (NSURL* candidate in frameworkEnumerator) { + NSBundle* bundle = [NSBundle bundleWithURL:candidate]; + if ([bundle.bundleIdentifier isEqualToString:bundleID]) { + return bundle; + } + } + return nil; +} + +// 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 +// in a medium sized Flutter app on an iPhone 13. It is likely that the slowness +// comes from having to traverse and load all bundles known to the process. +// Using `+[NSBundle allframeworks]` and filtering also suffers from the same +// problem. +// +// This implementation is an optimization to first limit the search space to +// `+[NSBundle privateFrameworksURL]` of the main bundle, which is usually where +// 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* bundleID) { + NSBundle* bundle = FLTFrameworkBundleInternal(bundleID, NSBundle.mainBundle.privateFrameworksURL); + if (bundle != nil) { + return bundle; + } + // Fallback to slow implementation. + return [NSBundle bundleWithIdentifier:bundleID]; +} diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index 1830ad67eb4cb..e0b0cf56c33c7 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -32,50 +32,6 @@ static const char* kApplicationKernelSnapshotFileName = "kernel_blob.bin"; -// 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* bundleID, NSURL* searchURL) { - NSDirectoryEnumerator* frameworkEnumerator = [NSFileManager.defaultManager - enumeratorAtURL:searchURL - includingPropertiesForKeys:nil - options:NSDirectoryEnumerationSkipsSubdirectoryDescendants | - NSDirectoryEnumerationSkipsHiddenFiles - // Skip directories where errors are encountered. - errorHandler:nil]; - - for (NSURL* candidate in frameworkEnumerator) { - NSBundle* bundle = [NSBundle bundleWithURL:candidate]; - if ([bundle.bundleIdentifier isEqualToString:bundleID]) { - return bundle; - } - } - return nil; -} - -// 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 -// in a medium sized Flutter app on an iPhone 13. It is likely that the slowness -// comes from having to traverse and load all bundles known to the process. -// Using `+[NSBundle allframeworks]` and filtering also suffers from the same -// problem. -// -// This implementation is an optimization to first limit the search space to -// `+[NSBundle privateFrameworksURL]` of the main bundle, which is usually where -// frameworks used by this file are placed. If the desired bundle cannot be -// found here, the implementation falls back to -// `+[NSBundle bundleWithIdentifier:]`. -NS_INLINE NSBundle* FLTFrameworkBundleWithIdentifier(NSString* bundleID) { - NSBundle* bundle = FLTFrameworkBundleInternal(bundleID, NSBundle.mainBundle.privateFrameworksURL); - if (bundle != nil) { - return bundle; - } - // Fallback to slow implementation. - return [NSBundle bundleWithIdentifier:bundleID]; -} - flutter::Settings FLTDefaultSettingsForBundle(NSBundle* bundle) { auto command_line = flutter::CommandLineFromNSProcessInfo(); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h index 915092b51556c..5fb7d33a1d0ce 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h @@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN NSBundle* FLTFrameworkBundleInternal(NSString* bundleID, NSURL* searchURL); +NSBundle* FLTFrameworkBundleWithIdentifier(NSString* bundleID); flutter::Settings FLTDefaultSettingsForBundle(NSBundle* bundle = nil); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm index fc0f4aa885051..4f5387aa010a6 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm @@ -12,50 +12,6 @@ static NSString* const kICUBundlePath = @"icudtl.dat"; static NSString* const kAppBundleIdentifier = @"io.flutter.flutter.app"; -// 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* bundleID, NSURL* searchURL) { - NSDirectoryEnumerator* frameworkEnumerator = [NSFileManager.defaultManager - enumeratorAtURL:searchURL - includingPropertiesForKeys:nil - options:NSDirectoryEnumerationSkipsSubdirectoryDescendants | - NSDirectoryEnumerationSkipsHiddenFiles - // Skip directories where errors are encountered. - errorHandler:nil]; - - for (NSURL* candidate in frameworkEnumerator) { - NSBundle* bundle = [NSBundle bundleWithURL:candidate]; - if ([bundle.bundleIdentifier isEqualToString:bundleID]) { - return bundle; - } - } - return nil; -} - -// 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 -// in a medium sized Flutter app on an iPhone 13. It is likely that the slowness -// comes from having to traverse and load all bundles known to the process. -// Using `+[NSBundle allframeworks]` and filtering also suffers from the same -// problem. -// -// This implementation is an optimization to first limit the search space to -// `+[NSBundle privateFrameworksURL]` of the main bundle, which is usually where -// frameworks used by this file are placed. If the desired bundle cannot be -// found here, the implementation falls back to -// `+[NSBundle bundleWithIdentifier:]`. -NS_INLINE NSBundle* FLTFrameworkBundleWithIdentifier(NSString* bundleID) { - NSBundle* bundle = FLTFrameworkBundleInternal(bundleID, NSBundle.mainBundle.privateFrameworksURL); - if (bundle != nil) { - return bundle; - } - // Fallback to slow implementation. - return [NSBundle bundleWithIdentifier:bundleID]; -} - #pragma mark - Private interface declaration. @interface FlutterDartProject () /** diff --git a/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h b/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h index f8f6de94ebdc8..c43d1029d6280 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h @@ -10,6 +10,8 @@ #include #include +NSBundle* _Nullable FLTFrameworkBundleWithIdentifier(NSString* _Nonnull bundleID); + /** * Provides access to data needed to construct a FlutterProjectArgs for the project. */ From 48eb2fa609d357c22caa2e18c503dfaaaaebab3c Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Tue, 4 Apr 2023 12:32:18 +0800 Subject: [PATCH 11/15] Resolve conflict --- .../darwin/ios/framework/Source/FlutterDartProject.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index 913f0edb3547d..30f50a18a486c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -32,8 +32,8 @@ static const char* kApplicationKernelSnapshotFileName = "kernel_blob.bin"; -flutter::Settings FLTDefaultSettingsForBundle(NSBundle* bundle) { - auto command_line = flutter::CommandLineFromNSProcessInfo(); +flutter::Settings FLTDefaultSettingsForBundle(NSBundle* bundle, NSProcessInfo* processInfoOrNil) { + auto command_line = flutter::CommandLineFromNSProcessInfo(processInfoOrNil); // Precedence: // 1. Settings from the specified NSBundle (except for enable-impeller). From 335ad66f639a26669da0ff342bbdff09f98105c8 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Tue, 4 Apr 2023 12:46:42 +0800 Subject: [PATCH 12/15] License update --- ci/licenses_golden/licenses_flutter | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 81d1eda533a55..45fb39b921a69 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -2457,6 +2457,7 @@ ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterT ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannels.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannelsTest.m + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterCodecs.mm + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterDartProjectHelper.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.h + ../../../flutter/LICENSE @@ -5050,6 +5051,7 @@ FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterTex FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannels.mm FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannelsTest.m FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterCodecs.mm +FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterDartProjectHelper.mm FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec.mm FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.cc FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.h From 3d06ecfc4e7faa3af508e9a06a80761ba3c809f5 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Thu, 6 Apr 2023 09:40:18 +0800 Subject: [PATCH 13/15] Avoid of clang checker error --- .../darwin/ios/framework/Source/FlutterDartProject.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index 30f50a18a486c..a61ab0568795f 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -242,6 +242,11 @@ @implementation FlutterDartProject { flutter::Settings _settings; } +// This property is marked unavailable on iOS in the common header. +// That doesn't seem to be enough to prevent this property from being synthesized. +// Mark dynamic to avoid warnings. +@dynamic dartEntrypointArguments; + #pragma mark - Override base class designated initializers - (instancetype)init { From 4e0925b94598fb1ca801845bf156c5744c108e7a Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Fri, 14 Apr 2023 11:25:48 +0800 Subject: [PATCH 14/15] Apply reviews --- shell/platform/darwin/common/BUILD.gn | 5 ++- .../framework/Headers/FlutterDartProject.h | 3 +- .../framework/Source/FlutterNSBundleUtils.h | 35 +++++++++++++++++++ ...ojectHelper.mm => FlutterNSBundleUtils.mm} | 17 --------- .../Source/FlutterDartProject_Internal.h | 4 +-- .../framework/Source/FlutterDartProject.mm | 4 +++ .../Source/FlutterDartProject_Internal.h | 3 +- .../Source/FlutterViewControllerTest.mm | 11 +++++- 8 files changed, 56 insertions(+), 26 deletions(-) create mode 100644 shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h rename shell/platform/darwin/common/framework/Source/{FlutterDartProjectHelper.mm => FlutterNSBundleUtils.mm} (57%) diff --git a/shell/platform/darwin/common/BUILD.gn b/shell/platform/darwin/common/BUILD.gn index 3e851c55f5d13..d7c0a0cf17be6 100644 --- a/shell/platform/darwin/common/BUILD.gn +++ b/shell/platform/darwin/common/BUILD.gn @@ -36,7 +36,8 @@ source_set("framework_shared") { sources = [ "framework/Source/FlutterChannels.mm", "framework/Source/FlutterCodecs.mm", - "framework/Source/FlutterDartProjectHelper.mm", + "framework/Source/FlutterNSBundleUtils.h", + "framework/Source/FlutterNSBundleUtils.mm", "framework/Source/FlutterStandardCodec.mm", "framework/Source/FlutterStandardCodecHelper.cc", "framework/Source/FlutterStandardCodec_Internal.h", @@ -44,6 +45,8 @@ source_set("framework_shared") { public = framework_shared_headers + public += [ "framework/Source/FlutterNSBundleUtils.h" ] + defines = [ "FLUTTER_FRAMEWORK" ] public_configs = [ diff --git a/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h b/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h index 9b5f1366cf48a..2878a1d202e57 100644 --- a/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h +++ b/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h @@ -15,7 +15,6 @@ NS_ASSUME_NONNULL_BEGIN /** * A set of Flutter and Dart assets used by a `FlutterEngine` to initialize execution. * - * TODO(stuartmorgan): Align API with FlutterDartProject, and combine. */ FLUTTER_DARWIN_EXPORT @interface FlutterDartProject : NSObject @@ -40,7 +39,7 @@ FLUTTER_DARWIN_EXPORT * Returns the default identifier for the bundle where we expect to find the Flutter Dart * application. */ -+ (NSString*)defaultBundleIdentifier API_UNAVAILABLE(macos); ++ (NSString*)defaultBundleIdentifier; /** * An NSArray of NSStrings to be passed as command line arguments to the Dart entrypoint. diff --git a/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h b/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h new file mode 100644 index 0000000000000..569b551cfa951 --- /dev/null +++ b/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h @@ -0,0 +1,35 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_SOURCE_FLUTTERNSBUNDLEUTILS_H_ +#define SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_SOURCE_FLUTTERNSBUNDLEUTILS_H_ + +#import + +NS_ASSUME_NONNULL_BEGIN + +// 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* bundleID, NSURL* searchURL); + +// 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 +// in a medium sized Flutter app on an iPhone 13. It is likely that the slowness +// comes from having to traverse and load all bundles known to the process. +// Using `+[NSBundle allframeworks]` and filtering also suffers from the same +// problem. +// +// This implementation is an optimization to first limit the search space to +// `+[NSBundle privateFrameworksURL]` of the main bundle, which is usually where +// 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* bundleID); + +NS_ASSUME_NONNULL_END + +#endif // SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_SOURCE_FLUTTERNSBUNDLEUTILS_H_ diff --git a/shell/platform/darwin/common/framework/Source/FlutterDartProjectHelper.mm b/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.mm similarity index 57% rename from shell/platform/darwin/common/framework/Source/FlutterDartProjectHelper.mm rename to shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.mm index 73bfe940fc486..7ad26579f511c 100644 --- a/shell/platform/darwin/common/framework/Source/FlutterDartProjectHelper.mm +++ b/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.mm @@ -4,9 +4,6 @@ #include -// 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* bundleID, NSURL* searchURL) { NSDirectoryEnumerator* frameworkEnumerator = [NSFileManager.defaultManager enumeratorAtURL:searchURL @@ -25,20 +22,6 @@ return nil; } -// 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 -// in a medium sized Flutter app on an iPhone 13. It is likely that the slowness -// comes from having to traverse and load all bundles known to the process. -// Using `+[NSBundle allframeworks]` and filtering also suffers from the same -// problem. -// -// This implementation is an optimization to first limit the search space to -// `+[NSBundle privateFrameworksURL]` of the main bundle, which is usually where -// 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* bundleID) { NSBundle* bundle = FLTFrameworkBundleInternal(bundleID, NSBundle.mainBundle.privateFrameworksURL); if (bundle != nil) { diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h index 64e378344b703..8ca970a337f7c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h @@ -9,12 +9,10 @@ #include "flutter/runtime/platform_data.h" #include "flutter/shell/common/engine.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h" +#import "flutter/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h" NS_ASSUME_NONNULL_BEGIN -NSBundle* FLTFrameworkBundleInternal(NSString* bundleID, NSURL* searchURL); -NSBundle* FLTFrameworkBundleWithIdentifier(NSString* bundleID); - flutter::Settings FLTDefaultSettingsForBundle(NSBundle* _Nullable bundle = nil, NSProcessInfo* _Nullable processInfoOrNil = nil); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm index 4f5387aa010a6..8391e4f8b4550 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm @@ -124,4 +124,8 @@ + (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:bundle]; } ++ (NSString*)defaultBundleIdentifier { + return kAppBundleIdentifier; +} + @end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h b/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h index c43d1029d6280..0e0cad3757152 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h @@ -6,12 +6,11 @@ #define SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERDARTPROJECT_INTERNAL_H_ #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterDartProject.h" +#import "flutter/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h" #include #include -NSBundle* _Nullable FLTFrameworkBundleWithIdentifier(NSString* _Nonnull bundleID); - /** * Provides access to data needed to construct a FlutterProjectArgs for the project. */ diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm index 13ef5b880ba1f..1e29259824147 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm @@ -67,6 +67,7 @@ - (bool)testModifierKeysAreSynthesizedOnMouseMove; - (bool)testViewWillAppearCalledMultipleTimes; - (bool)testFlutterViewIsConfigured; - (bool)testLookupKeyAssets; +- (bool)testLookupKeyAssetsWithPackage; + (void)respondFalseForSendEvent:(const FlutterKeyEvent&)event callback:(nullable FlutterKeyEventCallback)callback @@ -241,6 +242,10 @@ id MockGestureEvent(NSEventType type, NSEventPhase phase, double magnification, ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testLookupKeyAssets]); } +TEST(FlutterViewControllerTest, testLookupKeyAssetsWithPackage) { + ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testLookupKeyAssetsWithPackage]); +} + } // namespace flutter::testing #pragma mark - FlutterViewControllerTestObjC @@ -842,9 +847,13 @@ - (bool)testLookupKeyAssets { NSString* key = [viewController lookupKeyForAsset:@"test.png"]; EXPECT_TRUE( [key isEqualToString:@"Contents/Frameworks/App.framework/Resources/flutter_assets/test.png"]); + return true; +} + +- (bool)testLookupKeyAssetsWithPackage { + FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:nil]; NSString* packageKey = [viewController lookupKeyForAsset:@"test.png" fromPackage:@"test"]; - NSLog(@"%@", packageKey); EXPECT_TRUE([packageKey isEqualToString: @"Contents/Frameworks/App.framework/Resources/flutter_assets/packages/test/test.png"]); From 3b3e6aa2da8a71a1e56af370318c1a34740ea7d3 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Fri, 14 Apr 2023 13:04:55 +0800 Subject: [PATCH 15/15] Add licence --- ci/licenses_golden/licenses_flutter | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index bfa730de496bb..8f80d70a8ab5f 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -2464,7 +2464,8 @@ ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterT ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannels.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannelsTest.m + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterCodecs.mm + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterDartProjectHelper.mm + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h + ../../../flutter/LICENSE +ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.h + ../../../flutter/LICENSE @@ -5063,7 +5064,8 @@ FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterTex FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannels.mm FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannelsTest.m FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterCodecs.mm -FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterDartProjectHelper.mm +FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.h +FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterNSBundleUtils.mm FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec.mm FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.cc FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.h