refs #2966: remove -ObjC linker flag & bring in categories via other means

This commit is contained in:
Justin R. Miller
2015-11-06 14:58:17 -08:00
parent 17451418cc
commit 423cfc11e5
10 changed files with 42 additions and 1 deletions

View File

@@ -54,6 +54,8 @@
'../platform/ios/MGLAnnotationImage.m',
'../include/mbgl/ios/MGLStyle.h',
'../platform/ios/MGLStyle.mm',
'../platform/ios/MGLCategoryLoader.h',
'../platform/ios/MGLCategoryLoader.m',
'../platform/ios/NSBundle+MGLAdditions.h',
'../platform/ios/NSBundle+MGLAdditions.m',
'../platform/ios/NSException+MGLAdditions.h',
@@ -82,7 +84,6 @@
'-framework MobileCoreServices',
'-framework QuartzCore',
'-framework SystemConfiguration',
'-ObjC',
],
},

View File

@@ -1,5 +1,6 @@
#import "MGLAccountManager_Private.h"
#import "MGLMapboxEvents.h"
#import "MGLCategoryLoader.h"
#import "NSProcessInfo+MGLAdditions.h"
#import <Fabric/FABKitProtocol.h>
@@ -34,6 +35,8 @@
// Can be called from any thread.
//
+ (instancetype) sharedManager {
[MGLCategoryLoader loadCategories];
if (NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent) {
return nil;
}

View File

@@ -0,0 +1,7 @@
#import <Foundation/Foundation.h>
@interface MGLCategoryLoader : NSObject
+ (void)loadCategories;
@end

View File

@@ -0,0 +1,18 @@
#import "MGLCategoryLoader.h"
#import "NSBundle+MGLAdditions.h"
#import "NSProcessInfo+MGLAdditions.h"
#import "NSString+MGLAdditions.h"
// https://github.com/mapbox/mapbox-gl-native/issues/2966
@implementation MGLCategoryLoader
+ (void)loadCategories
{
mgl_linkBundleCategory();
mgl_linkProcessCategory();
mgl_linkStringCategory();
}
@end

View File

@@ -2,6 +2,8 @@
NS_ASSUME_NONNULL_BEGIN
void mgl_linkBundleCategory();
@interface NSBundle (MGLAdditions)
+ (NSString *)mgl_resourceBundlePath;

View File

@@ -4,6 +4,8 @@
@implementation NSBundle (MGLAdditions)
void mgl_linkBundleCategory(){}
+ (NSString *)mgl_resourceBundlePath
{
NSString *resourceBundlePath = [[NSBundle bundleForClass:[MGLMapView class]] pathForResource:@"Mapbox" ofType:@"bundle"];

View File

@@ -1,5 +1,7 @@
#import <Foundation/Foundation.h>
void mgl_linkProcessCategory();
@interface NSProcessInfo (MGLAdditions)
- (BOOL)mgl_isInterfaceBuilderDesignablesAgent;

View File

@@ -2,6 +2,8 @@
@implementation NSProcessInfo (MGLAdditions)
void mgl_linkProcessCategory(){}
- (BOOL)mgl_isInterfaceBuilderDesignablesAgent
{
return [self.processName isEqualToString:@"IBDesignablesAgentCocoaTouch"];

View File

@@ -2,6 +2,8 @@
NS_ASSUME_NONNULL_BEGIN
void mgl_linkStringCategory();
@interface NSString (MGLAdditions)
/** Returns the receiver if non-empty or nil if empty. */

View File

@@ -2,6 +2,8 @@
@implementation NSString (MGLAdditions)
void mgl_linkStringCategory(){}
- (nullable NSString *)mgl_stringOrNilIfEmpty
{
return self.length ? self : nil;