summaryrefslogtreecommitdiff
path: root/platform/ios/NSBundle+MGLAdditions.m
blob: d5842ea59605950600d72c543eb5667bb00bce38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#import "NSBundle+MGLAdditions.h"

#import "MGLMapView.h"

@implementation NSBundle (MGLAdditions)

void mgl_linkBundleCategory(){}

+ (NSString *)mgl_resourceBundlePath
{
    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;
}

@end