Skip to content

Commit c2d836e

Browse files
ncooke3andrewheard
authored andcommitted
[Release] Cherry-pick FIAM fixes into 10.26.0 (#12920)
1 parent a2292e4 commit c2d836e

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

FirebaseInAppMessaging/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Unreleased
2+
- [fixed] Fixed crash at app start that affected CocoaPods users using static
3+
frameworks (#12882).
4+
5+
# 10.26.0
6+
- [fixed] Fixed crash at app start that affected SwiftPM users (#12882).
7+
18
# 10.25.0
29
- [changed] Removed usages of user defaults API to eliminate required reason
310
impact.

FirebaseInAppMessaging/Sources/DefaultUI/FIRIAMDefaultDisplayImpl.m

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)