summaryrefslogtreecommitdiff
path: root/platform/ios/src
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/src')
-rw-r--r--platform/ios/src/MGLAccountManager.m4
-rw-r--r--platform/ios/src/MGLCategoryLoader.h7
-rw-r--r--platform/ios/src/MGLCategoryLoader.m24
-rw-r--r--platform/ios/src/MGLMapView.mm31
-rw-r--r--platform/ios/src/MGLMapboxEvents.m2
-rw-r--r--platform/ios/src/NSBundle+MGLAdditions.h2
-rw-r--r--platform/ios/src/NSBundle+MGLAdditions.m27
-rw-r--r--platform/ios/src/NSProcessInfo+MGLAdditions.h2
-rw-r--r--platform/ios/src/NSProcessInfo+MGLAdditions.m2
9 files changed, 24 insertions, 77 deletions
diff --git a/platform/ios/src/MGLAccountManager.m b/platform/ios/src/MGLAccountManager.m
index c5aeae7077..9b60a40986 100644
--- a/platform/ios/src/MGLAccountManager.m
+++ b/platform/ios/src/MGLAccountManager.m
@@ -1,6 +1,5 @@
#import "MGLAccountManager_Private.h"
#import "MGLMapboxEvents.h"
-#import "MGLCategoryLoader.h"
#import "NSProcessInfo+MGLAdditions.h"
#import "FABKitProtocol.h"
@@ -17,9 +16,6 @@
#pragma mark - Internal
+ (void)load {
- // Load all referenced categories due to absence of -ObjC linker flag
- [MGLCategoryLoader loadCategories];
-
// Read the initial configuration from Info.plist.
NSString *accessToken = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLMapboxAccessToken"];
if (accessToken.length) {
diff --git a/platform/ios/src/MGLCategoryLoader.h b/platform/ios/src/MGLCategoryLoader.h
deleted file mode 100644
index 874450d148..0000000000
--- a/platform/ios/src/MGLCategoryLoader.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#import <Foundation/Foundation.h>
-
-@interface MGLCategoryLoader : NSObject
-
-+ (void)loadCategories;
-
-@end
diff --git a/platform/ios/src/MGLCategoryLoader.m b/platform/ios/src/MGLCategoryLoader.m
deleted file mode 100644
index 9b66be73d8..0000000000
--- a/platform/ios/src/MGLCategoryLoader.m
+++ /dev/null
@@ -1,24 +0,0 @@
-#import "MGLCategoryLoader.h"
-
-#import "NSBundle+MGLAdditions.h"
-#import "NSProcessInfo+MGLAdditions.h"
-#import "NSString+MGLAdditions.h"
-
-#import "MGLMapView.h"
-
-@implementation MGLCategoryLoader
-
-+ (void)loadCategories
-{
- // https://github.com/mapbox/mapbox-gl-native/issues/2966
- //
- mgl_linkBundleCategory();
- mgl_linkProcessCategory();
- mgl_linkStringCategory();
-
- // https://github.com/mapbox/mapbox-gl-native/issues/3113
- //
- [MGLMapView description];
-}
-
-@end
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
diff --git a/platform/ios/src/MGLMapboxEvents.m b/platform/ios/src/MGLMapboxEvents.m
index 6654cc6ac5..8aa790c41f 100644
--- a/platform/ios/src/MGLMapboxEvents.m
+++ b/platform/ios/src/MGLMapboxEvents.m
@@ -220,7 +220,7 @@ const NSTimeInterval MGLFlushInterval = 60;
_paused = YES;
[self resumeMetricsCollection];
- NSBundle *resourceBundle = [NSBundle bundleWithPath:[NSBundle mgl_resourceBundlePath]];
+ NSBundle *resourceBundle = [NSBundle mgl_frameworkBundle];
// Load Local Copy of Server's Public Key
NSString *cerPath = nil;
diff --git a/platform/ios/src/NSBundle+MGLAdditions.h b/platform/ios/src/NSBundle+MGLAdditions.h
index a86e85f79b..6d6ebc35ad 100644
--- a/platform/ios/src/NSBundle+MGLAdditions.h
+++ b/platform/ios/src/NSBundle+MGLAdditions.h
@@ -8,7 +8,7 @@ void mgl_linkBundleCategory();
@interface NSBundle (MGLAdditions)
-+ (NSString *)mgl_resourceBundlePath;
++ (instancetype)mgl_frameworkBundle;
@end
diff --git a/platform/ios/src/NSBundle+MGLAdditions.m b/platform/ios/src/NSBundle+MGLAdditions.m
index d5842ea596..05d8f5c87c 100644
--- a/platform/ios/src/NSBundle+MGLAdditions.m
+++ b/platform/ios/src/NSBundle+MGLAdditions.m
@@ -1,31 +1,14 @@
#import "NSBundle+MGLAdditions.h"
-#import "MGLMapView.h"
+#import "MGLAccountManager.h"
-@implementation NSBundle (MGLAdditions)
+void mgl_linkBundleCategory() {}
-void mgl_linkBundleCategory(){}
+@implementation NSBundle (MGLAdditions)
-+ (NSString *)mgl_resourceBundlePath
++ (instancetype)mgl_frameworkBundle
{
- NSString *resourceBundlePath = nil;
-
- // check for resource bundle in framework bundle (Fabric, premade framework)
- //
- NSString *frameworkBundlePath = [NSString stringWithFormat:@"%@/Mapbox.framework/Mapbox.bundle",
- [[NSBundle mainBundle] privateFrameworksPath]];
- if ([NSBundle bundleWithPath:frameworkBundlePath]) resourceBundlePath = frameworkBundlePath;
-
- // check for resource bundle in app bundle (static library)
- //
- if ( ! resourceBundlePath) resourceBundlePath = [[NSBundle bundleForClass:
- [MGLMapView class]] pathForResource:@"Mapbox" ofType:@"bundle"];
-
- // fall back to resources directly in app bundle (test app)
- //
- if ( ! resourceBundlePath) resourceBundlePath = [[NSBundle mainBundle] bundlePath];
-
- return resourceBundlePath;
+ return [self bundleForClass:[MGLAccountManager class]];
}
@end
diff --git a/platform/ios/src/NSProcessInfo+MGLAdditions.h b/platform/ios/src/NSProcessInfo+MGLAdditions.h
index b97979ddb4..6b34f54756 100644
--- a/platform/ios/src/NSProcessInfo+MGLAdditions.h
+++ b/platform/ios/src/NSProcessInfo+MGLAdditions.h
@@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
-void mgl_linkProcessCategory();
+void mgl_linkProcessInfoCategory();
@interface NSProcessInfo (MGLAdditions)
diff --git a/platform/ios/src/NSProcessInfo+MGLAdditions.m b/platform/ios/src/NSProcessInfo+MGLAdditions.m
index 1f12f7256e..73d76bc17f 100644
--- a/platform/ios/src/NSProcessInfo+MGLAdditions.m
+++ b/platform/ios/src/NSProcessInfo+MGLAdditions.m
@@ -2,7 +2,7 @@
@implementation NSProcessInfo (MGLAdditions)
-void mgl_linkProcessCategory(){}
+void mgl_linkProcessInfoCategory() {}
- (BOOL)mgl_isInterfaceBuilderDesignablesAgent
{