@@ -64,19 +64,33 @@ + (NSBundle *)getViewResourceBundle {
6464 bundledResource = @" InAppMessagingDisplayResources" ;
6565#endif // SWIFT_PACKAGE
6666
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+ NSBundle *frameworkBundle = [NSBundle
83+ bundleWithURL:
84+ [NSBundle .mainBundle.bundleURL
85+ URLByAppendingPathComponent: @" Frameworks/FirebaseInAppMessaging.framework" ]];
86+ if (frameworkBundle) {
87+ [bundles addObject: frameworkBundle];
88+ }
89+
6790 NSBundle *containingBundle;
6891 NSURL *bundleURL;
6992 // 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- // Embedded static framework (zip distribution).
76- [NSBundle bundleWithURL: [NSBundle .mainBundle.bundleURL
77- URLByAppendingPathComponent:
78- @" Frameworks/FirebaseInAppMessaging.framework" ]]
79- ]) {
93+ for (containingBundle in bundles) {
8094 bundleURL = [containingBundle URLForResource: bundledResource withExtension: @" bundle" ];
8195 if (bundleURL != nil ) break ;
8296 }
0 commit comments