@@ -64,21 +64,35 @@ + (NSBundle *)getViewResourceBundle {
64
64
bundledResource = @" InAppMessagingDisplayResources" ;
65
65
#endif // SWIFT_PACKAGE
66
66
67
+ NSMutableArray *bundles = [NSMutableArray array ];
68
+
69
+ // Resources may be in main bundle when statically linked.
70
+ NSBundle *mainBundle = [NSBundle mainBundle ];
71
+ if (mainBundle) {
72
+ [bundles addObject: mainBundle];
73
+ }
74
+ // Resources may be in the bundle associated with this class when
75
+ // dynamically linked.
76
+ NSBundle *bundleForClass = [NSBundle bundleForClass: myClass];
77
+ if (bundleForClass) {
78
+ [bundles addObject: bundleForClass];
79
+ }
80
+ // When embedding static frameworks from the zip distribution, the Xcode
81
+ // will copy the resources into the framework's directory.
82
+ // TODO(Firebase 11): Remove when Firebase.zip is composed of dynamic
83
+ // frameworks.
84
+ NSBundle *frameworkBundle = [NSBundle
85
+ bundleWithURL:
86
+ [NSBundle .mainBundle.bundleURL
87
+ URLByAppendingPathComponent: @" Frameworks/FirebaseInAppMessaging.framework" ]];
88
+ if (frameworkBundle) {
89
+ [bundles addObject: frameworkBundle];
90
+ }
91
+
67
92
NSBundle *containingBundle;
68
93
NSURL *bundleURL;
69
94
// The containing bundle is different whether FIAM is statically or dynamically linked.
70
- for (containingBundle in @[
71
- // Statically linked.
72
- [NSBundle mainBundle ],
73
- // Dynamically linked.
74
- [NSBundle bundleForClass: myClass],
75
- #if FIREBASE_BUILD_ZIP_FILE
76
- // Embedded static framework (zip distribution).
77
- [NSBundle bundleWithURL: [NSBundle .mainBundle.bundleURL
78
- URLByAppendingPathComponent:
79
- @" Frameworks/FirebaseInAppMessaging.framework" ]]
80
- #endif // FIREBASE_BUILD_ZIP_FILE
81
- ]) {
95
+ for (containingBundle in bundles) {
82
96
bundleURL = [containingBundle URLForResource: bundledResource withExtension: @" bundle" ];
83
97
if (bundleURL != nil ) break ;
84
98
}
0 commit comments