provide resource bundle search for premade frameworks

This commit is contained in:
Justin R. Miller
2015-11-13 17:22:01 -08:00
parent c35f18fdbc
commit 212e7a1e08

View File

@@ -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;