summaryrefslogtreecommitdiff
path: root/SmartDeviceLink
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2016-08-31 09:41:57 -0400
committerJoel Fischer <joeljfischer@gmail.com>2016-08-31 09:41:57 -0400
commit38f7edffb300a5bb7eb20c6c9e3f6f9239bafd72 (patch)
treed4afaabf6b3f4bb8f39f8304b06699d5cd6d2a16 /SmartDeviceLink
parent63018b18b3f8f04eea715e631fa0d78958c6c3ab (diff)
downloadsdl_ios-38f7edffb300a5bb7eb20c6c9e3f6f9239bafd72.tar.gz
Cocoapods may have the resources in a different location
Diffstat (limited to 'SmartDeviceLink')
-rw-r--r--SmartDeviceLink/SDLLockScreenManager.m11
-rw-r--r--SmartDeviceLink/SDLLockScreenViewController.m22
2 files changed, 26 insertions, 7 deletions
diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m
index 2e88c9021..0f4e1cda2 100644
--- a/SmartDeviceLink/SDLLockScreenManager.m
+++ b/SmartDeviceLink/SDLLockScreenManager.m
@@ -59,8 +59,17 @@ NS_ASSUME_NONNULL_BEGIN
self.presenter.viewController = self.config.customViewController;
} else {
SDLLockScreenViewController *viewController = nil;
+
+ // Attempt to find it using cocoapods weirdness
+ NSURL *sdlBundleURL = [[NSBundle mainBundle] URLForResource:@"SmartDeviceLink" withExtension:@"bundle"];
+ NSBundle *sdlBundle = [NSBundle bundleWithURL:sdlBundleURL];
+ if (sdlBundle == nil) {
+ sdlBundle = [NSBundle bundleForClass:[self class]];
+ }
+
+ // Attempt to find it using frameworks
@try {
- viewController = [[UIStoryboard storyboardWithName:@"SDLLockScreen" bundle:[NSBundle bundleForClass:[self class]]] instantiateInitialViewController];
+ viewController = [[UIStoryboard storyboardWithName:@"SDLLockScreen" bundle:sdlBundle] instantiateInitialViewController];
} @catch (NSException *exception) {
[SDLDebugTool logInfo:@"SDL Error: Attempted to instantiate the default SDL Lock Screen and could not find the storyboard. Be sure the 'SmartDeviceLink' bundle is within your main bundle. We're just going to return without instantiating the lock screen."];
return;
diff --git a/SmartDeviceLink/SDLLockScreenViewController.m b/SmartDeviceLink/SDLLockScreenViewController.m
index e64b94ccd..064b21f06 100644
--- a/SmartDeviceLink/SDLLockScreenViewController.m
+++ b/SmartDeviceLink/SDLLockScreenViewController.m
@@ -145,25 +145,25 @@ NS_ASSUME_NONNULL_BEGIN
// TODO: (Joel F.)[2016-08-22] When moved to iOS 7+, use `imageWithRenderingMode:`
+ (UIImage *)sdl_logoImageWithColor:(BOOL)white {
if (white) {
- return [UIImage imageNamed:@"sdl_logo_white" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil];
+ return [UIImage imageNamed:@"sdl_logo_white" inBundle:[self podBundle] compatibleWithTraitCollection:nil];
} else {
- return [UIImage imageNamed:@"sdl_logo_black" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil];
+ return [UIImage imageNamed:@"sdl_logo_black" inBundle:[self podBundle] compatibleWithTraitCollection:nil];
}
}
+ (UIImage *)sdl_arrowUpImageWithColor:(BOOL)white {
if (white) {
- return [UIImage imageNamed:@"lock_arrow_up_white" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil];
+ return [UIImage imageNamed:@"lock_arrow_up_white" inBundle:[self podBundle] compatibleWithTraitCollection:nil];
} else {
- return [UIImage imageNamed:@"lock_arrow_up_black" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil];
+ return [UIImage imageNamed:@"lock_arrow_up_black" inBundle:[self podBundle] compatibleWithTraitCollection:nil];
}
}
+ (UIImage *)sdl_arrowDownImageWithColor:(BOOL)white {
if (white) {
- return [UIImage imageNamed:@"lock_arrow_down_white" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil];
+ return [UIImage imageNamed:@"lock_arrow_down_white" inBundle:[self podBundle] compatibleWithTraitCollection:nil];
} else {
- return [UIImage imageNamed:@"lock_arrow_down_black" inBundle:[NSBundle bundleForClass:[self class]] compatibleWithTraitCollection:nil];
+ return [UIImage imageNamed:@"lock_arrow_down_black" inBundle:[self podBundle] compatibleWithTraitCollection:nil];
}
}
@@ -181,6 +181,16 @@ NS_ASSUME_NONNULL_BEGIN
return (luminescence <= 0.179);
}
++ (nullable NSBundle *)podBundle {
+ NSURL *sdlBundleURL = [[NSBundle mainBundle] URLForResource:@"SmartDeviceLink" withExtension:@"bundle"];
+ NSBundle *sdlBundle = [NSBundle bundleWithURL:sdlBundleURL];
+ if (sdlBundle == nil) {
+ sdlBundle = [NSBundle bundleForClass:[self class]];
+ }
+
+ return sdlBundle;
+}
+
@end
NS_ASSUME_NONNULL_END \ No newline at end of file