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

Commit

Permalink
[ios] Converted iOS SDK into dynamic framework
Browse files Browse the repository at this point in the history
make iproj now produces a target that pulls together static libraries like core and platform-ios into a real dynamic framework. iosapp is pretty much just a regular iOS application that links Mapbox.framework (except for the inclusion of default_styles.hpp). iosapp runs fine in the Simulator and on a device, and the same is true for any application linking against Mapbox.framework.

The ipackage target produces both a Bitcode-disabled static framework and a Bitcode-enabled dynamic framework, eliminating the need for a separate framework.sh. It disables code signing, since that happens on copy when the framework is embedded inside the application bundle. It also merges the device and simulator builds into a single fat framework.

Also bumped itest minimum deployment target to iOS 8.0, the first version that supports linking frameworks.

Fixes #828.
  • Loading branch information
1ec5 committed Jan 22, 2016
1 parent ded8b62 commit 9350d3f
Show file tree
Hide file tree
Showing 33 changed files with 348 additions and 327 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Known issues:

## iOS master

- The SDK is now distributed as a dynamic framework instead of a static library, resulting in a simpler installation workflow and significantly reduced download size. The framework contains both simulator and device content; due to [an Xcode bug](http://www.openradar.me/radar?id=6409498411401216), you’ll need to strip out the simulator content before submitting your application to the App Store. ([#3183](https://github.com/mapbox/mapbox-gl-native/pull/3183))
- Fixed an issue causing the entire MGLMapView to leak. ([#3447](https://github.com/mapbox/mapbox-gl-native/pull/3447))
- `MGLMapView` methods that alter the viewport now accept optional completion handlers. ([#3090](https://github.com/mapbox/mapbox-gl-native/pull/3090))
- You can now modify an annotation’s image after adding the annotation to the map. ([#3146](https://github.com/mapbox/mapbox-gl-native/pull/3146))
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ isim: ; $(RUN) HOST=ios Xcode/iosapp
ibench: export XCODEBUILD_ARGS += -sdk iphoneos ARCHS="arm64"
ibench: ; $(RUN) HOST=ios Xcode/ios-bench

.PHONY: ipackage ipackage-strip ipackage-sim ipackage-no-bitcode itest
.PHONY: ipackage ipackage-strip ipackage-sim itest
ipackage: Xcode/ios ; @JOBS=$(JOBS) ./platform/ios/scripts/package.sh
ipackage-strip: Xcode/ios ; @JOBS=$(JOBS) ./platform/ios/scripts/package.sh strip
ipackage-sim: Xcode/ios ; @JOBS=$(JOBS) ./platform/ios/scripts/package.sh sim
ipackage-no-bitcode: Xcode/ios ; @JOBS=$(JOBS) ./platform/ios/scripts/package.sh no-bitcode
iframework: ipackage-strip ; ./platform/ios/scripts/framework.sh
itest: ipackage-sim ; ./platform/ios/scripts/test.sh

.PHONY: xpackage xpackage-strip xctest
Expand Down
1 change: 1 addition & 0 deletions gyp/ios.gyp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
'includes': [
'../ios/app/mapboxgl-app.gypi',
'../ios/framework/framework-ios.gypi',
'../ios/benchmark/benchmark-ios.gypi',
],
}
51 changes: 17 additions & 34 deletions gyp/platform-ios.gypi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
'targets': [
{ 'target_name': 'platform-ios',
{
'target_name': 'platform-ios',
'product_name': 'mbgl-platform-ios',
'type': 'static_library',
'standalone_static_library': 1,
Expand All @@ -27,51 +28,31 @@
'../platform/darwin/NSException+MGLAdditions.h',
'../platform/darwin/NSString+MGLAdditions.h',
'../platform/darwin/NSString+MGLAdditions.m',
'../include/mbgl/darwin/MGLTypes.h',
'../platform/darwin/MGLTypes.m',
'../include/mbgl/darwin/MGLStyle.h',
'../platform/darwin/MGLStyle.mm',
'../include/mbgl/darwin/MGLGeometry.h',
'../platform/darwin/MGLGeometry_Private.h',
'../platform/darwin/MGLGeometry.mm',
'../include/mbgl/darwin/MGLAnnotation.h',
'../include/mbgl/darwin/MGLShape.h',
'../platform/darwin/MGLShape.m',
'../include/mbgl/darwin/MGLMultiPoint.h',
'../platform/darwin/MGLMultiPoint_Private.h',
'../platform/darwin/MGLMultiPoint.mm',
'../include/mbgl/darwin/MGLOverlay.h',
'../include/mbgl/darwin/MGLPointAnnotation.h',
'../platform/darwin/MGLPointAnnotation.m',
'../include/mbgl/darwin/MGLPolyline.h',
'../platform/darwin/MGLPolyline.mm',
'../include/mbgl/darwin/MGLPolygon.h',
'../platform/darwin/MGLPolygon.mm',
'../include/mbgl/darwin/MGLMapCamera.h',
'../platform/darwin/MGLMapCamera.mm',
'../include/mbgl/ios/Mapbox.h',
'../platform/ios/src/MGLMapboxEvents.h',
'../platform/ios/src/MGLMapboxEvents.m',
'../include/mbgl/ios/MGLMapView.h',
'../include/mbgl/ios/MGLMapView+IBAdditions.h',
'../include/mbgl/ios/MGLMapView+MGLCustomStyleLayerAdditions.h',
'../platform/ios/src/MGLMapView.mm',
'../include/mbgl/ios/MGLAccountManager.h',
'../platform/ios/src/MGLAccountManager_Private.h',
'../platform/ios/src/MGLAccountManager.m',
'../include/mbgl/ios/MGLUserLocation.h',
'../platform/ios/src/MGLUserLocation_Private.h',
'../platform/ios/src/MGLUserLocation.m',
'../platform/ios/src/MGLUserLocationAnnotationView.h',
'../platform/ios/src/MGLUserLocationAnnotationView.m',
'../include/mbgl/ios/MGLAnnotationImage.h',
'../platform/ios/src/MGLAnnotationImage_Private.h',
'../platform/ios/src/MGLAnnotationImage.m',
'../include/mbgl/ios/MGLCalloutView.h',
'../platform/ios/src/MGLCompactCalloutView.h',
'../platform/ios/src/MGLCompactCalloutView.m',
'../platform/ios/src/MGLCategoryLoader.h',
'../platform/ios/src/MGLCategoryLoader.m',
'../platform/ios/src/NSBundle+MGLAdditions.h',
'../platform/ios/src/NSBundle+MGLAdditions.m',
'../platform/ios/src/NSProcessInfo+MGLAdditions.h',
Expand All @@ -82,7 +63,6 @@
'../platform/ios/vendor/Fabric/FABKitProtocol.h',
'../platform/ios/vendor/Fabric/Fabric.h',
'../platform/ios/vendor/Fabric/Fabric+FABKits.h',
'../platform/ios/resources/',
],

'variables': {
Expand All @@ -93,21 +73,24 @@
'<@(sqlite_cflags)',
'<@(zlib_cflags)',
],
'ldflags': [
'<@(sqlite_ldflags)',
'<@(zlib_ldflags)',
],
'libraries': [
'<@(libuv_static_libs)',
'<@(sqlite_static_libs)',
'<@(zlib_static_libs)',
],
'ldflags': [
'<@(sqlite_ldflags)',
'<@(zlib_ldflags)',
'-framework CoreLocation',
'-framework GLKit',
'-framework ImageIO',
'-framework MobileCoreServices',
'-framework QuartzCore',
'-framework SystemConfiguration',
'-ObjC',
'$(SDKROOT)/System/Library/Frameworks/CoreGraphics.framework',
'$(SDKROOT)/System/Library/Frameworks/CoreLocation.framework',
'$(SDKROOT)/System/Library/Frameworks/GLKit.framework',
'$(SDKROOT)/System/Library/Frameworks/ImageIO.framework',
'$(SDKROOT)/System/Library/Frameworks/MobileCoreServices.framework',
'$(SDKROOT)/System/Library/Frameworks/OpenGLES.framework',
'$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework',
'$(SDKROOT)/System/Library/Frameworks/Security.framework',
'$(SDKROOT)/System/Library/Frameworks/SystemConfiguration.framework',
'$(SDKROOT)/System/Library/Frameworks/UIKit.framework',
],
},

Expand Down Expand Up @@ -138,7 +121,7 @@
'../include',
],
'mac_bundle_resources': [
'<!@(find ../platform/ios/resources -type f \! -name "README")',
'<!@(find ../platform/ios/resources -type f \! -name "README" \! -name \'.*\')',
],
},
},
Expand Down
11 changes: 1 addition & 10 deletions ios/Mapbox-iOS-SDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@ Pod::Spec.new do |m|

m.requires_arc = true

m.preserve_paths = '**'
m.resource_bundle = { 'Mapbox' => 'Mapbox.framework/Mapbox.bundle/*' }
m.vendored_frameworks = 'Mapbox.framework'
m.vendored_frameworks = 'dynamic/Mapbox.framework'
m.module_name = 'Mapbox'

m.frameworks = 'CoreLocation', 'GLKit', 'ImageIO', 'MobileCoreServices', 'QuartzCore', 'SystemConfiguration'
m.libraries = 'c++', 'sqlite3', 'z'
m.pod_target_xcconfig = {
'OTHER_CPLUSPLUSFLAGS' => '-std=gnu++11 -stdlib=libc++',
'OTHER_LDFLAGS' => '-ObjC',
}

end
2 changes: 1 addition & 1 deletion ios/app/MBXAppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "MBXAppDelegate.h"
#import "MBXViewController.h"
#import <mbgl/ios/Mapbox.h>
#import <Mapbox/Mapbox.h>

@implementation MBXAppDelegate

Expand Down
2 changes: 1 addition & 1 deletion ios/app/MBXCustomCalloutView.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import <UIKit/UIKit.h>
#import <mbgl/ios/MGLCalloutView.h>
#import <Mapbox/Mapbox.h>

/**
* Basic custom callout view to demonstrate how to
Expand Down
2 changes: 0 additions & 2 deletions ios/app/MBXCustomCalloutView.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#import "MBXCustomCalloutView.h"

#import <mbgl/darwin/MGLAnnotation.h>

static CGFloat const tipHeight = 10.0;
static CGFloat const tipWidth = 10.0;

Expand Down
4 changes: 2 additions & 2 deletions ios/app/MBXViewController.mm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#import "MBXViewController.h"
#import "MBXCustomCalloutView.h"

#import <mbgl/ios/Mapbox.h>
#import <mbgl/util/default_styles.hpp>
#import <Mapbox/Mapbox.h>
#import "../../include/mbgl/util/default_styles.hpp"

#import <CoreLocation/CoreLocation.h>
#import <OpenGLES/ES2/gl.h>
Expand Down
45 changes: 30 additions & 15 deletions ios/app/mapboxgl-app.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
'../../gyp/common.gypi',
],
'targets': [
{ 'target_name': 'iosapp',
{
'target_name': 'iosapp',
'product_name': 'Mapbox GL',
'type': 'executable',
'product_extension': 'app',
Expand All @@ -14,50 +15,64 @@
'./polyline.geojson',
'./threestates.geojson',
'./Settings.bundle/',
'./app-info.plist'
'./app-info.plist',
],

'dependencies': [
'mbgl.gyp:core',
'mbgl.gyp:platform-<(platform_lib)',
'mbgl.gyp:http-<(http_lib)',
'mbgl.gyp:asset-<(asset_lib)',
'iossdk',
],

'sources': [
'./main.m',
'./MBXAppDelegate.h',
'./MBXAppDelegate.m',
'./MBXCustomCalloutView.h',
'./MBXCustomCalloutView.m',
'./MBXViewController.h',
'./MBXViewController.mm',
'main.m',
'MBXAppDelegate.h',
'MBXAppDelegate.m',
'MBXCustomCalloutView.h',
'MBXCustomCalloutView.m',
'MBXViewController.h',
'MBXViewController.mm',
],

'xcode_settings': {
'SDKROOT': 'iphoneos',
'SUPPORTED_PLATFORMS': 'iphonesimulator iphoneos',
'IPHONEOS_DEPLOYMENT_TARGET': '7.0',
'IPHONEOS_DEPLOYMENT_TARGET': '8.0',
'INFOPLIST_FILE': '../ios/app/app-info.plist',
'TARGETED_DEVICE_FAMILY': '1,2',
'COMBINE_HIDPI_IMAGES': 'NO', # don't merge @2x.png images into .tiff files
'COMBINE_HIDPI_IMAGES': 'NO', # disable combining @2x, @3x images into .tiff files
'COPY_PHASE_STRIP': 'NO',
'CLANG_ENABLE_OBJC_ARC': 'YES',
'CLANG_ENABLE_MODULES': 'YES',
'LD_RUNPATH_SEARCH_PATHS': [
'$(inherited)',
'@executable_path/Frameworks',
],
},

'configurations': {
'Debug': {
'xcode_settings': {
'CODE_SIGN_IDENTITY': 'iPhone Developer',
'COPY_PHASE_STRIP': 'NO',
},
},
'Release': {
'xcode_settings': {
'CODE_SIGN_IDENTITY': 'iPhone Distribution',
'ARCHS': [ "armv7", "armv7s", "arm64", "i386", "x86_64" ],
'COPY_PHASE_STRIP': 'YES',
},
},
},

'copies': [
{
'destination': '<(PRODUCT_DIR)/$(FRAMEWORKS_FOLDER_PATH)',
'files': [
'<(PRODUCT_DIR)/Mapbox.framework',
],
'xcode_code_sign': 1,
},
],
}
]
}
38 changes: 18 additions & 20 deletions ios/framework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.mapbox.sdk.ios</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>#####</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>%%%%%</string>
<key>NSPrincipalClass</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0</string>
</dict>
</plist>
26 changes: 26 additions & 0 deletions ios/framework/Mapbox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#import <Foundation/Foundation.h>

/// Project version number for Mapbox.
FOUNDATION_EXPORT double MapboxVersionNumber;

/// Project version string for Mapbox.
FOUNDATION_EXPORT const unsigned char MapboxVersionString[];

#import <Mapbox/MGLAccountManager.h>
#import <Mapbox/MGLAnnotation.h>
#import <Mapbox/MGLAnnotationImage.h>
#import <Mapbox/MGLCalloutView.h>
#import <Mapbox/MGLMapCamera.h>
#import <Mapbox/MGLGeometry.h>
#import <Mapbox/MGLMapView.h>
#import <Mapbox/MGLMapView+IBAdditions.h>
#import <Mapbox/MGLMapView+MGLCustomStyleLayerAdditions.h>
#import <Mapbox/MGLMultiPoint.h>
#import <Mapbox/MGLOverlay.h>
#import <Mapbox/MGLPointAnnotation.h>
#import <Mapbox/MGLPolygon.h>
#import <Mapbox/MGLPolyline.h>
#import <Mapbox/MGLShape.h>
#import <Mapbox/MGLStyle.h>
#import <Mapbox/MGLTypes.h>
#import <Mapbox/MGLUserLocation.h>
29 changes: 29 additions & 0 deletions ios/framework/Mapbox.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#import <Mapbox/Mapbox.h>

#import "../../platform/ios/src/NSBundle+MGLAdditions.h"
#import "../../platform/ios/src/NSProcessInfo+MGLAdditions.h"
#import "../../platform/darwin/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];
[MGLPointAnnotation class];
[MGLPolygon class];
[MGLPolyline class];
[MGLShape class];
[MGLStyle class];
[MGLUserLocation class];
}
Loading

0 comments on commit 9350d3f

Please sign in to comment.