Flutter iOS Embedder
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

const NS_ASSUME_NONNULL_BEGIN 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 }

References kDefaultAssetPath.

Referenced by FLTAssetsPathFromBundle().

◆ 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 }

References FLTAssetPath(), and GetFlutterAssetsPathFromBundle().

Referenced by FLTDefaultSettingsForBundle().

◆ 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 }

Referenced by FLTFrameworkBundleWithIdentifier().

◆ 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 }

References FLTFrameworkBundleInternal(), and FLTGetApplicationBundle().

Referenced by FLTDefaultSettingsForBundle().

◆ 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 }

Referenced by FLTDefaultSettingsForBundle(), and FLTFrameworkBundleWithIdentifier().

Variable Documentation

◆ kDefaultAssetPath

const NS_ASSUME_NONNULL_BEGIN NSString* kDefaultAssetPath

Definition at line 11 of file FlutterNSBundleUtils.mm.

Referenced by FLTAssetPath().

FLTFrameworkBundleInternal
NSBundle * FLTFrameworkBundleInternal(NSString *flutterFrameworkBundleID, NSURL *searchURL)
Definition: FlutterNSBundleUtils.mm:14
GetFlutterAssetsPathFromBundle
static NSString * GetFlutterAssetsPathFromBundle(NSBundle *bundle, NSString *relativeAssetsPath)
Definition: FlutterNSBundleUtils.mm:70
FLTAssetPath
NSString * FLTAssetPath(NSBundle *bundle)
Definition: FlutterNSBundleUtils.mm:57
kDefaultAssetPath
const FLUTTER_ASSERT_ARC NSString * kDefaultAssetPath
Definition: FlutterNSBundleUtils.mm:11
FLTGetApplicationBundle
NSBundle * FLTGetApplicationBundle()
Definition: FlutterNSBundleUtils.mm:32