diff --git a/Makefile b/Makefile index 5a3c57476..0a6443541 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 1cd576cf1..b9104e4d3 100644 --- a/README.md +++ b/README.md @@ -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 6a4302520..000000000 --- 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 5b4f6e632..a2e936d59 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 3ca96ebf2..4b30a1e94 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 2df9d4818..86f4b44df 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 1462d6e36..66eef4327 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': [ - ' +#import 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 )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 0d178d4b9..118f2c1b1 100644 --- a/platform/osx/app/Info.plist +++ b/platform/osx/app/Info.plist @@ -36,7 +36,7 @@ CFBundleVersion - 0.1.0 + 1 CSResourcesFileMapped NSHighResolutionCapable diff --git a/platform/osx/app/mapboxgl-app.gypi b/platform/osx/app/mapboxgl-app.gypi index 8ab0320d3..99a5f3d09 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 000000000..aeebbb507 --- /dev/null +++ b/platform/osx/sdk/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 0.0.0 + CFBundleSignature + ???? + CFBundleVersion + 0.0.0 + + diff --git a/platform/osx/sdk/Mapbox.m b/platform/osx/sdk/Mapbox.m new file mode 100644 index 000000000..08d12579f --- /dev/null +++ b/platform/osx/sdk/Mapbox.m @@ -0,0 +1,27 @@ +#import + +#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 a53802c34..000000000 --- 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 000000000..0c7c89d3e --- /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': [ + ' -#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 similarity index 100% rename from platform/osx/sdk/MGLAccountManager_Private.h rename to platform/osx/src/MGLAccountManager_Private.h diff --git a/platform/osx/sdk/MGLAnnotationImage.m b/platform/osx/src/MGLAnnotationImage.m similarity index 100% rename from platform/osx/sdk/MGLAnnotationImage.m rename to platform/osx/src/MGLAnnotationImage.m diff --git a/platform/osx/sdk/MGLAttributionButton.h b/platform/osx/src/MGLAttributionButton.h similarity index 100% rename from platform/osx/sdk/MGLAttributionButton.h rename to platform/osx/src/MGLAttributionButton.h diff --git a/platform/osx/sdk/MGLAttributionButton.m b/platform/osx/src/MGLAttributionButton.m similarity index 100% rename from platform/osx/sdk/MGLAttributionButton.m rename to platform/osx/src/MGLAttributionButton.m diff --git a/platform/osx/sdk/MGLCompassCell.h b/platform/osx/src/MGLCompassCell.h similarity index 100% rename from platform/osx/sdk/MGLCompassCell.h rename to platform/osx/src/MGLCompassCell.h diff --git a/platform/osx/sdk/MGLCompassCell.m b/platform/osx/src/MGLCompassCell.m similarity index 100% rename from platform/osx/sdk/MGLCompassCell.m rename to platform/osx/src/MGLCompassCell.m diff --git a/platform/osx/sdk/MGLMapView+IBAdditions.m b/platform/osx/src/MGLMapView+IBAdditions.m similarity index 100% rename from platform/osx/sdk/MGLMapView+IBAdditions.m rename to platform/osx/src/MGLMapView+IBAdditions.m diff --git a/platform/osx/sdk/MGLMapView.mm b/platform/osx/src/MGLMapView.mm similarity index 99% rename from platform/osx/sdk/MGLMapView.mm rename to platform/osx/src/MGLMapView.mm index 350b59e20..a1cfe3c33 100644 --- a/platform/osx/sdk/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -66,7 +66,7 @@ typedef std::map 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 similarity index 100% rename from platform/osx/sdk/MGLMapView_Private.h rename to platform/osx/src/MGLMapView_Private.h diff --git a/platform/osx/sdk/MGLOpenGLLayer.h b/platform/osx/src/MGLOpenGLLayer.h similarity index 100% rename from platform/osx/sdk/MGLOpenGLLayer.h rename to platform/osx/src/MGLOpenGLLayer.h diff --git a/platform/osx/sdk/MGLOpenGLLayer.mm b/platform/osx/src/MGLOpenGLLayer.mm similarity index 100% rename from platform/osx/sdk/MGLOpenGLLayer.mm rename to platform/osx/src/MGLOpenGLLayer.mm diff --git a/platform/osx/sdk/NSBundle+MGLAdditions.h b/platform/osx/src/NSBundle+MGLAdditions.h similarity index 70% rename from platform/osx/sdk/NSBundle+MGLAdditions.h rename to platform/osx/src/NSBundle+MGLAdditions.h index c09ba38a5..6d6ebc35a 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 000000000..658d515eb --- /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 similarity index 100% rename from platform/osx/sdk/NSProcessInfo+MGLAdditions.h rename to platform/osx/src/NSProcessInfo+MGLAdditions.h diff --git a/platform/osx/sdk/NSProcessInfo+MGLAdditions.m b/platform/osx/src/NSProcessInfo+MGLAdditions.m similarity index 100% rename from platform/osx/sdk/NSProcessInfo+MGLAdditions.m rename to platform/osx/src/NSProcessInfo+MGLAdditions.m diff --git a/platform/osx/sdk/resources/MGLAnnotationCallout.xib b/platform/osx/src/resources/MGLAnnotationCallout.xib similarity index 100% rename from platform/osx/sdk/resources/MGLAnnotationCallout.xib rename to platform/osx/src/resources/MGLAnnotationCallout.xib diff --git a/platform/osx/sdk/resources/default_marker.pdf b/platform/osx/src/resources/default_marker.pdf similarity index 100% rename from platform/osx/sdk/resources/default_marker.pdf rename to platform/osx/src/resources/default_marker.pdf diff --git a/platform/osx/sdk/resources/mapbox.pdf b/platform/osx/src/resources/mapbox.pdf similarity index 100% rename from platform/osx/sdk/resources/mapbox.pdf rename to platform/osx/src/resources/mapbox.pdf diff --git a/scripts/osx/package.sh b/scripts/osx/package.sh index eef9fcd91..79ab3f137 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} +TARGET_BUILD_DIR=gyp/build/${BUILDTYPE} +INFOPLIST_PATH=Mapbox.framework/Versions/Current/Resources/Info.plist -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" +# 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