Skip to content

Commit 2bac0dd

Browse files
authored
[InAppMessaging] Follow-up to #12910 (#12917)
1 parent 1c605b2 commit 2bac0dd

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

FirebaseInAppMessaging/Sources/DefaultUI/FIRIAMDefaultDisplayImpl.m

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,35 @@ + (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+
// 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+
6792
NSBundle *containingBundle;
6893
NSURL *bundleURL;
6994
// 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) {
8296
bundleURL = [containingBundle URLForResource:bundledResource withExtension:@"bundle"];
8397
if (bundleURL != nil) break;
8498
}

0 commit comments

Comments
 (0)