From 7a38e568191a68e3311d36296e14c105b12c051c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 14 Apr 2016 09:52:04 -0700 Subject: [PATCH] [ios] Removed alternative to -ObjC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Xcode’s static library template comes with the -ObjC linker flag by default. Instead of removing that flag, this change removes the various imperfect workarounds we’ve been using to ensure that private SDK categories link. Given the size decrease in this static library since #2966 was fixed, we should have room to spare for the more straightforward approach. Moreover, an application that uses MGLMapView in a storyboard no longer needs to add -ObjC to the application target, which bloated the entire application, including other frameworks that had no need for -ObjC. -ObjC isn’t even needed for dynamic frameworks, and the OS X SDK is only built as a dynamic framework. --- platform/darwin/src/MGLAccountManager.m | 10 ------ platform/darwin/src/NSBundle+MGLAdditions.h | 2 -- platform/darwin/src/NSBundle+MGLAdditions.m | 2 -- .../darwin/src/NSProcessInfo+MGLAdditions.h | 2 -- .../darwin/src/NSProcessInfo+MGLAdditions.m | 2 -- platform/darwin/src/NSString+MGLAdditions.h | 2 -- platform/darwin/src/NSString+MGLAdditions.m | 2 -- platform/ios/CHANGELOG.md | 1 + platform/ios/INSTALL.md | 2 -- platform/ios/docs/pod-README.md | 2 -- platform/ios/framework/Mapbox.m | 32 ------------------ platform/ios/ios.xcodeproj/project.pbxproj | 4 --- platform/osx/platform.gyp | 1 - platform/osx/sdk/Mapbox.m | 33 ------------------- platform/osx/src/MGLMapView+IBAdditions.m | 2 -- platform/osx/src/MGLMapView_Private.h | 2 -- 16 files changed, 1 insertion(+), 100 deletions(-) delete mode 100644 platform/ios/framework/Mapbox.m delete mode 100644 platform/osx/sdk/Mapbox.m diff --git a/platform/darwin/src/MGLAccountManager.m b/platform/darwin/src/MGLAccountManager.m index bfaf9faae99..31baf4e2493 100644 --- a/platform/darwin/src/MGLAccountManager.m +++ b/platform/darwin/src/MGLAccountManager.m @@ -1,8 +1,6 @@ #import "MGLAccountManager_Private.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" @@ -108,14 +106,6 @@ + (void)initializeIfNeeded { } else { NSLog(@"MGLAccountManager is used in a project that doesn’t have Fabric."); } - - // https://github.com/mapbox/mapbox-gl-native/issues/2966 - mgl_linkBundleCategory(); - mgl_linkStringCategory(); - mgl_linkProcessInfoCategory(); - - // https://github.com/mapbox/mapbox-gl-native/issues/3113 - [MGLMapView class]; } #endif diff --git a/platform/darwin/src/NSBundle+MGLAdditions.h b/platform/darwin/src/NSBundle+MGLAdditions.h index 52ef7fbfa74..8a3e5c3c2ef 100644 --- a/platform/darwin/src/NSBundle+MGLAdditions.h +++ b/platform/darwin/src/NSBundle+MGLAdditions.h @@ -4,8 +4,6 @@ NS_ASSUME_NONNULL_BEGIN -void mgl_linkBundleCategory(); - @interface NSBundle (MGLAdditions) /// Returns the bundle containing the SDK’s classes and Info.plist file. diff --git a/platform/darwin/src/NSBundle+MGLAdditions.m b/platform/darwin/src/NSBundle+MGLAdditions.m index e1f3e7c720c..76d9cc0db78 100644 --- a/platform/darwin/src/NSBundle+MGLAdditions.m +++ b/platform/darwin/src/NSBundle+MGLAdditions.m @@ -2,8 +2,6 @@ #import "MGLAccountManager.h" -void mgl_linkBundleCategory() {} - @implementation NSBundle (MGLAdditions) + (instancetype)mgl_frameworkBundle { diff --git a/platform/darwin/src/NSProcessInfo+MGLAdditions.h b/platform/darwin/src/NSProcessInfo+MGLAdditions.h index ea231d4e6a9..1dc1439d530 100644 --- a/platform/darwin/src/NSProcessInfo+MGLAdditions.h +++ b/platform/darwin/src/NSProcessInfo+MGLAdditions.h @@ -1,7 +1,5 @@ #import -void mgl_linkProcessInfoCategory(); - @interface NSProcessInfo (MGLAdditions) /** diff --git a/platform/darwin/src/NSProcessInfo+MGLAdditions.m b/platform/darwin/src/NSProcessInfo+MGLAdditions.m index 3da2bf73edc..293f49538b6 100644 --- a/platform/darwin/src/NSProcessInfo+MGLAdditions.m +++ b/platform/darwin/src/NSProcessInfo+MGLAdditions.m @@ -1,7 +1,5 @@ #import "NSProcessInfo+MGLAdditions.h" -void mgl_linkProcessInfoCategory() {} - #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR static NSString * const MGLIBDesignablesAgentProcessName = @"IBDesignablesAgentCocoaTouch"; #elif TARGET_OS_MAC diff --git a/platform/darwin/src/NSString+MGLAdditions.h b/platform/darwin/src/NSString+MGLAdditions.h index 6064f8b40f4..3001624d320 100644 --- a/platform/darwin/src/NSString+MGLAdditions.h +++ b/platform/darwin/src/NSString+MGLAdditions.h @@ -4,8 +4,6 @@ NS_ASSUME_NONNULL_BEGIN -void mgl_linkStringCategory(); - @interface NSString (MGLAdditions) /** Returns the receiver if non-empty or nil if empty. */ diff --git a/platform/darwin/src/NSString+MGLAdditions.m b/platform/darwin/src/NSString+MGLAdditions.m index b94a5f0198d..969886651b0 100644 --- a/platform/darwin/src/NSString+MGLAdditions.m +++ b/platform/darwin/src/NSString+MGLAdditions.m @@ -1,7 +1,5 @@ #import "NSString+MGLAdditions.h" -void mgl_linkStringCategory() {} - @implementation NSString (MGLAdditions) - (nullable NSString *)mgl_stringOrNilIfEmpty diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 8541fc296db..d450401b948 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -4,6 +4,7 @@ Mapbox welcomes participation and contributions from everyone. If you’d like ## master +- Applications linking against the SDK static framework no longer need to add `-ObjC` to the Other Linker Flags (`OTHER_LDFLAGS`) build setting. If you previously added this flag solely for this SDK, removing the flag may potentially reduce the overall size of your application. ([#4641](https://github.com/mapbox/mapbox-gl-native/pull/4641)) - User location heading updates now resume properly when an app becomes active again. ([#4674](https://github.com/mapbox/mapbox-gl-native/pull/4674)) - Removed unused SVG files from the SDK’s resource bundle. ([#4641](https://github.com/mapbox/mapbox-gl-native/pull/4641)) diff --git a/platform/ios/INSTALL.md b/platform/ios/INSTALL.md index 4c769cedc41..b3ead6d0d6b 100644 --- a/platform/ios/INSTALL.md +++ b/platform/ios/INSTALL.md @@ -123,8 +123,6 @@ If your application targets iOS 7.x, you’ll need to install the static framewo - `libsqlite3.tbd` - `libz.tbd` -1. In the Build Settings tab, add `-ObjC` to the “Other Linker Flags” (`OTHER_LDFLAGS`) build setting. - ### Use 1. Mapbox vector tiles require a Mapbox account and API access token. In the project editor, select the application target. In the Info tab, set `MGLMapboxAccessToken` to your access token. You can obtain one from the [Mapbox account page](https://www.mapbox.com/studio/account/tokens/). diff --git a/platform/ios/docs/pod-README.md b/platform/ios/docs/pod-README.md index d62e23b6064..9ed62c56103 100644 --- a/platform/ios/docs/pod-README.md +++ b/platform/ios/docs/pod-README.md @@ -54,8 +54,6 @@ If your application targets iOS 7.x, you’ll need to install the static framewo - `libsqlite3.tbd` - `libz.tbd` -1. In the Build Settings tab, add `-ObjC` to the “Other Linker Flags” (`OTHER_LDFLAGS`) build setting. - {{/STATIC}} ## Configuration diff --git a/platform/ios/framework/Mapbox.m b/platform/ios/framework/Mapbox.m deleted file mode 100644 index a3f7b8e754f..00000000000 --- a/platform/ios/framework/Mapbox.m +++ /dev/null @@ -1,32 +0,0 @@ -#import - -#import "NSBundle+MGLAdditions.h" -#import "NSProcessInfo+MGLAdditions.h" -#import "NSString+MGLAdditions.h" - -__attribute__((constructor)) -static void InitializeMapbox() { - static int initialized = 0; - if (initialized) { - return; - } - - mgl_linkBundleCategory(); - mgl_linkStringCategory(); - mgl_linkProcessInfoCategory(); - - [MGLAccountManager class]; - [MGLAnnotationImage class]; - [MGLMapCamera class]; - [MGLMapView class]; - [MGLMultiPoint class]; - [MGLOfflinePack class]; - [MGLOfflineStorage class]; - [MGLPointAnnotation class]; - [MGLPolygon class]; - [MGLPolyline class]; - [MGLShape class]; - [MGLStyle class]; - [MGLTilePyramidOfflineRegion class]; - [MGLUserLocation class]; -} diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 3260c2ccc51..0173e8f6bf6 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -87,7 +87,6 @@ DA88485C1CBAFB9800AB86E3 /* MGLUserLocationAnnotationView.h in Headers */ = {isa = PBXBuildFile; fileRef = DA88484D1CBAFB9800AB86E3 /* MGLUserLocationAnnotationView.h */; }; DA88485D1CBAFB9800AB86E3 /* MGLUserLocationAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA88484E1CBAFB9800AB86E3 /* MGLUserLocationAnnotationView.m */; }; DA8848601CBAFC2E00AB86E3 /* Mapbox.h in Headers */ = {isa = PBXBuildFile; fileRef = DA88485E1CBAFC2E00AB86E3 /* Mapbox.h */; settings = {ATTRIBUTES = (Public, ); }; }; - DA8848611CBAFC2E00AB86E3 /* Mapbox.m in Sources */ = {isa = PBXBuildFile; fileRef = DA88485F1CBAFC2E00AB86E3 /* Mapbox.m */; }; DA88486D1CBAFCC100AB86E3 /* Compass.png in Resources */ = {isa = PBXBuildFile; fileRef = DA8848631CBAFCC100AB86E3 /* Compass.png */; }; DA88486E1CBAFCC100AB86E3 /* Compass@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DA8848641CBAFCC100AB86E3 /* Compass@2x.png */; }; DA88486F1CBAFCC100AB86E3 /* Compass@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = DA8848651CBAFCC100AB86E3 /* Compass@3x.png */; }; @@ -310,7 +309,6 @@ DA88484D1CBAFB9800AB86E3 /* MGLUserLocationAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MGLUserLocationAnnotationView.h; path = src/MGLUserLocationAnnotationView.h; sourceTree = ""; }; DA88484E1CBAFB9800AB86E3 /* MGLUserLocationAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLUserLocationAnnotationView.m; path = src/MGLUserLocationAnnotationView.m; sourceTree = ""; }; DA88485E1CBAFC2E00AB86E3 /* Mapbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Mapbox.h; sourceTree = ""; }; - DA88485F1CBAFC2E00AB86E3 /* Mapbox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Mapbox.m; sourceTree = ""; }; DA8848631CBAFCC100AB86E3 /* Compass.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Compass.png; sourceTree = ""; }; DA8848641CBAFCC100AB86E3 /* Compass@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Compass@2x.png"; sourceTree = ""; }; DA8848651CBAFCC100AB86E3 /* Compass@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Compass@3x.png"; sourceTree = ""; }; @@ -465,7 +463,6 @@ isa = PBXGroup; children = ( DA88485E1CBAFC2E00AB86E3 /* Mapbox.h */, - DA88485F1CBAFC2E00AB86E3 /* Mapbox.m */, DA8847DE1CBAFA3E00AB86E3 /* Foundation */, DA8848331CBAFB2A00AB86E3 /* Kit */, DA8848621CBAFCC100AB86E3 /* Resources */, @@ -922,7 +919,6 @@ DA8848901CBB048E00AB86E3 /* reachability.m in Sources */, DA8848211CBAFA6200AB86E3 /* MGLOfflinePack.mm in Sources */, DA8848591CBAFB9800AB86E3 /* MGLMapView.mm in Sources */, - DA8848611CBAFC2E00AB86E3 /* Mapbox.m in Sources */, DA8848501CBAFB9800AB86E3 /* MGLAnnotationImage.m in Sources */, DA8848281CBAFA6200AB86E3 /* MGLShape.m in Sources */, DA8848321CBAFA6200AB86E3 /* NSString+MGLAdditions.m in Sources */, diff --git a/platform/osx/platform.gyp b/platform/osx/platform.gyp index 229c7218457..b5b12b70c19 100644 --- a/platform/osx/platform.gyp +++ b/platform/osx/platform.gyp @@ -143,7 +143,6 @@ ], 'sources': [ - 'sdk/Mapbox.m', '../darwin/src/NSException+MGLAdditions.h', '../darwin/src/NSString+MGLAdditions.h', '../darwin/src/NSString+MGLAdditions.m', diff --git a/platform/osx/sdk/Mapbox.m b/platform/osx/sdk/Mapbox.m deleted file mode 100644 index dc935cd2650..00000000000 --- a/platform/osx/sdk/Mapbox.m +++ /dev/null @@ -1,33 +0,0 @@ -#import - -#import "../src/MGLMapView_Private.h" -#import "../../darwin/src/NSBundle+MGLAdditions.h" -#import "../../darwin/src/NSProcessInfo+MGLAdditions.h" -#import "../../darwin/src/NSString+MGLAdditions.h" - -__attribute__((constructor)) -static void InitializeMapbox() { - static int initialized = 0; - if (initialized) { - return; - } - - mgl_linkBundleCategory(); - mgl_linkStringCategory(); - mgl_linkProcessInfoCategory(); - mgl_linkMapViewIBCategory(); - - [MGLAccountManager class]; - [MGLAnnotationImage class]; - [MGLMapCamera class]; - [MGLMapView class]; - [MGLMultiPoint class]; - [MGLOfflinePack class]; - [MGLOfflineStorage class]; - [MGLPointAnnotation class]; - [MGLPolygon class]; - [MGLPolyline class]; - [MGLShape class]; - [MGLStyle class]; - [MGLTilePyramidOfflineRegion class]; -} diff --git a/platform/osx/src/MGLMapView+IBAdditions.m b/platform/osx/src/MGLMapView+IBAdditions.m index da187606454..eada47ef904 100644 --- a/platform/osx/src/MGLMapView+IBAdditions.m +++ b/platform/osx/src/MGLMapView+IBAdditions.m @@ -2,8 +2,6 @@ #import "MGLMapView_Private.h" -void mgl_linkMapViewIBCategory() {} - @implementation MGLMapView (IBAdditions) + (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingStyleURL__ { diff --git a/platform/osx/src/MGLMapView_Private.h b/platform/osx/src/MGLMapView_Private.h index b9a112718e8..76b1727925d 100644 --- a/platform/osx/src/MGLMapView_Private.h +++ b/platform/osx/src/MGLMapView_Private.h @@ -1,7 +1,5 @@ #import "MGLMapView.h" -void mgl_linkMapViewIBCategory(); - @interface MGLMapView (Private) /// True if the view or application is in a state where it is not expected to be