[osx] Build framework based on static library
This commit is contained in:
committed by
Minh Nguyễn
parent
6890af9cd9
commit
df0511af18
1
Makefile
1
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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://travis-ci.org/mapbox/mapbox-gl-native/builds) [](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.**
|
||||
|
||||
|
||||
@@ -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`.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### 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`.
|
||||
@@ -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).
|
||||
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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 \'.*\')',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.1.0</string>
|
||||
<string>1</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
22
platform/osx/sdk/Info.plist
Normal file
22
platform/osx/sdk/Info.plist
Normal file
@@ -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>
|
||||
27
platform/osx/sdk/Mapbox.m
Normal file
27
platform/osx/sdk/Mapbox.m
Normal file
@@ -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];
|
||||
}
|
||||
@@ -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
|
||||
46
platform/osx/sdk/framework-osx.gypi
Normal file
46
platform/osx/sdk/framework-osx.gypi
Normal file
@@ -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',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -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) {
|
||||
@@ -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;
|
||||
@@ -8,8 +8,7 @@ void mgl_linkBundleCategory();
|
||||
|
||||
@interface NSBundle (MGLAdditions)
|
||||
|
||||
+ (instancetype)mgl_resourceBundle;
|
||||
+ (NSString *)mgl_resourceBundlePath;
|
||||
+ (instancetype)mgl_frameworkBundle;
|
||||
|
||||
@end
|
||||
|
||||
13
platform/osx/src/NSBundle+MGLAdditions.m
Normal file
13
platform/osx/src/NSBundle+MGLAdditions.m
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user