| Flutter macOS Embedder |

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 NSString *const | kDefaultAssetPath

## Function Documentation

## ◆ FLTAssetPath()

NSString* FLTAssetPath | ( | NSBundle * | bundle | ) |

Definition at line 60 of file FlutterNSBundleUtils.mm.

60 {
61 return [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"] ?: kDefaultAssetPath;
62 }
kDefaultAssetPath
FLUTTER_ASSERT_ARC NSString *const kDefaultAssetPath
Definition: FlutterNSBundleUtils.mm:13

References kDefaultAssetPath.

Referenced by FLTAssetsPathFromBundle().

## ◆ FLTAssetsPathFromBundle()

NSString* FLTAssetsPathFromBundle | ( | NSBundle * | bundle | ) |

Definition at line 64 of file FlutterNSBundleUtils.mm.

64 {
65 NSString* relativeAssetsPath = FLTAssetPath(bundle);
66 NSString* flutterAssetsPath = GetFlutterAssetsPathFromBundle(bundle, relativeAssetsPath);
67 if (flutterAssetsPath.length == 0) {
68 flutterAssetsPath = GetFlutterAssetsPathFromBundle(NSBundle.mainBundle, relativeAssetsPath);
69 }
70 return flutterAssetsPath;
71 }
FLTAssetPath
NSString * FLTAssetPath(NSBundle *bundle)
Definition: FlutterNSBundleUtils.mm:60
GetFlutterAssetsPathFromBundle
static NSString * GetFlutterAssetsPathFromBundle(NSBundle *bundle, NSString *relativeAssetsPath)
Definition: FlutterNSBundleUtils.mm:73

References FLTAssetPath(), and GetFlutterAssetsPathFromBundle().

## ◆ FLTFrameworkBundleInternal()

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

Definition at line 17 of file FlutterNSBundleUtils.mm.

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

Referenced by FLTFrameworkBundleWithIdentifier().

## ◆ FLTFrameworkBundleWithIdentifier()

NSBundle* FLTFrameworkBundleWithIdentifier | ( | NSString * | flutterFrameworkBundleID | ) |

Definition at line 46 of file FlutterNSBundleUtils.mm.

46 {
47 NSBundle* appBundle = FLTGetApplicationBundle();
48 NSBundle* flutterFrameworkBundle =
49 FLTFrameworkBundleInternal(flutterFrameworkBundleID, appBundle.privateFrameworksURL);
50 if (flutterFrameworkBundle == nil) {
51 // Fallback to slow implementation.
52 flutterFrameworkBundle = [NSBundle bundleWithIdentifier:flutterFrameworkBundleID];
53 }
54 if (flutterFrameworkBundle == nil) {
55 flutterFrameworkBundle = NSBundle.mainBundle;
56 }
57 return flutterFrameworkBundle;
58 }
FLTFrameworkBundleInternal
NSBundle * FLTFrameworkBundleInternal(NSString *flutterFrameworkBundleID, NSURL *searchURL)
Definition: FlutterNSBundleUtils.mm:17
FLTGetApplicationBundle
NSBundle * FLTGetApplicationBundle()
Definition: FlutterNSBundleUtils.mm:35

References FLTFrameworkBundleInternal(), and FLTGetApplicationBundle().

## ◆ FLTGetApplicationBundle()

NSBundle* FLTGetApplicationBundle | ( |  | ) |

Definition at line 35 of file FlutterNSBundleUtils.mm.

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

Referenced by FLTFrameworkBundleWithIdentifier().

## Variable Documentation

## ◆ kDefaultAssetPath

NS_ASSUME_NONNULL_BEGIN NSString* const kDefaultAssetPath
| extern

Definition at line 13 of file FlutterNSBundleUtils.mm.

Referenced by FLTAssetPath().