From b79bcc1bc74db7519abf865b221894b63cbb1901 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 9 Dec 2020 18:03:27 -0800 Subject: [PATCH] Load iOS dart bundle by URL fallback --- .../ios/framework/Source/FlutterDartProject.mm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index d22a9684f3b2a..cb2e70bf96728 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -43,6 +43,11 @@ if (bundle == nil) { bundle = [NSBundle bundleWithIdentifier:[FlutterDartProject defaultBundleIdentifier]]; } + if (bundle == nil) { + // The bundle isn't loaded and can't be found by bundle ID. Find it by path. + bundle = [NSBundle bundleWithURL:[NSBundle.mainBundle.privateFrameworksURL + URLByAppendingPathComponent:@"App.framework"]]; + } if (bundle == nil) { bundle = mainBundle; } @@ -239,11 +244,16 @@ + (NSString*)flutterAssetsName:(NSBundle*)bundle { bundle = [NSBundle bundleWithIdentifier:[FlutterDartProject defaultBundleIdentifier]]; } if (bundle == nil) { - bundle = [NSBundle mainBundle]; + // The bundle isn't loaded and can't be found by bundle ID. Find it by path. + bundle = [NSBundle bundleWithURL:[NSBundle.mainBundle.privateFrameworksURL + URLByAppendingPathComponent:@"App.framework"]]; } NSString* flutterAssetsName = [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"]; - if (flutterAssetsName == nil) { + if (bundle == nil) { + bundle = [NSBundle mainBundle]; flutterAssetsName = @"Frameworks/App.framework/flutter_assets"; + } else if (flutterAssetsName == nil) { + flutterAssetsName = @"flutter_assets"; } return flutterAssetsName; }