|
9 | 9 | FLUTTER_ASSERT_ARC |
10 | 10 |
|
11 | 11 | const NSString* kDefaultAssetPath = @"Frameworks/App.framework/flutter_assets"; |
12 | | -static NSString* GetFlutterAssetPathFromBundle(NSBundle* bundle); |
13 | 12 |
|
14 | 13 | NSBundle* FLTFrameworkBundleInternal(NSString* flutterFrameworkBundleID, NSURL* searchURL) { |
15 | 14 | NSDirectoryEnumerator<NSURL*>* frameworkEnumerator = [NSFileManager.defaultManager |
|
30 | 29 | } |
31 | 30 |
|
32 | 31 | NSBundle* FLTGetApplicationBundle() { |
33 | | - NSBundle* mainBundle = NSBundle.mainBundle; |
| 32 | + NSBundle* mainBundle = [NSBundle mainBundle]; |
34 | 33 | // App extension bundle is in <AppName>.app/PlugIns/Extension.appex. |
35 | 34 | if ([mainBundle.bundleURL.pathExtension isEqualToString:@"appex"]) { |
36 | 35 | // Up two levels. |
|
49 | 48 | flutterFrameworkBundle = [NSBundle bundleWithIdentifier:flutterFrameworkBundleID]; |
50 | 49 | } |
51 | 50 | if (flutterFrameworkBundle == nil) { |
52 | | - flutterFrameworkBundle = NSBundle.mainBundle; |
| 51 | + flutterFrameworkBundle = [NSBundle mainBundle]; |
53 | 52 | } |
54 | 53 | return flutterFrameworkBundle; |
55 | 54 | } |
|
59 | 58 | } |
60 | 59 |
|
61 | 60 | NSString* FLTAssetsPathFromBundle(NSBundle* bundle) { |
62 | | - NSString* flutterAssetsPath = GetFlutterAssetPathFromBundle(bundle); |
63 | | - if (flutterAssetsPath.length == 0) { |
64 | | - flutterAssetsPath = GetFlutterAssetPathFromBundle(NSBundle.mainBundle); |
65 | | - } |
66 | | - return flutterAssetsPath; |
67 | | -} |
68 | | - |
69 | | -static NSString* GetFlutterAssetPathFromBundle(NSBundle* bundle) { |
70 | 61 | NSString* flutterAssetsPath = FLTAssetPath(bundle); |
71 | 62 | // Use the raw path solution so that asset path can be returned from unloaded bundles. |
72 | 63 | // See https://github.com/flutter/engine/pull/46073 |
73 | | - NSString* assetsPath = [bundle pathForResource:flutterAssetsPath ofType:nil]; |
| 64 | + NSString* assetsPath = [bundle pathForResource:flutterAssetsPath ofType:@""]; |
| 65 | + |
74 | 66 | if (assetsPath.length == 0) { |
75 | | - // In app extension, using full relative path (kDefaultAssetPath) |
76 | | - // returns nil when the app bundle is not loaded. Try to use |
77 | | - // the sub folder name, which can successfully return a valid path. |
78 | | - assetsPath = [bundle pathForResource:@"flutter_assets" ofType:nil]; |
| 67 | + assetsPath = [[NSBundle mainBundle] pathForResource:flutterAssetsPath ofType:@""]; |
79 | 68 | } |
80 | 69 | return assetsPath; |
81 | 70 | } |
0 commit comments