Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
refs #2966: remove -ObjC linker flag & bring in categories via other …
Browse files Browse the repository at this point in the history
…means
  • Loading branch information
incanus committed Nov 7, 2015
1 parent 1745141 commit 423cfc1
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gyp/platform-ios.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -82,7 +84,6 @@
'-framework MobileCoreServices',
'-framework QuartzCore',
'-framework SystemConfiguration',
'-ObjC',
],
},

Expand Down
3 changes: 3 additions & 0 deletions platform/ios/MGLAccountManager.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "MGLAccountManager_Private.h"
#import "MGLMapboxEvents.h"
#import "MGLCategoryLoader.h"
#import "NSProcessInfo+MGLAdditions.h"

#import <Fabric/FABKitProtocol.h>
Expand Down Expand Up @@ -34,6 +35,8 @@ + (void)load {
// Can be called from any thread.
//
+ (instancetype) sharedManager {
[MGLCategoryLoader loadCategories];

if (NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent) {
return nil;
}
Expand Down
7 changes: 7 additions & 0 deletions platform/ios/MGLCategoryLoader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#import <Foundation/Foundation.h>

@interface MGLCategoryLoader : NSObject

+ (void)loadCategories;

@end
18 changes: 18 additions & 0 deletions platform/ios/MGLCategoryLoader.m
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions platform/ios/NSBundle+MGLAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

NS_ASSUME_NONNULL_BEGIN

void mgl_linkBundleCategory();

@interface NSBundle (MGLAdditions)

+ (NSString *)mgl_resourceBundlePath;
Expand Down
2 changes: 2 additions & 0 deletions platform/ios/NSBundle+MGLAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

@implementation NSBundle (MGLAdditions)

void mgl_linkBundleCategory(){}

+ (NSString *)mgl_resourceBundlePath
{
NSString *resourceBundlePath = [[NSBundle bundleForClass:[MGLMapView class]] pathForResource:@"Mapbox" ofType:@"bundle"];
Expand Down
2 changes: 2 additions & 0 deletions platform/ios/NSProcessInfo+MGLAdditions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#import <Foundation/Foundation.h>

void mgl_linkProcessCategory();

@interface NSProcessInfo (MGLAdditions)

- (BOOL)mgl_isInterfaceBuilderDesignablesAgent;
Expand Down
2 changes: 2 additions & 0 deletions platform/ios/NSProcessInfo+MGLAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

@implementation NSProcessInfo (MGLAdditions)

void mgl_linkProcessCategory(){}

- (BOOL)mgl_isInterfaceBuilderDesignablesAgent
{
return [self.processName isEqualToString:@"IBDesignablesAgentCocoaTouch"];
Expand Down
2 changes: 2 additions & 0 deletions platform/ios/NSString+MGLAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

NS_ASSUME_NONNULL_BEGIN

void mgl_linkStringCategory();

@interface NSString (MGLAdditions)

/** Returns the receiver if non-empty or nil if empty. */
Expand Down
2 changes: 2 additions & 0 deletions platform/ios/NSString+MGLAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

@implementation NSString (MGLAdditions)

void mgl_linkStringCategory(){}

- (nullable NSString *)mgl_stringOrNilIfEmpty
{
return self.length ? self : nil;
Expand Down

0 comments on commit 423cfc1

Please sign in to comment.