Flutter Engine
The Flutter Engine
Functions | Variables
FlutterNSBundleUtils.h File Reference
#import <Foundation/Foundation.h>

Go to the source code of this file.

Functions

NSBundle * FLTFrameworkBundleInternal (NSString *flutterFrameworkBundleID, NSURL *searchURL)
 
NSBundle * FLTFrameworkBundleWithIdentifier (NSString *flutterFrameworkBundleID)
 
NSBundle * FLTGetApplicationBundle ()
 
NSString * FLTAssetPath (NSBundle *bundle)
 
NSString * FLTAssetsPathFromBundle (NSBundle *bundle)
 

Variables

NS_ASSUME_NONNULL_BEGIN const NSString * kDefaultAssetPath
 

Function Documentation

◆ FLTAssetPath()

NSString * FLTAssetPath ( NSBundle *  bundle)

Definition at line 57 of file FlutterNSBundleUtils.mm.

57 {
58 return [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"] ?: kDefaultAssetPath;
59}
FLUTTER_ASSERT_ARC const NSString * kDefaultAssetPath

◆ FLTAssetsPathFromBundle()

NSString * FLTAssetsPathFromBundle ( NSBundle *  bundle)

Definition at line 61 of file FlutterNSBundleUtils.mm.

61 {
62 NSString* relativeAssetsPath = FLTAssetPath(bundle);
63 NSString* flutterAssetsPath = GetFlutterAssetsPathFromBundle(bundle, relativeAssetsPath);
64 if (flutterAssetsPath.length == 0) {
65 flutterAssetsPath = GetFlutterAssetsPathFromBundle(NSBundle.mainBundle, relativeAssetsPath);
66 }
67 return flutterAssetsPath;
68}
static NSString * GetFlutterAssetsPathFromBundle(NSBundle *bundle, NSString *relativeAssetsPath)
NSString * FLTAssetPath(NSBundle *bundle)

◆ FLTFrameworkBundleInternal()

NSBundle * FLTFrameworkBundleInternal ( NSString *  flutterFrameworkBundleID,
NSURL *  searchURL 
)

Definition at line 14 of file FlutterNSBundleUtils.mm.

14 {
15 NSDirectoryEnumerator<NSURL*>* frameworkEnumerator = [NSFileManager.defaultManager
16 enumeratorAtURL:searchURL
17 includingPropertiesForKeys:nil
18 options:NSDirectoryEnumerationSkipsSubdirectoryDescendants |
19 NSDirectoryEnumerationSkipsHiddenFiles
20 // Skip directories where errors are encountered.
21 errorHandler:nil];
22
23 for (NSURL* candidate in frameworkEnumerator) {
24 NSBundle* flutterFrameworkBundle = [NSBundle bundleWithURL:candidate];
25 if ([flutterFrameworkBundle.bundleIdentifier isEqualToString:flutterFrameworkBundleID]) {
26 return flutterFrameworkBundle;
27 }
28 }
29 return nil;
30}
const char * options

◆ FLTFrameworkBundleWithIdentifier()

NSBundle * FLTFrameworkBundleWithIdentifier ( NSString *  flutterFrameworkBundleID)

Definition at line 43 of file FlutterNSBundleUtils.mm.

43 {
44 NSBundle* appBundle = FLTGetApplicationBundle();
45 NSBundle* flutterFrameworkBundle =
46 FLTFrameworkBundleInternal(flutterFrameworkBundleID, appBundle.privateFrameworksURL);
47 if (flutterFrameworkBundle == nil) {
48 // Fallback to slow implementation.
49 flutterFrameworkBundle = [NSBundle bundleWithIdentifier:flutterFrameworkBundleID];
50 }
51 if (flutterFrameworkBundle == nil) {
52 flutterFrameworkBundle = NSBundle.mainBundle;
53 }
54 return flutterFrameworkBundle;
55}
NSBundle * FLTGetApplicationBundle()
NSBundle * FLTFrameworkBundleInternal(NSString *flutterFrameworkBundleID, NSURL *searchURL)

◆ FLTGetApplicationBundle()

NSBundle * FLTGetApplicationBundle ( )

Definition at line 32 of file FlutterNSBundleUtils.mm.

32 {
33 NSBundle* mainBundle = NSBundle.mainBundle;
34 // App extension bundle is in <AppName>.app/PlugIns/Extension.appex.
35 if ([mainBundle.bundleURL.pathExtension isEqualToString:@"appex"]) {
36 // Up two levels.
37 return [NSBundle bundleWithURL:mainBundle.bundleURL.URLByDeletingLastPathComponent
38 .URLByDeletingLastPathComponent];
39 }
40 return mainBundle;
41}

Variable Documentation

◆ kDefaultAssetPath

NS_ASSUME_NONNULL_BEGIN const NSString* kDefaultAssetPath
extern

Definition at line 11 of file FlutterNSBundleUtils.mm.