From 212e7a1e081da35309730e6aa15a5fbe967bfeb4 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Fri, 13 Nov 2015 17:22:01 -0800 Subject: [PATCH] provide resource bundle search for premade frameworks --- platform/ios/NSBundle+MGLAdditions.m | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/ios/NSBundle+MGLAdditions.m b/platform/ios/NSBundle+MGLAdditions.m index 3fca7384a..d5842ea59 100644 --- a/platform/ios/NSBundle+MGLAdditions.m +++ b/platform/ios/NSBundle+MGLAdditions.m @@ -8,8 +8,21 @@ void mgl_linkBundleCategory(){} + (NSString *)mgl_resourceBundlePath { - NSString *resourceBundlePath = [[NSBundle bundleForClass:[MGLMapView class]] pathForResource:@"Mapbox" ofType:@"bundle"]; + NSString *resourceBundlePath = nil; + // check for resource bundle in framework bundle (Fabric, premade framework) + // + NSString *frameworkBundlePath = [NSString stringWithFormat:@"%@/Mapbox.framework/Mapbox.bundle", + [[NSBundle mainBundle] privateFrameworksPath]]; + if ([NSBundle bundleWithPath:frameworkBundlePath]) resourceBundlePath = frameworkBundlePath; + + // check for resource bundle in app bundle (static library) + // + if ( ! resourceBundlePath) resourceBundlePath = [[NSBundle bundleForClass: + [MGLMapView class]] pathForResource:@"Mapbox" ofType:@"bundle"]; + + // fall back to resources directly in app bundle (test app) + // if ( ! resourceBundlePath) resourceBundlePath = [[NSBundle mainBundle] bundlePath]; return resourceBundlePath;