summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gyp/platform-ios.gypi2
-rw-r--r--platform/ios/MGLMapView.mm14
-rw-r--r--platform/ios/MGLMapboxEvents.m6
-rw-r--r--platform/ios/NSBundle+MGLAdditions.h7
-rw-r--r--platform/ios/NSBundle+MGLAdditions.m16
5 files changed, 32 insertions, 13 deletions
diff --git a/gyp/platform-ios.gypi b/gyp/platform-ios.gypi
index f707431182..cc4c1349bf 100644
--- a/gyp/platform-ios.gypi
+++ b/gyp/platform-ios.gypi
@@ -31,6 +31,8 @@
'../include/mbgl/ios/MGLMetricsLocationManager.h',
'../platform/ios/MGLMetricsLocationManager.m',
'../include/mbgl/ios/MGLTypes.h',
+ '../platform/ios/NSBundle+MGLAdditions.h',
+ '../platform/ios/NSBundle+MGLAdditions.m',
'../platform/ios/NSProcessInfo+MGLAdditions.h',
'../platform/ios/NSProcessInfo+MGLAdditions.m',
'../platform/ios/NSString+MGLAdditions.h',
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index d90f99e0eb..b0f25e1d67 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -16,6 +16,7 @@
#include <mbgl/util/geo.hpp>
#import "MGLTypes.h"
+#import "NSBundle+MGLAdditions.h"
#import "NSString+MGLAdditions.h"
#import "NSProcessInfo+MGLAdditions.h"
#import "MGLAnnotation.h"
@@ -1406,7 +1407,7 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng)
{
if ( ! _bundledStyleURLs)
{
- NSString *stylesPath = [[MGLMapView resourceBundlePath] stringByAppendingPathComponent:@"styles"];
+ NSString *stylesPath = [[NSBundle mgl_resourceBundlePath] stringByAppendingPathComponent:@"styles"];
_bundledStyleURLs = [NSMutableArray array];
@@ -2332,22 +2333,13 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng)
+ (NSString *)pathForBundleResourceNamed:(NSString *)name ofType:(NSString *)extension inDirectory:(NSString *)directory
{
- NSString *path = [[NSBundle bundleWithPath:[MGLMapView resourceBundlePath]] pathForResource:name ofType:extension inDirectory:directory];
+ NSString *path = [[NSBundle bundleWithPath:[NSBundle mgl_resourceBundlePath]] pathForResource:name ofType:extension inDirectory:directory];
NSAssert(path, @"Resource not found in application.");
return path;
}
-+ (NSString *)resourceBundlePath
-{
- NSString *resourceBundlePath = [[NSBundle bundleForClass:[MGLMapView class]] pathForResource:@"MapboxGL" ofType:@"bundle"];
-
- if ( ! resourceBundlePath) resourceBundlePath = [[NSBundle mainBundle] bundlePath];
-
- return resourceBundlePath;
-}
-
- (void)invalidate
{
assert([[NSThread currentThread] isMainThread]);
diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m
index a7e0525a27..cf8345222b 100644
--- a/platform/ios/MGLMapboxEvents.m
+++ b/platform/ios/MGLMapboxEvents.m
@@ -7,6 +7,7 @@
#import "MGLMetricsLocationManager.h"
#import "NSProcessInfo+MGLAdditions.h"
+#import "NSBundle+MGLAdditions.h"
#include <sys/sysctl.h>
@@ -142,16 +143,17 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
// ===============================
_session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:nil];
+ NSBundle *resourceBundle = [NSBundle bundleWithPath:[NSBundle mgl_resourceBundlePath]];
// Load Local Copy of Server's Public Key
NSString *cerPath = nil;
- cerPath = [[NSBundle bundleForClass:[MGLMapboxEvents class]] pathForResource:@"api_mapbox_com-geotrust" ofType:@"der"];
+ cerPath = [resourceBundle pathForResource:@"api_mapbox_com-geotrust" ofType:@"der"];
if (cerPath != nil) {
_geoTrustCert = [NSData dataWithContentsOfFile:cerPath];
}
cerPath = nil;
- cerPath = [[NSBundle bundleForClass:[MGLMapboxEvents class]] pathForResource:@"api_mapbox_com-digicert" ofType:@"der"];
+ cerPath = [resourceBundle pathForResource:@"api_mapbox_com-digicert" ofType:@"der"];
if (cerPath != nil) {
_digicertCert = [NSData dataWithContentsOfFile:cerPath];
}
diff --git a/platform/ios/NSBundle+MGLAdditions.h b/platform/ios/NSBundle+MGLAdditions.h
new file mode 100644
index 0000000000..1fc0803b4d
--- /dev/null
+++ b/platform/ios/NSBundle+MGLAdditions.h
@@ -0,0 +1,7 @@
+#import <Foundation/Foundation.h>
+
+@interface NSBundle (MGLAdditions)
+
++ (NSString *)mgl_resourceBundlePath;
+
+@end
diff --git a/platform/ios/NSBundle+MGLAdditions.m b/platform/ios/NSBundle+MGLAdditions.m
new file mode 100644
index 0000000000..b0ecf4656e
--- /dev/null
+++ b/platform/ios/NSBundle+MGLAdditions.m
@@ -0,0 +1,16 @@
+#import "NSBundle+MGLAdditions.h"
+
+#import "MGLMapView.h"
+
+@implementation NSBundle (MGLAdditions)
+
++ (NSString *)mgl_resourceBundlePath
+{
+ NSString *resourceBundlePath = [[NSBundle bundleForClass:[MGLMapView class]] pathForResource:@"MapboxGL" ofType:@"bundle"];
+
+ if ( ! resourceBundlePath) resourceBundlePath = [[NSBundle mainBundle] bundlePath];
+
+ return resourceBundlePath;
+}
+
+@end