summaryrefslogtreecommitdiff
path: root/platform/ios/src/MGLMapView.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r--platform/ios/src/MGLMapView.mm31
1 files changed, 15 insertions, 16 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 3cb8209f1d..ebcc62eba6 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -3529,25 +3529,24 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration)
+ (UIImage *)resourceImageNamed:(NSString *)imageName
{
- if ( ! [[imageName pathExtension] length])
- {
- imageName = [imageName stringByAppendingString:@".png"];
- }
-
- return [UIImage imageWithContentsOfFile:[self pathForBundleResourceNamed:imageName ofType:nil inDirectory:@""]];
-}
-
-+ (NSString *)pathForBundleResourceNamed:(NSString *)name ofType:(NSString *)extension inDirectory:(NSString *)directory
-{
- NSString *path = [[NSBundle bundleWithPath:[NSBundle mgl_resourceBundlePath]] pathForResource:name ofType:extension inDirectory:directory];
-
- if (!path)
+ NSString *extension = imageName.pathExtension.length ? imageName.pathExtension : @"png";
+ NSBundle *bundle = [NSBundle mgl_frameworkBundle];
+ NSString *directory = nil;
+ if (![bundle.infoDictionary[@"CFBundlePackageType"] isEqualToString:@"FMWK"]) {
+ // For static libraries, the bundle is the containing application bundle
+ // and the resources are in a bundle alongside the static library.
+ directory = @"Mapbox.bundle";
+ }
+ NSString *path = [bundle pathForResource:imageName.stringByDeletingPathExtension
+ ofType:extension
+ inDirectory:directory];
+ if ( ! path)
{
[NSException raise:@"Resource not found" format:
- @"The resource named “%@” could not be found in the Mapbox resource bundle.", name];
+ @"The resource named “%@” could not be found in the Mapbox resource bundle.", imageName];
}
-
- return path;
+
+ return [UIImage imageWithContentsOfFile:path];
}
- (BOOL)isFullyLoaded