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', '../platform/ios/MGLAnnotationImage.m',
'../include/mbgl/ios/MGLStyle.h', '../include/mbgl/ios/MGLStyle.h',
'../platform/ios/MGLStyle.mm', '../platform/ios/MGLStyle.mm',
'../platform/ios/MGLCategoryLoader.h',
'../platform/ios/MGLCategoryLoader.m',
'../platform/ios/NSBundle+MGLAdditions.h', '../platform/ios/NSBundle+MGLAdditions.h',
'../platform/ios/NSBundle+MGLAdditions.m', '../platform/ios/NSBundle+MGLAdditions.m',
'../platform/ios/NSException+MGLAdditions.h', '../platform/ios/NSException+MGLAdditions.h',
@@ -82,7 +84,6 @@
'-framework MobileCoreServices', '-framework MobileCoreServices',
'-framework QuartzCore', '-framework QuartzCore',
'-framework SystemConfiguration', '-framework SystemConfiguration',
'-ObjC',
], ],
}, },

View File

@@ -1,5 +1,6 @@
#import "MGLAccountManager_Private.h" #import "MGLAccountManager_Private.h"
#import "MGLMapboxEvents.h" #import "MGLMapboxEvents.h"
#import "MGLCategoryLoader.h"
#import "NSProcessInfo+MGLAdditions.h" #import "NSProcessInfo+MGLAdditions.h"
#import <Fabric/FABKitProtocol.h> #import <Fabric/FABKitProtocol.h>
@@ -34,6 +35,8 @@
// Can be called from any thread. // Can be called from any thread.
// //
+ (instancetype) sharedManager { + (instancetype) sharedManager {
[MGLCategoryLoader loadCategories];
if (NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent) { if (NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent) {
return nil; 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 NS_ASSUME_NONNULL_BEGIN
void mgl_linkBundleCategory();
@interface NSBundle (MGLAdditions) @interface NSBundle (MGLAdditions)
+ (NSString *)mgl_resourceBundlePath; + (NSString *)mgl_resourceBundlePath;

View File

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

View File

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

View File

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

View File

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

View File

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