-
Notifications
You must be signed in to change notification settings - Fork 6k
[ios] Fix app extension not able to find assets from unloaded bundle #46283
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,10 +61,23 @@ | |
| NSString* flutterAssetsPath = FLTAssetPath(bundle); | ||
| // Use the raw path solution so that asset path can be returned from unloaded bundles. | ||
| // See https://github.com/flutter/engine/pull/46073 | ||
| NSString* assetsPath = [bundle pathForResource:flutterAssetsPath ofType:@""]; | ||
| NSString* assetsPath = [bundle pathForResource:flutterAssetsPath ofType:nil]; | ||
| if (assetsPath.length == 0) { | ||
| // In app extension, using full relative path(kDefaultAssetPath) | ||
| // returns nil when the app bundle is not loaded. We try to use | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: "We try" -> "Try". |
||
| // the sub folder name, which can successfully return a valid path. | ||
| assetsPath = [bundle pathForResource:@"flutter_assets" ofType:nil]; | ||
| } | ||
|
|
||
| if (assetsPath.length == 0) { | ||
| assetsPath = [[NSBundle mainBundle] pathForResource:flutterAssetsPath ofType:nil]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: we may as well modernize while we are touching this and use |
||
| } | ||
|
|
||
| if (assetsPath.length == 0) { | ||
| assetsPath = [[NSBundle mainBundle] pathForResource:flutterAssetsPath ofType:@""]; | ||
| // In app extension, using full relative path(kDefaultAssetPath) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comments here. But rather than duplicating everything including the comments twice, let's extract a private ( |
||
| // returns nil when the app bundle is not loaded. We try to use | ||
| // the sub folder name, which can successfully return a valid path. | ||
| assetsPath = [[NSBundle mainBundle] pathForResource:@"flutter_assets" ofType:nil]; | ||
| } | ||
| return assetsPath; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: missing space before "(".