Add overloads for lookup that lets you specify a bundle (flutter/engine#8007)
* Add overloads for lookup that lets you specify a bundle * check bundle with defaultBundleIdentifier before main bundle
This commit is contained in:
@@ -26,14 +26,26 @@ FLUTTER_EXPORT
|
||||
- (instancetype)initFromDefaultSourceForConfiguration FLUTTER_UNAVAILABLE("Use -init instead.");
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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`.
|
||||
*
|
||||
* @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:(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.
|
||||
@@ -44,6 +56,19 @@ FLUTTER_EXPORT
|
||||
*/
|
||||
+ (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:(NSBundle*)bundle;
|
||||
|
||||
/**
|
||||
* Returns the default identifier for the bundle where we expect to find the Flutter Dart
|
||||
* application.
|
||||
|
||||
@@ -199,6 +199,12 @@ static blink::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) {
|
||||
#pragma mark - Assets-related utilities
|
||||
|
||||
+ (NSString*)flutterAssetsName:(NSBundle*)bundle {
|
||||
if (bundle == nil) {
|
||||
bundle = [NSBundle bundleWithIdentifier:[FlutterDartProject defaultBundleIdentifier]];
|
||||
}
|
||||
if (bundle == nil) {
|
||||
bundle = [NSBundle mainBundle];
|
||||
}
|
||||
NSString* flutterAssetsName = [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"];
|
||||
if (flutterAssetsName == nil) {
|
||||
flutterAssetsName = @"Frameworks/App.framework/flutter_assets";
|
||||
@@ -207,12 +213,23 @@ static blink::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) {
|
||||
}
|
||||
|
||||
+ (NSString*)lookupKeyForAsset:(NSString*)asset {
|
||||
NSString* flutterAssetsName = [FlutterDartProject flutterAssetsName:[NSBundle mainBundle]];
|
||||
return [self lookupKeyForAsset:asset fromBundle:nil];
|
||||
}
|
||||
|
||||
+ (NSString*)lookupKeyForAsset:(NSString*)asset fromBundle:(NSBundle*)bundle {
|
||||
NSString* flutterAssetsName = [FlutterDartProject flutterAssetsName:bundle];
|
||||
return [NSString stringWithFormat:@"%@/%@", flutterAssetsName, asset];
|
||||
}
|
||||
|
||||
+ (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package {
|
||||
return [self lookupKeyForAsset:[NSString stringWithFormat:@"packages/%@/%@", package, asset]];
|
||||
return [self lookupKeyForAsset:asset fromPackage:package fromBundle:nil];
|
||||
}
|
||||
|
||||
+ (NSString*)lookupKeyForAsset:(NSString*)asset
|
||||
fromPackage:(NSString*)package
|
||||
fromBundle:(NSBundle*)bundle {
|
||||
return [self lookupKeyForAsset:[NSString stringWithFormat:@"packages/%@/%@", package, asset]
|
||||
fromBundle:bundle];
|
||||
}
|
||||
|
||||
+ (NSString*)defaultBundleIdentifier {
|
||||
|
||||
Reference in New Issue
Block a user