diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-12-01 22:37:43 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2015-12-13 17:26:53 -0800 |
commit | df0511af185c334c7480f06bbc21b974a2a320fb (patch) | |
tree | a868569cb9a4c9462a01404bab034be9790ecad8 | |
parent | 6890af9cd95fcecb5329f54b81965a5fc0cffe62 (diff) | |
download | qtlocation-mapboxgl-df0511af185c334c7480f06bbc21b974a2a320fb.tar.gz |
[osx] Build framework based on static library
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | docs/BUILD_OSX | 92 | ||||
-rw-r--r-- | docs/BUILD_OSX.md | 19 | ||||
-rw-r--r-- | docs/DEVELOP_OSX.md | 6 | ||||
-rw-r--r-- | gyp/osx.gyp | 1 | ||||
-rw-r--r-- | gyp/platform-osx.gypi | 50 | ||||
-rw-r--r-- | platform/osx/app/AppDelegate.m | 5 | ||||
-rw-r--r-- | platform/osx/app/Info.plist | 2 | ||||
-rw-r--r-- | platform/osx/app/mapboxgl-app.gypi | 13 | ||||
-rw-r--r-- | platform/osx/sdk/Info.plist | 22 | ||||
-rw-r--r-- | platform/osx/sdk/Mapbox.m | 27 | ||||
-rw-r--r-- | platform/osx/sdk/NSBundle+MGLAdditions.m | 22 | ||||
-rw-r--r-- | platform/osx/sdk/framework-osx.gypi | 46 | ||||
-rw-r--r-- | platform/osx/src/MGLAccountManager.m (renamed from platform/osx/sdk/MGLAccountManager.m) | 10 | ||||
-rw-r--r-- | platform/osx/src/MGLAccountManager_Private.h (renamed from platform/osx/sdk/MGLAccountManager_Private.h) | 0 | ||||
-rw-r--r-- | platform/osx/src/MGLAnnotationImage.m (renamed from platform/osx/sdk/MGLAnnotationImage.m) | 0 | ||||
-rw-r--r-- | platform/osx/src/MGLAttributionButton.h (renamed from platform/osx/sdk/MGLAttributionButton.h) | 0 | ||||
-rw-r--r-- | platform/osx/src/MGLAttributionButton.m (renamed from platform/osx/sdk/MGLAttributionButton.m) | 0 | ||||
-rw-r--r-- | platform/osx/src/MGLCompassCell.h (renamed from platform/osx/sdk/MGLCompassCell.h) | 0 | ||||
-rw-r--r-- | platform/osx/src/MGLCompassCell.m (renamed from platform/osx/sdk/MGLCompassCell.m) | 0 | ||||
-rw-r--r-- | platform/osx/src/MGLMapView+IBAdditions.m (renamed from platform/osx/sdk/MGLMapView+IBAdditions.m) | 0 | ||||
-rw-r--r-- | platform/osx/src/MGLMapView.mm (renamed from platform/osx/sdk/MGLMapView.mm) | 6 | ||||
-rw-r--r-- | platform/osx/src/MGLMapView_Private.h (renamed from platform/osx/sdk/MGLMapView_Private.h) | 0 | ||||
-rw-r--r-- | platform/osx/src/MGLOpenGLLayer.h (renamed from platform/osx/sdk/MGLOpenGLLayer.h) | 0 | ||||
-rw-r--r-- | platform/osx/src/MGLOpenGLLayer.mm (renamed from platform/osx/sdk/MGLOpenGLLayer.mm) | 0 | ||||
-rw-r--r-- | platform/osx/src/NSBundle+MGLAdditions.h (renamed from platform/osx/sdk/NSBundle+MGLAdditions.h) | 3 | ||||
-rw-r--r-- | platform/osx/src/NSBundle+MGLAdditions.m | 13 | ||||
-rw-r--r-- | platform/osx/src/NSProcessInfo+MGLAdditions.h (renamed from platform/osx/sdk/NSProcessInfo+MGLAdditions.h) | 0 | ||||
-rw-r--r-- | platform/osx/src/NSProcessInfo+MGLAdditions.m (renamed from platform/osx/sdk/NSProcessInfo+MGLAdditions.m) | 0 | ||||
-rw-r--r-- | platform/osx/src/resources/MGLAnnotationCallout.xib (renamed from platform/osx/sdk/resources/MGLAnnotationCallout.xib) | 0 | ||||
-rw-r--r-- | platform/osx/src/resources/default_marker.pdf (renamed from platform/osx/sdk/resources/default_marker.pdf) | bin | 2601 -> 2601 bytes | |||
-rw-r--r-- | platform/osx/src/resources/mapbox.pdf (renamed from platform/osx/sdk/resources/mapbox.pdf) | bin | 3762 -> 3762 bytes | |||
-rwxr-xr-x | scripts/osx/package.sh | 52 |
34 files changed, 174 insertions, 218 deletions
@@ -152,6 +152,7 @@ endif clean: clear_sqlite_cache clear_xcode_cache -find ./deps/gyp -name "*.pyc" -exec rm {} \; -rm -rf ./build/ + -rm -rf ./gyp/build/ -rm -rf ./macosx/build -rm -rf ./linux/build -rm -rf ./ios/build @@ -2,7 +2,7 @@ [![Travis](https://api.travis-ci.org/mapbox/mapbox-gl-native.svg?branch=master)](https://travis-ci.org/mapbox/mapbox-gl-native/builds) [![Bitrise](https://www.bitrise.io/app/7514e4cf3da2cc57.svg?token=OwqZE5rSBR9MVWNr_lf4sA&branch=master)](https://www.bitrise.io/app/7514e4cf3da2cc57) -An OpenGL-based renderer for [Mapbox Vector Tiles](https://www.mapbox.com/blog/vector-tiles), consisting of a C++ library for OS X and Linux and SDK bindings for iOS, Android and Node.js. +An OpenGL-based renderer for [Mapbox Vector Tiles](https://www.mapbox.com/blog/vector-tiles), consisting of a C++ library for Linux and SDK bindings for iOS, Android, Node.js, and OS X. **This repository is for development on Mapbox GL Native itself.** diff --git a/docs/BUILD_OSX b/docs/BUILD_OSX deleted file mode 100644 index 6a43025201..0000000000 --- a/docs/BUILD_OSX +++ /dev/null @@ -1,92 +0,0 @@ -# Building Mapbox GL Native for iOS - -This section is for people contributing to Mapbox GL directly in the context of their own app. - -### Build - -1. Install [appledoc](http://appledoc.gentlebytes.com/appledoc/) for API docs generation. - - ``` - curl -L -o appledoc.zip https://github.com/tomaz/appledoc/releases/download/v2.2-963/appledoc.zip - unzip appledoc.zip - cp appledoc /usr/local/bin - cp -Rf Templates/ ~/.appledoc - ``` - -1. Run `make ipackage`. The packaging script will produce the statically-linked `libMapbox.a`, `Mapbox.bundle` for resources, a `Headers` folder, and a `Docs` folder with HTML API documentation. - -### Access Tokens - -_The demo applications use Mapbox vector tiles, which require a Mapbox account and API access token. Obtain an access token on the [Mapbox account page](https://www.mapbox.com/account/apps/)._ - -Set up the access token by editing the scheme for the application target, then adding an environment variable with the name `MAPBOX_ACCESS_TOKEN`. - -![edit scheme](https://cloud.githubusercontent.com/assets/98601/5460702/c4610262-8519-11e4-873a-8597821da468.png) - -![setting access token in Xcode scheme](https://cloud.githubusercontent.com/assets/162976/5349358/0a086f00-7f8c-11e4-8433-bdbaccda2b58.png) - -### Test - -In the context of your own app, you can now either: - -#### CocoaPods - -Currently, until [#1437](https://github.com/mapbox/mapbox-gl-native/issues/1437) is completed, to install a _development version_ of Mapbox GL using CocoaPods you will need to build it from source manually per above. - -1. Zip up the build product. - - ``` - cd build/ios/pkg/static - ZIP=mapbox-ios-sdk.zip - rm -f ../${ZIP} - zip -r ../${ZIP} * - ``` - -1. Modify a custom `Mapbox-iOS-SDK.podspec` to download this zip file. - - ```rb - {...} - - m.source = { - :http => "http://{...}/mapbox-ios-sdk.zip", - :flatten => true - } - - {...} - ``` - -1. Update your app's `Podfile` to point to the `Mapbox-iOS-SDK.podspec`. - - ```rb - pod 'Mapbox-iOS-SDK', :podspec => 'http://{...}/Mapbox-iOS-SDK.podspec' - ``` - -1. Run `pod update` to grab the newly-built library. - -#### Binary - -1. Built from source manually per above. - -1. Copy the contents of `build/ios/pkg/static` into your project. It should happen automatically, but ensure that: - - - `Headers` is in your *Header Search Paths* (`HEADER_SEARCH_PATHS`) build setting. - - `Mapbox.bundle` is in your target's *Copy Bundle Resources* build phase. - - `libMapbox.a` is in your target's *Link Binary With Libraries* build phase. - -1. Add the following Cocoa framework dependencies to your target's *Link Binary With Libraries* build phase: - - - `GLKit.framework` - - `ImageIO.framework` - - `MobileCoreServices.framework` - - `QuartzCore.framework` - - `SystemConfiguration.framework` - - `libc++.dylib` - - `libsqlite3.dylib` - - `libz.dylib` - - `CoreTelephony.framework` (optional, telemetry-only) - -1. Add `-ObjC` to your target's "Other Linker Flags" build setting (`OTHER_LDFLAGS`). - -## Troubleshooting - -On OS X, you can also try clearing the Xcode cache with `make clear_xcode_cache`. diff --git a/docs/BUILD_OSX.md b/docs/BUILD_OSX.md index 5b4f6e6327..a2e936d59b 100644 --- a/docs/BUILD_OSX.md +++ b/docs/BUILD_OSX.md @@ -4,26 +4,13 @@ This project provides an OS X SDK analogous to the Mapbox iOS SDK. Mapbox does n ### Build -1. Run `make xpackage`. The packaging script will produce the statically-linked `libMapbox.a`, `Mapbox.bundle` for resources, and a `Headers` folder. +1. Run `make xpackage`, which produces a `Mapbox.framework` in the `gyp/build/Release/` folder. ### Install -1. Copy the contents of `build/osx/pkg/static` into your project. It should happen automatically, but ensure that: +1. Copy `gyp/build/Release/Mapbox.framework` into your project. It should happen automatically, but ensure that `Mapbox.framework` is listed in the *Linked Frameworks and Libraries* section of the General tab for your application target. - - `Headers` is in your *Header Search Paths* (`HEADER_SEARCH_PATHS`) build setting. - - `Mapbox.bundle` is in your target's *Copy Bundle Resources* build phase. - - `libMapbox.a` is in your target's *Link Binary With Libraries* build phase. - -1. Add the following Cocoa framework dependencies to your target's *Link Binary With Libraries* build phase: - - - `SystemConfiguration.framework` - - `libc++.tbd` - - `libsqlite3.tbd` - - `libz.tbd` - -1. Add `-ObjC` to your target's "Other Linker Flags" build setting (`OTHER_LDFLAGS`). - -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/account/apps/). +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/). 1. In a XIB or storyboard, add a Custom View and set its custom class to `MGLMapView`. If you need to manipulate the map view programmatically, import the `Mapbox` module (Swift) or `Mapbox.h` umbrella header (Objective-C). diff --git a/docs/DEVELOP_OSX.md b/docs/DEVELOP_OSX.md index 3ca96ebf24..4b30a1e94a 100644 --- a/docs/DEVELOP_OSX.md +++ b/docs/DEVELOP_OSX.md @@ -6,12 +6,14 @@ To create projects, you can run: - `make lproj`: Creates an Xcode project with platform-independent handlers for downloads and settings storage. This is what is also being built on Linux. - `make osx run-osx`: Builds and runs the OS X application on the command line with `xcodebuild`. -Note that you can't have more than one project in Xcode open at a time because the static library project is shared across the OS X, Linux and iOS project. +Note that you can't have more than one project in Xcode open at a time because the static library project is shared across the OS X, Linux, and iOS projects. -### Access Tokens +### Access tokens The demo applications use Mapbox vector tiles, which require a Mapbox account and API access token. Obtain an access token on the [Mapbox account page](https://www.mapbox.com/studio/account/tokens/). You will be prompted for this access token the first time you launch the demo application. ### Usage Through the OS X SDK, the demo application supports a variety of standard gestures and keyboard shortcuts. For more details, open Mapbox GL Help from the Help menu. + +You can also [integrate the Mapbox OS X SDK into your own Cocoa application](BUILD_OSX.md). diff --git a/gyp/osx.gyp b/gyp/osx.gyp index 2df9d4818d..86f4b44dfa 100644 --- a/gyp/osx.gyp +++ b/gyp/osx.gyp @@ -1,6 +1,7 @@ { 'includes': [ '../platform/osx/app/mapboxgl-app.gypi', + '../platform/osx/sdk/framework-osx.gypi', '../platform/linux/mapboxgl-app.gypi', '../test/test.gypi', '../bin/render.gypi', diff --git a/gyp/platform-osx.gypi b/gyp/platform-osx.gypi index 1462d6e364..66eef43277 100644 --- a/gyp/platform-osx.gypi +++ b/gyp/platform-osx.gypi @@ -45,27 +45,26 @@ '../platform/darwin/MGLPolygon.mm', '../include/mbgl/osx/Mapbox.h', '../include/mbgl/osx/MGLAccountManager.h', - '../platform/osx/sdk/MGLAccountManager_Private.h', - '../platform/osx/sdk/MGLAccountManager.m', + '../platform/osx/src/MGLAccountManager_Private.h', + '../platform/osx/src/MGLAccountManager.m', '../include/mbgl/osx/MGLMapView.h', - '../platform/osx/sdk/MGLMapView_Private.h', - '../platform/osx/sdk/MGLMapView.mm', + '../platform/osx/src/MGLMapView_Private.h', + '../platform/osx/src/MGLMapView.mm', '../include/mbgl/osx/MGLMapView+IBAdditions.h', - '../platform/osx/sdk/MGLMapView+IBAdditions.m', + '../platform/osx/src/MGLMapView+IBAdditions.m', '../include/mbgl/osx/MGLMapViewDelegate.h', - '../platform/osx/sdk/MGLOpenGLLayer.h', - '../platform/osx/sdk/MGLOpenGLLayer.mm', - '../platform/osx/sdk/MGLCompassCell.h', - '../platform/osx/sdk/MGLCompassCell.m', - '../platform/osx/sdk/MGLAttributionButton.h', - '../platform/osx/sdk/MGLAttributionButton.m', + '../platform/osx/src/MGLOpenGLLayer.h', + '../platform/osx/src/MGLOpenGLLayer.mm', + '../platform/osx/src/MGLCompassCell.h', + '../platform/osx/src/MGLCompassCell.m', + '../platform/osx/src/MGLAttributionButton.h', + '../platform/osx/src/MGLAttributionButton.m', '../include/mbgl/osx/MGLAnnotationImage.h', - '../platform/osx/sdk/MGLAnnotationImage.m', - '../platform/osx/sdk/NSBundle+MGLAdditions.h', - '../platform/osx/sdk/NSBundle+MGLAdditions.m', - '../platform/osx/sdk/NSProcessInfo+MGLAdditions.h', - '../platform/osx/sdk/NSProcessInfo+MGLAdditions.m', - '../platform/osx/sdk/resources/', + '../platform/osx/src/MGLAnnotationImage.m', + '../platform/osx/src/NSBundle+MGLAdditions.h', + '../platform/osx/src/NSBundle+MGLAdditions.m', + '../platform/osx/src/NSProcessInfo+MGLAdditions.h', + '../platform/osx/src/NSProcessInfo+MGLAdditions.m', ], 'variables': { @@ -76,13 +75,11 @@ ], 'libraries': [ '<@(libuv_static_libs)', - ], - 'ldflags': [ - '-framework Cocoa', - '-framework CoreLocation', - '-framework OpenGL', - '-framework QuartzCore', - '-framework SystemConfiguration', + '$(SDKROOT)/System/Library/Frameworks/Cocoa.framework', + '$(SDKROOT)/System/Library/Frameworks/CoreLocation.framework', + '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework', + '$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework', + '$(SDKROOT)/System/Library/Frameworks/SystemConfiguration.framework', ], }, @@ -101,9 +98,6 @@ 'link_settings': { 'libraries': [ '<@(libraries)' ], - 'xcode_settings': { - 'OTHER_LDFLAGS': [ '<@(ldflags)' ], - }, }, 'direct_dependent_settings': { @@ -113,7 +107,7 @@ '../include', ], 'mac_bundle_resources': [ - '<!@(find ../platform/osx/sdk/resources -type f \! -name "README")', + '<!@(find ../platform/osx/src/resources -type f \! -name \'.*\')', ], }, }, diff --git a/platform/osx/app/AppDelegate.m b/platform/osx/app/AppDelegate.m index dd4562090c..1bea883eb2 100644 --- a/platform/osx/app/AppDelegate.m +++ b/platform/osx/app/AppDelegate.m @@ -4,7 +4,7 @@ #import "LocationCoordinate2DTransformer.h" #import "NSValue+Additions.h" -#import <mbgl/osx/Mapbox.h> +#import <Mapbox/Mapbox.h> static NSString * const MGLMapboxAccessTokenDefaultsKey = @"MGLMapboxAccessToken"; static NSString * const MGLDroppedPinAnnotationImageIdentifier = @"dropped"; @@ -526,7 +526,8 @@ static NSString * const MGLDroppedPinAnnotationImageIdentifier = @"dropped"; - (MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id <MGLAnnotation>)annotation { MGLAnnotationImage *annotationImage = [self.mapView dequeueReusableAnnotationImageWithIdentifier:MGLDroppedPinAnnotationImageIdentifier]; if (!annotationImage) { - NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"default_marker" ofType:@"pdf"]; + NSString *imagePath = [[NSBundle bundleForClass:[MGLMapView class]] + pathForResource:@"default_marker" ofType:@"pdf"]; NSImage *image = [[NSImage alloc] initWithContentsOfFile:imagePath]; NSRect alignmentRect = image.alignmentRect; alignmentRect.origin.y = NSMidY(alignmentRect); diff --git a/platform/osx/app/Info.plist b/platform/osx/app/Info.plist index 0d178d4b9e..118f2c1b11 100644 --- a/platform/osx/app/Info.plist +++ b/platform/osx/app/Info.plist @@ -36,7 +36,7 @@ </dict> </array> <key>CFBundleVersion</key> - <string>0.1.0</string> + <string>1</string> <key>CSResourcesFileMapped</key> <true/> <key>NSHighResolutionCapable</key> diff --git a/platform/osx/app/mapboxgl-app.gypi b/platform/osx/app/mapboxgl-app.gypi index 8ab0320d31..99a5f3d099 100644 --- a/platform/osx/app/mapboxgl-app.gypi +++ b/platform/osx/app/mapboxgl-app.gypi @@ -3,7 +3,8 @@ '../../../gyp/common.gypi', ], 'targets': [ - { 'target_name': 'osxapp', + { + 'target_name': 'osxapp', 'product_name': 'Mapbox GL', 'type': 'executable', 'product_extension': 'app', @@ -15,11 +16,7 @@ ], 'dependencies': [ - 'mbgl.gyp:core', - 'mbgl.gyp:platform-<(platform_lib)', - 'mbgl.gyp:http-<(http_lib)', - 'mbgl.gyp:asset-<(asset_lib)', - 'mbgl.gyp:cache-<(cache_lib)', + 'osxsdk', ], 'sources': [ @@ -39,10 +36,10 @@ 'xcode_settings': { 'SDKROOT': 'macosx', 'SUPPORTED_PLATFORMS':'macosx', - 'OTHER_LDFLAGS': [ '-stdlib=libc++', '-lstdc++' ], 'INFOPLIST_FILE': '../platform/osx/app/Info.plist', 'CLANG_ENABLE_OBJC_ARC': 'YES', + 'PRODUCT_BUNDLE_IDENTIFIER': 'com.mapbox.MapboxGL', }, - } + }, ] } diff --git a/platform/osx/sdk/Info.plist b/platform/osx/sdk/Info.plist new file mode 100644 index 0000000000..aeebbb5072 --- /dev/null +++ b/platform/osx/sdk/Info.plist @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <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.0.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>0.0.0</string> +</dict> +</plist> diff --git a/platform/osx/sdk/Mapbox.m b/platform/osx/sdk/Mapbox.m new file mode 100644 index 0000000000..08d12579fe --- /dev/null +++ b/platform/osx/sdk/Mapbox.m @@ -0,0 +1,27 @@ +#import <mbgl/osx/Mapbox.h> + +#import "../src/NSBundle+MGLAdditions.h" +#import "../src/NSProcessInfo+MGLAdditions.h" +#import "../../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]; + [MGLMapView class]; + [MGLMultiPoint class]; + [MGLPointAnnotation class]; + [MGLPolygon class]; + [MGLPolyline class]; + [MGLShape class]; + [MGLStyle class]; +} diff --git a/platform/osx/sdk/NSBundle+MGLAdditions.m b/platform/osx/sdk/NSBundle+MGLAdditions.m deleted file mode 100644 index a53802c343..0000000000 --- a/platform/osx/sdk/NSBundle+MGLAdditions.m +++ /dev/null @@ -1,22 +0,0 @@ -#import "NSBundle+MGLAdditions.h" - -#import "MGLAccountManager.h" - -void mgl_linkBundleCategory() {} - -@implementation NSBundle (MGLAdditions) - -+ (instancetype)mgl_resourceBundle { - return [self bundleWithPath:[self mgl_resourceBundlePath]]; -} - -+ (NSString *)mgl_resourceBundlePath { - NSString *resourceBundlePath = [[self bundleForClass:[MGLAccountManager class]] - pathForResource:@"Mapbox" ofType:@"bundle"]; - if (!resourceBundlePath) { - resourceBundlePath = [[self mainBundle] bundlePath]; - } - return resourceBundlePath; -} - -@end diff --git a/platform/osx/sdk/framework-osx.gypi b/platform/osx/sdk/framework-osx.gypi new file mode 100644 index 0000000000..0c7c89d3ec --- /dev/null +++ b/platform/osx/sdk/framework-osx.gypi @@ -0,0 +1,46 @@ +{ + 'includes': [ + '../../../gyp/common.gypi', + ], + 'targets': [ + { + 'target_name': 'osxsdk', + 'product_name': 'Mapbox', + 'type': 'shared_library', + 'mac_bundle': 1, + + 'dependencies': [ + 'mbgl.gyp:core', + 'mbgl.gyp:platform-<(platform_lib)', + 'mbgl.gyp:http-<(http_lib)', + 'mbgl.gyp:asset-<(asset_lib)', + 'mbgl.gyp:cache-<(cache_lib)', + ], + + 'xcode_settings': { + 'SDKROOT': 'macosx', + 'SUPPORTED_PLATFORMS':'macosx', + 'OTHER_LDFLAGS': [ '-stdlib=libc++', '-lstdc++' ], + 'INSTALL_PATH': '@executable_path/../Frameworks', + 'INFOPLIST_FILE': '../platform/osx/sdk/Info.plist', + 'CLANG_ENABLE_OBJC_ARC': 'YES', + 'PRODUCT_BUNDLE_IDENTIFIER': 'com.mapbox.MapboxGL', + }, + + 'mac_framework_headers': [ + '<!@(find ../include/mbgl/{darwin,osx} -type f \! -name \'.*\')', + ], + + 'sources': [ + './Mapbox.m', + ], + + 'direct_dependent_settings': { + 'libraries': [ + '$(SDKROOT)/System/Library/Frameworks/Cocoa.framework', + '$(SDKROOT)/System/Library/Frameworks/CoreLocation.framework', + ], + }, + }, + ] +} diff --git a/platform/osx/sdk/MGLAccountManager.m b/platform/osx/src/MGLAccountManager.m index d6bc82defe..14969c101b 100644 --- a/platform/osx/sdk/MGLAccountManager.m +++ b/platform/osx/src/MGLAccountManager.m @@ -2,10 +2,6 @@ #import <mbgl/osx/MGLMapView.h> -#import "NSBundle+MGLAdditions.h" -#import "NSProcessInfo+MGLAdditions.h" -#import "../../darwin/NSString+MGLAdditions.h" - @interface MGLAccountManager () @property (atomic) NSString *accessToken; @@ -17,12 +13,6 @@ #pragma mark - Internal + (void)load { - mgl_linkBundleCategory(); - mgl_linkStringCategory(); - mgl_linkProcessInfoCategory(); - - [MGLMapView restorableStateKeyPaths]; - // Read the initial configuration from Info.plist. NSString *accessToken = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLMapboxAccessToken"]; if (accessToken.length) { diff --git a/platform/osx/sdk/MGLAccountManager_Private.h b/platform/osx/src/MGLAccountManager_Private.h index c0b8d2666a..c0b8d2666a 100644 --- a/platform/osx/sdk/MGLAccountManager_Private.h +++ b/platform/osx/src/MGLAccountManager_Private.h diff --git a/platform/osx/sdk/MGLAnnotationImage.m b/platform/osx/src/MGLAnnotationImage.m index 855105fded..855105fded 100644 --- a/platform/osx/sdk/MGLAnnotationImage.m +++ b/platform/osx/src/MGLAnnotationImage.m diff --git a/platform/osx/sdk/MGLAttributionButton.h b/platform/osx/src/MGLAttributionButton.h index 7bc0fa5357..7bc0fa5357 100644 --- a/platform/osx/sdk/MGLAttributionButton.h +++ b/platform/osx/src/MGLAttributionButton.h diff --git a/platform/osx/sdk/MGLAttributionButton.m b/platform/osx/src/MGLAttributionButton.m index 642f71f608..642f71f608 100644 --- a/platform/osx/sdk/MGLAttributionButton.m +++ b/platform/osx/src/MGLAttributionButton.m diff --git a/platform/osx/sdk/MGLCompassCell.h b/platform/osx/src/MGLCompassCell.h index 8c89b43e18..8c89b43e18 100644 --- a/platform/osx/sdk/MGLCompassCell.h +++ b/platform/osx/src/MGLCompassCell.h diff --git a/platform/osx/sdk/MGLCompassCell.m b/platform/osx/src/MGLCompassCell.m index 88911de2ff..88911de2ff 100644 --- a/platform/osx/sdk/MGLCompassCell.m +++ b/platform/osx/src/MGLCompassCell.m diff --git a/platform/osx/sdk/MGLMapView+IBAdditions.m b/platform/osx/src/MGLMapView+IBAdditions.m index 504bc789de..504bc789de 100644 --- a/platform/osx/sdk/MGLMapView+IBAdditions.m +++ b/platform/osx/src/MGLMapView+IBAdditions.m diff --git a/platform/osx/sdk/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index 350b59e208..a1cfe3c33d 100644 --- a/platform/osx/sdk/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -66,7 +66,7 @@ typedef std::map<MGLAnnotationID, MGLAnnotationContext> MGLAnnotationContextMap; /// Returns an NSImage for the default marker image. NSImage *MGLDefaultMarkerImage() { - NSString *path = [[NSBundle mgl_resourceBundle] pathForResource:MGLDefaultStyleMarkerSymbolName + NSString *path = [[NSBundle mgl_frameworkBundle] pathForResource:MGLDefaultStyleMarkerSymbolName ofType:@"pdf"]; return [[NSImage alloc] initWithContentsOfFile:path]; } @@ -266,7 +266,7 @@ public: _logoView = [[NSImageView alloc] initWithFrame:NSZeroRect]; _logoView.wantsLayer = YES; NSImage *logoImage = [[NSImage alloc] initWithContentsOfFile: - [[NSBundle mgl_resourceBundle] pathForResource:@"mapbox" ofType:@"pdf"]]; + [[NSBundle mgl_frameworkBundle] pathForResource:@"mapbox" ofType:@"pdf"]]; logoImage.alignmentRect = NSInsetRect(logoImage.alignmentRect, 3, 3); _logoView.image = logoImage; _logoView.translatesAutoresizingMaskIntoConstraints = NO; @@ -1396,7 +1396,7 @@ public: } if (!viewController) { viewController = [[NSViewController alloc] initWithNibName:@"MGLAnnotationCallout" - bundle:[NSBundle mgl_resourceBundle]]; + bundle:[NSBundle mgl_frameworkBundle]]; } NSAssert(viewController, @"Unable to load MGLAnnotationCallout view controller"); viewController.representedObject = annotation; diff --git a/platform/osx/sdk/MGLMapView_Private.h b/platform/osx/src/MGLMapView_Private.h index 3b37ce24b4..3b37ce24b4 100644 --- a/platform/osx/sdk/MGLMapView_Private.h +++ b/platform/osx/src/MGLMapView_Private.h diff --git a/platform/osx/sdk/MGLOpenGLLayer.h b/platform/osx/src/MGLOpenGLLayer.h index 9429b01bb5..9429b01bb5 100644 --- a/platform/osx/sdk/MGLOpenGLLayer.h +++ b/platform/osx/src/MGLOpenGLLayer.h diff --git a/platform/osx/sdk/MGLOpenGLLayer.mm b/platform/osx/src/MGLOpenGLLayer.mm index 06a7be961c..06a7be961c 100644 --- a/platform/osx/sdk/MGLOpenGLLayer.mm +++ b/platform/osx/src/MGLOpenGLLayer.mm diff --git a/platform/osx/sdk/NSBundle+MGLAdditions.h b/platform/osx/src/NSBundle+MGLAdditions.h index c09ba38a5d..6d6ebc35ad 100644 --- a/platform/osx/sdk/NSBundle+MGLAdditions.h +++ b/platform/osx/src/NSBundle+MGLAdditions.h @@ -8,8 +8,7 @@ void mgl_linkBundleCategory(); @interface NSBundle (MGLAdditions) -+ (instancetype)mgl_resourceBundle; -+ (NSString *)mgl_resourceBundlePath; ++ (instancetype)mgl_frameworkBundle; @end diff --git a/platform/osx/src/NSBundle+MGLAdditions.m b/platform/osx/src/NSBundle+MGLAdditions.m new file mode 100644 index 0000000000..658d515ebf --- /dev/null +++ b/platform/osx/src/NSBundle+MGLAdditions.m @@ -0,0 +1,13 @@ +#import "NSBundle+MGLAdditions.h" + +#import "MGLAccountManager.h" + +void mgl_linkBundleCategory() {} + +@implementation NSBundle (MGLAdditions) + ++ (instancetype)mgl_frameworkBundle { + return [self bundleForClass:[MGLAccountManager class]]; +} + +@end diff --git a/platform/osx/sdk/NSProcessInfo+MGLAdditions.h b/platform/osx/src/NSProcessInfo+MGLAdditions.h index 6b34f54756..6b34f54756 100644 --- a/platform/osx/sdk/NSProcessInfo+MGLAdditions.h +++ b/platform/osx/src/NSProcessInfo+MGLAdditions.h diff --git a/platform/osx/sdk/NSProcessInfo+MGLAdditions.m b/platform/osx/src/NSProcessInfo+MGLAdditions.m index 16f869703c..16f869703c 100644 --- a/platform/osx/sdk/NSProcessInfo+MGLAdditions.m +++ b/platform/osx/src/NSProcessInfo+MGLAdditions.m diff --git a/platform/osx/sdk/resources/MGLAnnotationCallout.xib b/platform/osx/src/resources/MGLAnnotationCallout.xib index edf84a26a7..edf84a26a7 100644 --- a/platform/osx/sdk/resources/MGLAnnotationCallout.xib +++ b/platform/osx/src/resources/MGLAnnotationCallout.xib diff --git a/platform/osx/sdk/resources/default_marker.pdf b/platform/osx/src/resources/default_marker.pdf Binary files differindex 4e2e332301..4e2e332301 100644 --- a/platform/osx/sdk/resources/default_marker.pdf +++ b/platform/osx/src/resources/default_marker.pdf diff --git a/platform/osx/sdk/resources/mapbox.pdf b/platform/osx/src/resources/mapbox.pdf Binary files differindex c08a0e3135..c08a0e3135 100644 --- a/platform/osx/sdk/resources/mapbox.pdf +++ b/platform/osx/src/resources/mapbox.pdf diff --git a/scripts/osx/package.sh b/scripts/osx/package.sh index eef9fcd919..79ab3f1377 100755 --- a/scripts/osx/package.sh +++ b/scripts/osx/package.sh @@ -9,10 +9,10 @@ OUTPUT=build/osx/pkg OSX_SDK_VERSION=`xcrun --sdk macosx --show-sdk-version` LIBUV_VERSION=1.7.5 -if [[ ${#} -eq 0 ]]; then # e.g. "make ipackage" +if [[ ${#} -eq 0 ]]; then # e.g. "make xpackage" BUILDTYPE="Release" GCC_GENERATE_DEBUGGING_SYMBOLS="YES" -else # e.g. "make ipackage-strip" +else # e.g. "make xpackage-strip" BUILDTYPE="Release" GCC_GENERATE_DEBUGGING_SYMBOLS="NO" fi @@ -23,11 +23,11 @@ trap finish EXIT rm -rf ${OUTPUT} -mkdir -p "${OUTPUT}"/static +mkdir -p "${OUTPUT}"/shared step "Recording library version..." -VERSION="${OUTPUT}"/static/version.txt +VERSION="${OUTPUT}"/shared/version.txt echo -n "https://github.com/mapbox/mapbox-gl-native/commit/" > ${VERSION} HASH=`git log | head -1 | awk '{ print $2 }' | cut -c 1-10` && true echo -n "mapbox-gl-native " @@ -46,33 +46,23 @@ xcodebuild -sdk macosx${OSX_SDK_VERSION} \ ARCHS="x86_64" \ ONLY_ACTIVE_ARCH=NO \ GCC_GENERATE_DEBUGGING_SYMBOLS=${GCC_GENERATE_DEBUGGING_SYMBOLS} \ - -project ./build/osx-x86_64/gyp/mbgl.xcodeproj \ + -project ./build/osx-x86_64/gyp/osx.xcodeproj \ -configuration ${BUILDTYPE} \ - -target everything \ + -target osxsdk \ -jobs ${JOBS} - -step "Building static library..." -LIBS=(core.a platform-osx.a asset-fs.a cache-sqlite.a http-nsurl.a) -libtool -static -no_warning_for_no_symbols \ - `find mason_packages/osx-${OSX_SDK_VERSION} -type f -name libuv.a` \ - `find mason_packages/osx-${OSX_SDK_VERSION} -type f -name libgeojsonvt.a` \ - -o ${OUTPUT}/static/lib${NAME}.a \ - ${LIBS[@]/#/gyp/build/${BUILDTYPE}/libmbgl-} -echo "Created ${OUTPUT}/static/lib${NAME}.a" - - -step "Copying Headers..." -mkdir -p "${OUTPUT}/static/Headers" -for i in `ls -R include/mbgl/darwin | grep -vi private`; do - cp -pv include/mbgl/darwin/$i "${OUTPUT}/static/Headers" -done -for i in `ls -R include/mbgl/osx | grep -vi private`; do - cp -pv include/mbgl/osx/$i "${OUTPUT}/static/Headers" -done - -step "Copying Resources..." -cp -pv LICENSE.md "${OUTPUT}/static" -mkdir -p "${OUTPUT}/static/${NAME}.bundle" -cp -pv platform/osx/resources/* "${OUTPUT}/static/${NAME}.bundle" - +TARGET_BUILD_DIR=gyp/build/${BUILDTYPE} +INFOPLIST_PATH=Mapbox.framework/Versions/Current/Resources/Info.plist + +# Uncomment when we're ready to release an official version. +#VERSION=$( git tag | grep ^osx | sed 's/^osx-//' | sort -r | grep -v '\-rc.' | grep -v '\-pre.' | sed -n '1p' | sed 's/^v//' ) +#if [ "$VERSION" ]; then +# plutil \ +# -replace CFBundleShortVersionString -string ${VERSION} \ +# $TARGET_BUILD_DIR/$INFOPLIST_PATH +# plutil \ +# -replace CFBundleVersion -string ${VERSION} \ +# $TARGET_BUILD_DIR/$INFOPLIST_PATH +#fi + +echo $TARGET_BUILD_DIR/Mapbox.framework |