Skip to content

Commit 6bc4a69

Browse files
authored
Resource bundle support (#412)
* add logic to find resources in case when our sdk is statically linked * move logic for getting bundle in utils class
1 parent dd4100f commit 6bc4a69

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

Leanplum-SDK/Classes/MessageTemplates/ViewControllers/LPInterstitialViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ +(LPInterstitialViewController *)instantiateFromStoryboard
2020
#ifdef SWIFTPM_MODULE_BUNDLE
2121
NSBundle *bundle = SWIFTPM_MODULE_BUNDLE;
2222
#else
23-
NSBundle *bundle = [NSBundle bundleForClass:[Leanplum class]];
23+
NSBundle *bundle = [LPUtils leanplumBundle];
2424
#endif
2525
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Interstitial" bundle:bundle];
2626

Leanplum-SDK/Classes/MessageTemplates/ViewControllers/LPPopupViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ +(LPPopupViewController *)instantiateFromStoryboard
2323
#ifdef SWIFTPM_MODULE_BUNDLE
2424
NSBundle *bundle = SWIFTPM_MODULE_BUNDLE;
2525
#else
26-
NSBundle *bundle = [NSBundle bundleForClass:[Leanplum class]];
26+
NSBundle *bundle = [LPUtils leanplumBundle];
2727
#endif
2828
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Popup" bundle:bundle];
2929

Leanplum-SDK/Classes/MessageTemplates/ViewControllers/LPWebInterstitialViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ +(LPWebInterstitialViewController *)instantiateFromStoryboard
2525
#ifdef SWIFTPM_MODULE_BUNDLE
2626
NSBundle *bundle = SWIFTPM_MODULE_BUNDLE;
2727
#else
28-
NSBundle *bundle = [NSBundle bundleForClass:[Leanplum class]];
28+
NSBundle *bundle = [LPUtils leanplumBundle];
2929
#endif
3030
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"WebInterstitial" bundle:bundle];
3131

Leanplum-SDK/Classes/Utilities/LPUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,6 @@
6262
*/
6363
+ (BOOL)isSwizzlingEnabled;
6464

65+
+ (NSBundle *)leanplumBundle;
66+
6567
@end

Leanplum-SDK/Classes/Utilities/LPUtils.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#import "LPExceptionHandler.h"
2828
#import "LPAPIConfig.h"
2929
#import "LPConstants.h"
30+
#import "Leanplum.h"
3031

3132

3233
@implementation LPUtils
@@ -97,4 +98,17 @@ +(BOOL)isSwizzlingEnabled
9798
return swizzlingEnabled;
9899
}
99100

101+
+ (NSBundle *)leanplumBundle
102+
{
103+
NSBundle *bundle = [NSBundle bundleForClass:[Leanplum class]];
104+
NSURL *bundleUrl = [bundle URLForResource:@"Leanplum-iOS-SDK" withExtension:@".bundle"];
105+
if (bundleUrl != nil)
106+
{
107+
NSBundle *lpBundle = [NSBundle bundleWithURL:bundleUrl];
108+
bundle = lpBundle;
109+
}
110+
111+
return bundle;
112+
}
113+
100114
@end

0 commit comments

Comments
 (0)