summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-03-05 18:00:11 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-03-10 17:08:58 -0800
commite36218a8668316e8c1b0bcc06d43dad31461615c (patch)
tree04d5e58ae0c4dea4b0a50e034a8a630564cb7a53
parent081ee9fbefbdb37f116a5bf2c0383586bce6608a (diff)
downloadqtlocation-mapboxgl-e36218a8668316e8c1b0bcc06d43dad31461615c.tar.gz
[osx] Added OS X support for offline downloads
-rw-r--r--gyp/platform-ios.gypi12
-rw-r--r--gyp/platform-osx.gypi18
-rw-r--r--platform/darwin/include/MGLAccountManager.h49
-rw-r--r--platform/darwin/src/MGLAccountManager.m (renamed from platform/ios/src/MGLAccountManager.m)45
-rw-r--r--platform/darwin/src/MGLAccountManager_Private.h (renamed from platform/ios/src/MGLAccountManager_Private.h)3
-rw-r--r--platform/darwin/src/MGLDownloadController.mm20
-rw-r--r--platform/darwin/src/MGLTilePyramidDownloadRegion.mm4
-rw-r--r--platform/darwin/src/NSBundle+MGLAdditions.h (renamed from platform/ios/src/NSBundle+MGLAdditions.h)0
-rw-r--r--platform/darwin/src/NSBundle+MGLAdditions.m (renamed from platform/ios/src/NSBundle+MGLAdditions.m)0
-rw-r--r--platform/darwin/src/NSProcessInfo+MGLAdditions.h (renamed from platform/ios/src/NSProcessInfo+MGLAdditions.h)4
-rw-r--r--platform/darwin/src/NSProcessInfo+MGLAdditions.m17
-rw-r--r--platform/ios/include/MGLAccountManager.h33
-rw-r--r--platform/ios/src/NSProcessInfo+MGLAdditions.m12
-rw-r--r--platform/osx/include/MGLAccountManager.h44
-rw-r--r--platform/osx/sdk/Mapbox.h4
-rw-r--r--platform/osx/sdk/Mapbox.m3
-rw-r--r--platform/osx/src/MGLAccountManager.m54
-rw-r--r--platform/osx/src/MGLAccountManager_Private.h15
-rw-r--r--platform/osx/src/MGLAnnotationImage.m2
-rw-r--r--platform/osx/src/MGLMapView+IBAdditions.m2
-rw-r--r--platform/osx/src/MGLMapView.mm16
-rw-r--r--platform/osx/src/MGLMapView_Private.h2
-rw-r--r--platform/osx/src/NSBundle+MGLAdditions.h16
-rw-r--r--platform/osx/src/NSBundle+MGLAdditions.m13
-rw-r--r--platform/osx/src/NSProcessInfo+MGLAdditions.h11
-rw-r--r--platform/osx/src/NSProcessInfo+MGLAdditions.m11
26 files changed, 160 insertions, 250 deletions
diff --git a/gyp/platform-ios.gypi b/gyp/platform-ios.gypi
index fc89ebcc43..15b2fef0cc 100644
--- a/gyp/platform-ios.gypi
+++ b/gyp/platform-ios.gypi
@@ -50,6 +50,12 @@
'../platform/darwin/src/MGLDownloadController_Private.h',
'../platform/darwin/src/MGLDownloadRegion_Private.h',
'../platform/darwin/src/MGLTilePyramidDownloadRegion.mm',
+ '../platform/darwin/src/MGLAccountManager_Private.h',
+ '../platform/darwin/src/MGLAccountManager.m',
+ '../platform/darwin/src/NSBundle+MGLAdditions.h',
+ '../platform/darwin/src/NSBundle+MGLAdditions.m',
+ '../platform/darwin/src/NSProcessInfo+MGLAdditions.h',
+ '../platform/darwin/src/NSProcessInfo+MGLAdditions.m',
'../platform/ios/src/MGLMapboxEvents.h',
'../platform/ios/src/MGLMapboxEvents.m',
'../platform/ios/src/MGLAPIClient.h',
@@ -57,8 +63,6 @@
'../platform/ios/src/MGLLocationManager.h',
'../platform/ios/src/MGLLocationManager.m',
'../platform/ios/src/MGLMapView.mm',
- '../platform/ios/src/MGLAccountManager_Private.h',
- '../platform/ios/src/MGLAccountManager.m',
'../platform/ios/src/MGLUserLocation_Private.h',
'../platform/ios/src/MGLUserLocation.m',
'../platform/ios/src/MGLUserLocationAnnotationView.h',
@@ -67,10 +71,6 @@
'../platform/ios/src/MGLAnnotationImage.m',
'../platform/ios/src/MGLCompactCalloutView.h',
'../platform/ios/src/MGLCompactCalloutView.m',
- '../platform/ios/src/NSBundle+MGLAdditions.h',
- '../platform/ios/src/NSBundle+MGLAdditions.m',
- '../platform/ios/src/NSProcessInfo+MGLAdditions.h',
- '../platform/ios/src/NSProcessInfo+MGLAdditions.m',
'../platform/ios/vendor/SMCalloutView/SMCalloutView.h',
'../platform/ios/vendor/SMCalloutView/SMCalloutView.m',
'../platform/ios/vendor/Fabric/FABAttributes.h',
diff --git a/gyp/platform-osx.gypi b/gyp/platform-osx.gypi
index 581937ac66..ae09a60d99 100644
--- a/gyp/platform-osx.gypi
+++ b/gyp/platform-osx.gypi
@@ -43,8 +43,18 @@
'../platform/darwin/src/MGLPolyline.mm',
'../platform/darwin/src/MGLPolygon.mm',
'../platform/darwin/src/MGLMapCamera.mm',
- '../platform/osx/src/MGLAccountManager_Private.h',
- '../platform/osx/src/MGLAccountManager.m',
+ '../platform/darwin/src/MGLDownloadable.mm',
+ '../platform/darwin/src/MGLDownloadable_Private.h',
+ '../platform/darwin/src/MGLDownloadController.mm',
+ '../platform/darwin/src/MGLDownloadController_Private.h',
+ '../platform/darwin/src/MGLDownloadRegion_Private.h',
+ '../platform/darwin/src/MGLTilePyramidDownloadRegion.mm',
+ '../platform/darwin/src/MGLAccountManager_Private.h',
+ '../platform/darwin/src/MGLAccountManager.m',
+ '../platform/darwin/src/NSBundle+MGLAdditions.h',
+ '../platform/darwin/src/NSBundle+MGLAdditions.m',
+ '../platform/darwin/src/NSProcessInfo+MGLAdditions.h',
+ '../platform/darwin/src/NSProcessInfo+MGLAdditions.m',
'../platform/osx/src/MGLMapView_Private.h',
'../platform/osx/src/MGLMapView.mm',
'../platform/osx/src/MGLMapView+IBAdditions.m',
@@ -55,10 +65,6 @@
'../platform/osx/src/MGLAttributionButton.h',
'../platform/osx/src/MGLAttributionButton.m',
'../platform/osx/src/MGLAnnotationImage.m',
- '../platform/osx/src/NSBundle+MGLAdditions.h',
- '../platform/osx/src/NSBundle+MGLAdditions.m',
- '../platform/osx/src/NSProcessInfo+MGLAdditions.h',
- '../platform/osx/src/NSProcessInfo+MGLAdditions.m',
],
'variables': {
diff --git a/platform/darwin/include/MGLAccountManager.h b/platform/darwin/include/MGLAccountManager.h
new file mode 100644
index 0000000000..5cf729ef3a
--- /dev/null
+++ b/platform/darwin/include/MGLAccountManager.h
@@ -0,0 +1,49 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLTypes.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ The MGLAccountManager object provides a global way to set a Mapbox API access
+ token, as well as other settings used framework-wide.
+ */
+@interface MGLAccountManager : NSObject
+
+#pragma mark Authorizing Access
+
+/**
+ Set the [Mapbox access token](https://www.mapbox.com/help/define-access-token/)
+ to be used by all instances of MGLMapView in the current application.
+
+ Mapbox-hosted vector tiles and styles require an API access token, which you
+ can obtain from the
+ [Mapbox account page](https://www.mapbox.com/studio/account/tokens/). Access
+ tokens associate requests to Mapbox’s vector tile and style APIs with your
+ Mapbox account. They also deter other developers from using your styles without
+ your permission.
+
+ @param accessToken A Mapbox access token. Calling this method with a value of
+ `nil` has no effect.
+
+ @note You must set the access token before attempting to load any Mapbox-hosted
+ style. Therefore, you should generally set it before creating an instance of
+ MGLMapView. The recommended way to set an access token is to add an entry to
+ your application’s Info.plist file with the key `MGLMapboxAccessToken` and
+ the type String. Alternatively, you may call this method from your
+ application delegate’s `-applicationDidFinishLaunching:` method.
+ */
++ (void)setAccessToken:(nullable NSString *)accessToken;
+
+/**
+ Returns the
+ [Mapbox access token](https://www.mapbox.com/help/define-access-token/) in use
+ by instances of MGLMapView in the current application.
+ */
++ (nullable NSString *)accessToken;
+
++ (BOOL)mapboxMetricsEnabledSettingShownInApp __attribute__((deprecated("Telemetry settings are now always shown in the ℹ️ menu.")));
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/ios/src/MGLAccountManager.m b/platform/darwin/src/MGLAccountManager.m
index d50f0f86de..bfaf9faae9 100644
--- a/platform/ios/src/MGLAccountManager.m
+++ b/platform/darwin/src/MGLAccountManager.m
@@ -1,18 +1,27 @@
#import "MGLAccountManager_Private.h"
-#import "MGLMapboxEvents.h"
#import "MGLMapView.h"
#import "NSBundle+MGLAdditions.h"
#import "NSProcessInfo+MGLAdditions.h"
#import "NSString+MGLAdditions.h"
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
+#import "MGLMapboxEvents.h"
+
#import "FABKitProtocol.h"
#import "Fabric+FABKits.h"
-@interface MGLAccountManager() <FABKit>
+@interface MGLAccountManager () <FABKit>
+
+@property (atomic) NSString *accessToken;
+
+@end
+#else
+@interface MGLAccountManager ()
@property (atomic) NSString *accessToken;
@end
+#endif
@implementation MGLAccountManager
@@ -26,9 +35,7 @@
}
}
-// Can be called from any thread.
-//
-+ (instancetype) sharedManager {
++ (instancetype)sharedManager {
if (NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent) {
return nil;
}
@@ -39,37 +46,43 @@
_sharedManager = [[self alloc] init];
});
};
- if ( ! [[NSThread currentThread] isMainThread]) {
+ if (![[NSThread currentThread] isMainThread]) {
dispatch_sync(dispatch_get_main_queue(), ^{
setupBlock();
});
- }
- else {
+ } else {
setupBlock();
}
return _sharedManager;
}
-+ (BOOL) mapboxMetricsEnabledSettingShownInApp {
++ (BOOL)mapboxMetricsEnabledSettingShownInApp {
NSLog(@"mapboxMetricsEnabledSettingShownInApp is no longer necessary; the Mapbox iOS SDK has changed to always provide a telemetry setting in-app.");
+ return YES;
}
-+ (void) setAccessToken:(NSString *) accessToken {
++ (void)setAccessToken:(NSString *)accessToken {
accessToken = [accessToken stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- if ( ! [accessToken length]) return;
+ if (!accessToken.length) {
+ return;
+ }
[MGLAccountManager sharedManager].accessToken = accessToken;
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
// Update MGLMapboxEvents
// NOTE: This is (likely) the initial setup of MGLMapboxEvents
[MGLMapboxEvents sharedManager];
+#endif
}
-+ (NSString *) accessToken {
++ (NSString *)accessToken {
return [MGLAccountManager sharedManager].accessToken;
}
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
+
#pragma mark - Fabric
+ (NSString *)bundleIdentifier {
@@ -85,15 +98,15 @@
if (fabric) {
NSDictionary *configuration = [fabric configurationDictionaryForKitClass:[MGLAccountManager class]];
- if ( ! configuration || ! configuration[@"accessToken"]) {
- NSLog(@"Configuration dictionary returned by Fabric was nil or doesn't have accessToken. Can't initialize MGLAccountManager.");
+ if (!configuration || !configuration[@"accessToken"]) {
+ NSLog(@"Configuration dictionary returned by Fabric was nil or doesn’t have accessToken. Can’t initialize MGLAccountManager.");
return;
}
[self setAccessToken:configuration[@"accessToken"]];
MGLAccountManager *sharedAccountManager = [self sharedManager];
NSLog(@"MGLAccountManager was initialized with access token: %@", sharedAccountManager.accessToken);
} else {
- NSLog(@"MGLAccountManager is used in a project that doesn't have Fabric.");
+ NSLog(@"MGLAccountManager is used in a project that doesn’t have Fabric.");
}
// https://github.com/mapbox/mapbox-gl-native/issues/2966
@@ -105,4 +118,6 @@
[MGLMapView class];
}
+#endif
+
@end
diff --git a/platform/ios/src/MGLAccountManager_Private.h b/platform/darwin/src/MGLAccountManager_Private.h
index 3cc05b09f0..655af08f20 100644
--- a/platform/ios/src/MGLAccountManager_Private.h
+++ b/platform/darwin/src/MGLAccountManager_Private.h
@@ -2,9 +2,10 @@
@interface MGLAccountManager (Private)
-/** Returns the shared instance of the `MGLAccountManager` class. */
+/// Returns the shared instance of the `MGLAccountManager` class.
+ (instancetype)sharedManager;
+/// The current global access token.
@property (atomic) NSString *accessToken;
@end
diff --git a/platform/darwin/src/MGLDownloadController.mm b/platform/darwin/src/MGLDownloadController.mm
index e4dd273032..95eae86b53 100644
--- a/platform/darwin/src/MGLDownloadController.mm
+++ b/platform/darwin/src/MGLDownloadController.mm
@@ -29,9 +29,25 @@
- (instancetype)initWithFileName:(NSString *)fileName {
if (self = [super init]) {
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *fileCachePath = [paths.firstObject stringByAppendingPathComponent:fileName];
- _mbglFileSource = new mbgl::DefaultFileSource(fileCachePath.UTF8String, [NSBundle mainBundle].resourceURL.path.UTF8String);
+ NSString *cachePath = [paths.firstObject stringByAppendingPathComponent:fileName];
+#elif TARGET_OS_MAC
+ NSURL *cacheDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory
+ inDomain:NSUserDomainMask
+ appropriateForURL:nil
+ create:YES
+ error:nil];
+ cacheDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:
+ [NSBundle mainBundle].bundleIdentifier];
+ [[NSFileManager defaultManager] createDirectoryAtURL:cacheDirectoryURL
+ withIntermediateDirectories:YES
+ attributes:nil
+ error:nil];
+ NSURL *cacheURL = [cacheDirectoryURL URLByAppendingPathComponent:fileName];
+ NSString *cachePath = cacheURL ? cacheURL.path : @"";
+#endif
+ _mbglFileSource = new mbgl::DefaultFileSource(cachePath.UTF8String, [NSBundle mainBundle].resourceURL.path.UTF8String);
// Observe for changes to the global access token (and find out the current one).
[[MGLAccountManager sharedManager] addObserver:self
diff --git a/platform/darwin/src/MGLTilePyramidDownloadRegion.mm b/platform/darwin/src/MGLTilePyramidDownloadRegion.mm
index 942450c0c2..94c0ac6358 100644
--- a/platform/darwin/src/MGLTilePyramidDownloadRegion.mm
+++ b/platform/darwin/src/MGLTilePyramidDownloadRegion.mm
@@ -1,5 +1,9 @@
#import "MGLTilePyramidDownloadRegion.h"
+#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
+ #import <Cocoa/Cocoa.h>
+#endif
+
#import "MGLDownloadRegion_Private.h"
#import "MGLGeometry_Private.h"
#import "MGLStyle.h"
diff --git a/platform/ios/src/NSBundle+MGLAdditions.h b/platform/darwin/src/NSBundle+MGLAdditions.h
index 52ef7fbfa7..52ef7fbfa7 100644
--- a/platform/ios/src/NSBundle+MGLAdditions.h
+++ b/platform/darwin/src/NSBundle+MGLAdditions.h
diff --git a/platform/ios/src/NSBundle+MGLAdditions.m b/platform/darwin/src/NSBundle+MGLAdditions.m
index e1f3e7c720..e1f3e7c720 100644
--- a/platform/ios/src/NSBundle+MGLAdditions.m
+++ b/platform/darwin/src/NSBundle+MGLAdditions.m
diff --git a/platform/ios/src/NSProcessInfo+MGLAdditions.h b/platform/darwin/src/NSProcessInfo+MGLAdditions.h
index 6b34f54756..ea231d4e6a 100644
--- a/platform/ios/src/NSProcessInfo+MGLAdditions.h
+++ b/platform/darwin/src/NSProcessInfo+MGLAdditions.h
@@ -4,6 +4,10 @@ void mgl_linkProcessInfoCategory();
@interface NSProcessInfo (MGLAdditions)
+/**
+ Returns YES if the current process is Interface Builder’s helper process for
+ rendering designables.
+ */
- (BOOL)mgl_isInterfaceBuilderDesignablesAgent;
@end
diff --git a/platform/darwin/src/NSProcessInfo+MGLAdditions.m b/platform/darwin/src/NSProcessInfo+MGLAdditions.m
new file mode 100644
index 0000000000..3da2bf73ed
--- /dev/null
+++ b/platform/darwin/src/NSProcessInfo+MGLAdditions.m
@@ -0,0 +1,17 @@
+#import "NSProcessInfo+MGLAdditions.h"
+
+void mgl_linkProcessInfoCategory() {}
+
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
+ static NSString * const MGLIBDesignablesAgentProcessName = @"IBDesignablesAgentCocoaTouch";
+#elif TARGET_OS_MAC
+ static NSString * const MGLIBDesignablesAgentProcessName = @"IBDesignablesAgent";
+#endif
+
+@implementation NSProcessInfo (MGLAdditions)
+
+- (BOOL)mgl_isInterfaceBuilderDesignablesAgent {
+ return [self.processName isEqualToString:MGLIBDesignablesAgentProcessName];
+}
+
+@end
diff --git a/platform/ios/include/MGLAccountManager.h b/platform/ios/include/MGLAccountManager.h
deleted file mode 100644
index c52ef08607..0000000000
--- a/platform/ios/include/MGLAccountManager.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#import <Foundation/Foundation.h>
-
-#import "MGLTypes.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-/** The MGLAccountManager object provides a global way to set a Mapbox API access token, as well as other settings used framework-wide. */
-@interface MGLAccountManager : NSObject
-
-#pragma mark Authorizing Access
-
-/**
- Set the Mapbox API access token for the framework.
-
- You can set an access token on MGLAccountManager or on an individual map view. The same token is used throughout the framework.
- @param accessToken The Mapbox API access token.
- */
-+ (void)setAccessToken:(nullable NSString *)accessToken;
-
-/**
- Retreive the Mapbox API access token for the framework.
-
- You can set an access token on MGLAccountManager or on an individual map view. The same token is used throughout the framework.
-
- @return accessToken The Mapbox API access token.
- */
-+ (nullable NSString *)accessToken;
-
-+ (BOOL)mapboxMetricsEnabledSettingShownInApp __attribute__((deprecated("Telemetry settings are now always shown in the ℹ️ menu.")));
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/platform/ios/src/NSProcessInfo+MGLAdditions.m b/platform/ios/src/NSProcessInfo+MGLAdditions.m
deleted file mode 100644
index 73d76bc17f..0000000000
--- a/platform/ios/src/NSProcessInfo+MGLAdditions.m
+++ /dev/null
@@ -1,12 +0,0 @@
-#import "NSProcessInfo+MGLAdditions.h"
-
-@implementation NSProcessInfo (MGLAdditions)
-
-void mgl_linkProcessInfoCategory() {}
-
-- (BOOL)mgl_isInterfaceBuilderDesignablesAgent
-{
- return [self.processName isEqualToString:@"IBDesignablesAgentCocoaTouch"];
-}
-
-@end
diff --git a/platform/osx/include/MGLAccountManager.h b/platform/osx/include/MGLAccountManager.h
deleted file mode 100644
index efcec5419c..0000000000
--- a/platform/osx/include/MGLAccountManager.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#import <Foundation/Foundation.h>
-
-#import "MGLTypes.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-/** The MGLAccountManager object provides a global way to set a Mapbox API
- access token, as well as other settings used framework-wide. */
-@interface MGLAccountManager : NSObject
-
-#pragma mark Authorizing access
-/** @name Authorizing Access */
-
-/** Set the
- [Mapbox access token](https://www.mapbox.com/help/define-access-token/) to
- used by all instances of MGLMapView in the current application.
-
- Mapbox-hosted vector tiles and styles require an API access token, which you
- can obtain from the
- [Mapbox account page](https://www.mapbox.com/studio/account/tokens/). Access
- tokens associate requests to Mapbox’s vector tile and style APIs with your
- Mapbox account. They also deter other developers from using your styles
- without your permission.
-
- @param accessToken A Mapbox access token. Calling this method with a value
- of `nil` has no effect.
-
- @note You must set the access token before attempting to load any
- Mapbox-hosted style. Therefore, you should generally set it before
- creating an instance of MGLMapView. The recommended way to set an access
- token is to add an entry to your application’s Info.plist file with the
- key `MGLMapboxAccessToken` and the type String. Alternatively, you may
- call this method from your application delegate’s
- -applicationDidFinishLaunching: method. */
-+ (void)setAccessToken:(nullable NSString *)accessToken;
-
-/** Returns the
- [Mapbox access token](https://www.mapbox.com/help/define-access-token/) in
- use by instances of MGLMapView in the current application. */
-+ (nullable NSString *)accessToken;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/platform/osx/sdk/Mapbox.h b/platform/osx/sdk/Mapbox.h
index ca09fbd641..018d16b3c0 100644
--- a/platform/osx/sdk/Mapbox.h
+++ b/platform/osx/sdk/Mapbox.h
@@ -9,6 +9,9 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[];
#import <Mapbox/MGLAccountManager.h>
#import <Mapbox/MGLAnnotation.h>
#import <Mapbox/MGLAnnotationImage.h>
+#import <Mapbox/MGLDownloadable.h>
+#import <Mapbox/MGLDownloadRegion.h>
+#import <Mapbox/MGLDownloadController.h>
#import <Mapbox/MGLGeometry.h>
#import <Mapbox/MGLMapCamera.h>
#import <Mapbox/MGLMapView.h>
@@ -21,4 +24,5 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[];
#import <Mapbox/MGLPolyline.h>
#import <Mapbox/MGLShape.h>
#import <Mapbox/MGLStyle.h>
+#import <Mapbox/MGLTilePyramidDownloadRegion.h>
#import <Mapbox/MGLTypes.h>
diff --git a/platform/osx/sdk/Mapbox.m b/platform/osx/sdk/Mapbox.m
index 58ebb408e0..5246124088 100644
--- a/platform/osx/sdk/Mapbox.m
+++ b/platform/osx/sdk/Mapbox.m
@@ -19,6 +19,8 @@ static void InitializeMapbox() {
[MGLAccountManager class];
[MGLAnnotationImage class];
+ [MGLDownloadable class];
+ [MGLDownloadController class];
[MGLMapCamera class];
[MGLMapView class];
[MGLMultiPoint class];
@@ -27,4 +29,5 @@ static void InitializeMapbox() {
[MGLPolyline class];
[MGLShape class];
[MGLStyle class];
+ [MGLTilePyramidDownloadRegion class];
}
diff --git a/platform/osx/src/MGLAccountManager.m b/platform/osx/src/MGLAccountManager.m
deleted file mode 100644
index 8458248357..0000000000
--- a/platform/osx/src/MGLAccountManager.m
+++ /dev/null
@@ -1,54 +0,0 @@
-#import "MGLAccountManager_Private.h"
-
-#import <MGLMapView.h>
-
-@interface MGLAccountManager ()
-
-@property (atomic) NSString *accessToken;
-
-@end
-
-@implementation MGLAccountManager
-
-#pragma mark - Internal
-
-+ (void)load {
- // Read the initial configuration from Info.plist.
- NSString *accessToken = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLMapboxAccessToken"];
- if (accessToken.length) {
- self.accessToken = accessToken;
- }
-}
-
-+ (instancetype)sharedManager {
- static dispatch_once_t onceToken;
- static MGLAccountManager *_sharedManager;
- void (^setupBlock)() = ^{
- dispatch_once(&onceToken, ^{
- _sharedManager = [[self alloc] init];
- });
- };
- if (![[NSThread currentThread] isMainThread]) {
- dispatch_sync(dispatch_get_main_queue(), ^{
- setupBlock();
- });
- }
- else {
- setupBlock();
- }
- return _sharedManager;
-}
-
-+ (void)setAccessToken:(NSString *)accessToken {
- accessToken = [accessToken stringByTrimmingCharactersInSet:
- [NSCharacterSet whitespaceAndNewlineCharacterSet]];
- if (![accessToken length]) return;
-
- [MGLAccountManager sharedManager].accessToken = accessToken;
-}
-
-+ (NSString *)accessToken {
- return [MGLAccountManager sharedManager].accessToken;
-}
-
-@end
diff --git a/platform/osx/src/MGLAccountManager_Private.h b/platform/osx/src/MGLAccountManager_Private.h
deleted file mode 100644
index 5088c8dfd2..0000000000
--- a/platform/osx/src/MGLAccountManager_Private.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#import <MGLAccountManager.h>
-
-@interface MGLAccountManager (Private)
-
-/**
- Returns the shared instance of the `MGLAccountManager` class.
-
- This method can be called from any thread.
- */
-+ (instancetype)sharedManager;
-
-/// The current global access token.
-@property (atomic) NSString *accessToken;
-
-@end
diff --git a/platform/osx/src/MGLAnnotationImage.m b/platform/osx/src/MGLAnnotationImage.m
index e65a6d15cf..49346b073b 100644
--- a/platform/osx/src/MGLAnnotationImage.m
+++ b/platform/osx/src/MGLAnnotationImage.m
@@ -1,4 +1,4 @@
-#import <MGLAnnotationImage.h>
+#import "MGLAnnotationImage.h"
@interface MGLAnnotationImage ()
diff --git a/platform/osx/src/MGLMapView+IBAdditions.m b/platform/osx/src/MGLMapView+IBAdditions.m
index cafd4511f1..da18760645 100644
--- a/platform/osx/src/MGLMapView+IBAdditions.m
+++ b/platform/osx/src/MGLMapView+IBAdditions.m
@@ -1,4 +1,4 @@
-#import <MGLMapView+IBAdditions.h>
+#import "MGLMapView+IBAdditions.h"
#import "MGLMapView_Private.h"
diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm
index 67729c2607..07c080663f 100644
--- a/platform/osx/src/MGLMapView.mm
+++ b/platform/osx/src/MGLMapView.mm
@@ -1,18 +1,18 @@
#import "MGLMapView_Private.h"
-#import "MGLAccountManager_Private.h"
#import "MGLAttributionButton.h"
#import "MGLCompassCell.h"
#import "MGLOpenGLLayer.h"
#import "MGLStyle.h"
+#import "../../darwin/src/MGLAccountManager_Private.h"
#import "../../darwin/src/MGLGeometry_Private.h"
#import "../../darwin/src/MGLMultiPoint_Private.h"
-#import <MGLMapCamera.h>
-#import <MGLPolygon.h>
-#import <MGLPolyline.h>
-#import <MGLAnnotationImage.h>
-#import <MGLMapViewDelegate.h>
+#import "MGLMapCamera.h"
+#import "MGLPolygon.h"
+#import "MGLPolyline.h"
+#import "MGLAnnotationImage.h"
+#import "MGLMapViewDelegate.h"
#import <mbgl/mbgl.hpp>
#import <mbgl/annotation/point_annotation.hpp>
@@ -30,8 +30,8 @@
#import <map>
#import <unordered_set>
-#import "NSBundle+MGLAdditions.h"
-#import "NSProcessInfo+MGLAdditions.h"
+#import "../../darwin/src/NSBundle+MGLAdditions.h"
+#import "../../darwin/src/NSProcessInfo+MGLAdditions.h"
#import "../../darwin/src/NSException+MGLAdditions.h"
#import "../../darwin/src/NSString+MGLAdditions.h"
diff --git a/platform/osx/src/MGLMapView_Private.h b/platform/osx/src/MGLMapView_Private.h
index a162beca61..b9a112718e 100644
--- a/platform/osx/src/MGLMapView_Private.h
+++ b/platform/osx/src/MGLMapView_Private.h
@@ -1,4 +1,4 @@
-#import <MGLMapView.h>
+#import "MGLMapView.h"
void mgl_linkMapViewIBCategory();
diff --git a/platform/osx/src/NSBundle+MGLAdditions.h b/platform/osx/src/NSBundle+MGLAdditions.h
deleted file mode 100644
index 642fcf141b..0000000000
--- a/platform/osx/src/NSBundle+MGLAdditions.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#import <Foundation/Foundation.h>
-
-#import "MGLTypes.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-void mgl_linkBundleCategory();
-
-@interface NSBundle (MGLAdditions)
-
-/// Returns the Mapbox.framework bundle.
-+ (instancetype)mgl_frameworkBundle;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/platform/osx/src/NSBundle+MGLAdditions.m b/platform/osx/src/NSBundle+MGLAdditions.m
deleted file mode 100644
index 658d515ebf..0000000000
--- a/platform/osx/src/NSBundle+MGLAdditions.m
+++ /dev/null
@@ -1,13 +0,0 @@
-#import "NSBundle+MGLAdditions.h"
-
-#import "MGLAccountManager.h"
-
-void mgl_linkBundleCategory() {}
-
-@implementation NSBundle (MGLAdditions)
-
-+ (instancetype)mgl_frameworkBundle {
- return [self bundleForClass:[MGLAccountManager class]];
-}
-
-@end
diff --git a/platform/osx/src/NSProcessInfo+MGLAdditions.h b/platform/osx/src/NSProcessInfo+MGLAdditions.h
deleted file mode 100644
index cd5ec148ec..0000000000
--- a/platform/osx/src/NSProcessInfo+MGLAdditions.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#import <Foundation/Foundation.h>
-
-void mgl_linkProcessInfoCategory();
-
-@interface NSProcessInfo (MGLAdditions)
-
-/// Returns YES if the current process is Interface Builder’s helper process for
-/// rendering designables.
-- (BOOL)mgl_isInterfaceBuilderDesignablesAgent;
-
-@end
diff --git a/platform/osx/src/NSProcessInfo+MGLAdditions.m b/platform/osx/src/NSProcessInfo+MGLAdditions.m
deleted file mode 100644
index 16f869703c..0000000000
--- a/platform/osx/src/NSProcessInfo+MGLAdditions.m
+++ /dev/null
@@ -1,11 +0,0 @@
-#import "NSProcessInfo+MGLAdditions.h"
-
-void mgl_linkProcessInfoCategory() {}
-
-@implementation NSProcessInfo (MGLAdditions)
-
-- (BOOL)mgl_isInterfaceBuilderDesignablesAgent {
- return [self.processName isEqualToString:@"IBDesignablesAgent"];
-}
-
-@end