fixes #1363: centrally & better address GL demo/third-party resource bundle issues
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
7
platform/ios/NSBundle+MGLAdditions.h
Normal file
7
platform/ios/NSBundle+MGLAdditions.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSBundle (MGLAdditions)
|
||||
|
||||
+ (NSString *)mgl_resourceBundlePath;
|
||||
|
||||
@end
|
||||
16
platform/ios/NSBundle+MGLAdditions.m
Normal file
16
platform/ios/NSBundle+MGLAdditions.m
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user