diff options
author | Justin R. Miller <incanus@codesorcery.net> | 2015-04-28 15:03:35 -0400 |
---|---|---|
committer | Justin R. Miller <incanus@codesorcery.net> | 2015-04-28 15:03:35 -0400 |
commit | 42b59eb655f2a8800da653af9c3959ed0ab6c236 (patch) | |
tree | 2b924c24ad1793d55a2d1b93fbfe4c878807901e | |
parent | c58c734ea0571f225980bdcfb4471b374736667b (diff) | |
download | qtlocation-mapboxgl-42b59eb655f2a8800da653af9c3959ed0ab6c236.tar.gz |
fixes #1363: centrally & better address GL demo/third-party resource bundle issues
-rw-r--r-- | gyp/platform-ios.gypi | 2 | ||||
-rw-r--r-- | platform/ios/MGLMapView.mm | 14 | ||||
-rw-r--r-- | platform/ios/MGLMapboxEvents.m | 6 | ||||
-rw-r--r-- | platform/ios/NSBundle+MGLAdditions.h | 7 | ||||
-rw-r--r-- | platform/ios/NSBundle+MGLAdditions.m | 16 |
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 |