Look inside MapboxGL.bundle when present

Fixes #1011.
This commit is contained in:
Minh Nguyễn
2015-03-16 16:22:16 -07:00
parent 0d8b3aa5f7
commit 3ba72da74f

View File

@@ -2,13 +2,22 @@
#include <mbgl/platform/platform.hpp>
@interface MGLApplicationRootBundleCanary : NSObject
@end
@implementation MGLApplicationRootBundleCanary
@end
namespace mbgl {
namespace platform {
// Returns the path to the root folder of the application.
const std::string &assetRoot() {
static const std::string root = []() -> std::string {
NSString *path = [[[NSBundle mainBundle] resourceURL] path];
NSString *path = [[NSBundle bundleForClass:[MGLApplicationRootBundleCanary class]] pathForResource:@"MapboxGL" ofType:@"bundle"];
if (!path) {
path = [[[NSBundle mainBundle] resourceURL] path];
}
return {[path cStringUsingEncoding : NSUTF8StringEncoding],
[path lengthOfBytesUsingEncoding:NSUTF8StringEncoding]};
}();