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

OS X SDK and revamped OS X demo application #3135

Merged
merged 25 commits into from
Dec 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0cab780
[osx] Rewrote platform-osx and osxapp
1ec5 Nov 23, 2015
cc35f5a
[osx, ios] Improved annotation interaction
1ec5 Dec 1, 2015
96145ef
[osx] Drop Pin context menu item
1ec5 Dec 1, 2015
f542d7b
[osx] Annotation tooltips
1ec5 Dec 1, 2015
004d040
[osx] Annotation cursors
1ec5 Dec 1, 2015
9d2e0a1
[osx] Blanket the map with pins
1ec5 Dec 1, 2015
6890af9
[osx] Fixed KVO compliance for selectedAnnotation
1ec5 Dec 2, 2015
df0511a
[osx] Build framework based on static library
1ec5 Dec 2, 2015
1598330
[osx] Added inline comments to MGLMapView
1ec5 Dec 2, 2015
47fb5e8
[osx] Moved Mapbox.{h,m} into framework proper; set version variables
1ec5 Dec 2, 2015
7f04c5d
[osx] Renamed annotation IDs to annotation tags
1ec5 Dec 2, 2015
62e6c04
[osx] Align build settings with Xcode framework project template
1ec5 Dec 2, 2015
73324ae
[osx] Commented private headers and implementation files
1ec5 Dec 2, 2015
ea57be5
[osx] Documentation comments for public classes
1ec5 Dec 3, 2015
bab3935
[osx] Fixed standalone launch of osxapp (and run-xosx)
1ec5 Dec 3, 2015
fdff790
[osx] Default callout view controller
1ec5 Dec 5, 2015
cd6830b
[osx] Fixed IB latitude/longitude inspectables
1ec5 Dec 6, 2015
3f2fae5
[osx] Don’t strip on copy in Debug
1ec5 Dec 6, 2015
0fb2b85
[osx] Map camera
1ec5 Dec 6, 2015
b869d3c
[osx] Persist viewpoint across relaunch
1ec5 Dec 6, 2015
0722d26
[osx] Remove All Pins command
1ec5 Dec 6, 2015
e7d7add
[ios] Strip OS X–specific APIs from iOS documentation
1ec5 Dec 6, 2015
727dd61
[osx] Printing
1ec5 Dec 7, 2015
835bb6a
[osx] Sort candidate annotations by proximity to tap
1ec5 Dec 11, 2015
a01dd8a
[osx] Corrected documentation
1ec5 Dec 14, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ ipackage-sim: Xcode/ios ; @JOBS=$(JOBS) ./scripts/ios/package.sh sim
ipackage-no-bitcode: Xcode/ios ; @JOBS=$(JOBS) ./scripts/ios/package.sh no-bitcode
iframework: ipackage-strip ; ./scripts/ios/framework.sh
itest: ipackage-sim ; ./scripts/ios/test.sh

.PHONY: xpackage xpackage-strip
xpackage: Xcode/osx ; @JOBS=$(JOBS) ./scripts/osx/package.sh
xpackage-strip: Xcode/osx ; @JOBS=$(JOBS) ./scripts/osx/package.sh strip
endif

#### All platforms targets #####################################################
Expand Down Expand Up @@ -128,10 +132,12 @@ ifeq ($(BUILD), osx)
if [ $$CUSTOM_DD ]; then \
echo clearing files in $$CUSTOM_DD older than one day; \
find $$CUSTOM_DD/mapboxgl-app-* -mtime +1 | xargs rm -rf; \
find $$CUSTOM_DD/osxapp-* -mtime +1 | xargs rm -rf; \
fi; \
if [ -d ~/Library/Developer/Xcode/DerivedData/ ] && [ ! $$CUSTOM_DD ]; then \
echo 'clearing files in ~/Library/Developer/Xcode/DerivedData/mapboxgl-app-* older than one day'; \
echo 'clearing files in ~/Library/Developer/Xcode/DerivedData/{mapboxgl-app,osxapp}-* older than one day'; \
find ~/Library/Developer/Xcode/DerivedData/mapboxgl-app-* -mtime +1 | xargs rm -rf; \
find ~/Library/Developer/Xcode/DerivedData/osxapp-* -mtime +1 | xargs rm -rf; \
fi
endif

Expand All @@ -146,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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**

Expand All @@ -19,7 +19,7 @@ If you want to use products _based on_ Mapbox GL, check out:
## Targets

* Ubuntu Linux
* OS X 10.9+
* OS X 10.10+
* iOS 7.0+
* iPhone 4S and above (5, 5c, 5s, 6, 6 Plus)
* iPad 2 and above (3, 4, Mini, Air, Mini 2, Air 2)
Expand Down
21 changes: 21 additions & 0 deletions docs/BUILD_OSX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Building Mapbox GL Native for OS X

This project provides an OS X SDK analogous to the Mapbox iOS SDK. Mapbox does not officially support it to the same extent as the iOS SDK; however, bug reports and pull requests are certainly welcome. This document explains how to build the OS X SDK and integrate it into your own Cocoa application.

### Build

1. Run `make xpackage`, which produces a `Mapbox.framework` in the `build/osx/pkg/` folder.

### Install

1. Copy `gyp/build/Release/Mapbox.framework` into your project.

1. In the project editor, select your application target, go to the General tab, and add `Mapbox.framework` to the *Embedded Binaries* section.

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).

## Troubleshooting

You can also try clearing the Xcode cache with `make clear_xcode_cache`.
2 changes: 1 addition & 1 deletion docs/DEVELOP_IOS_OSX.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Run

make iproj

Which which will create and open an Xcode project which can build the entire library from source, as well as an Objective-C test app.
Which will create and open an Xcode project that can build the entire library from source, as well as an Objective-C test app.

If you don't have an Apple Developer account, change the destination from "My Mac" to a simulator such as "iPhone 6" before you run and build the app.

Expand Down
18 changes: 7 additions & 11 deletions docs/DEVELOP_OSX.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@

To create projects, you can run:

- `make xproj`: Creates an Xcode project with OS X-specific handlers for HTTP downloads and settings storage. It uses [GLFW](http://www.glfw.org) for window handling.
- `make xproj`: Creates an Xcode project with a native OS X application for testing changes to mapbox-gl-native on the desktop.
- `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/)._

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)
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

Keyboard shortcuts for testing functionality are logged to the console when the test app is started.
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).
2 changes: 1 addition & 1 deletion gyp/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
'GCC_WARN_PEDANTIC': 'YES',
'GCC_WARN_UNINITIALIZED_AUTOS': 'YES_AGGRESSIVE',
'MACOSX_DEPLOYMENT_TARGET': '10.9',
'MACOSX_DEPLOYMENT_TARGET': '10.10',
},
}, {
'cflags_cc': [
Expand Down
3 changes: 2 additions & 1 deletion gyp/osx.gyp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
'includes': [
'../platform/osx/mapboxgl-app.gypi',
'../platform/osx/app/mapboxgl-app.gypi',
'../platform/osx/sdk/framework-osx.gypi',
'../platform/linux/mapboxgl-app.gypi',
'../test/test.gypi',
'../bin/render.gypi',
Expand Down
53 changes: 29 additions & 24 deletions gyp/platform-ios.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -20,52 +20,53 @@
'../platform/darwin/image.mm',
'../platform/darwin/nsthread.mm',
'../platform/darwin/reachability.m',
'../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/MGLMapboxEvents.h',
'../platform/ios/MGLMapboxEvents.m',
'../include/mbgl/ios/MGLMapCamera.h',
'../platform/ios/MGLMapCamera.mm',
'../include/mbgl/ios/MGLMapView.h',
'../include/mbgl/ios/MGLMapView+IBAdditions.h',
'../platform/ios/MGLMapView.mm',
'../include/mbgl/ios/MGLAccountManager.h',
'../platform/ios/MGLAccountManager_Private.h',
'../platform/ios/MGLAccountManager.m',
'../include/mbgl/ios/MGLAnnotation.h',
'../include/mbgl/ios/MGLUserLocation.h',
'../platform/ios/MGLUserLocation_Private.h',
'../platform/ios/MGLUserLocation.m',
'../platform/ios/MGLUserLocationAnnotationView.h',
'../platform/ios/MGLUserLocationAnnotationView.m',
'../include/mbgl/ios/MGLTypes.h',
'../platform/ios/MGLTypes.m',
'../include/mbgl/ios/MGLGeometry.h',
'../platform/ios/MGLGeometry.m',
'../include/mbgl/ios/MGLMultiPoint.h',
'../platform/ios/MGLMultiPoint_Private.h',
'../platform/ios/MGLMultiPoint.mm',
'../include/mbgl/ios/MGLOverlay.h',
'../include/mbgl/ios/MGLPointAnnotation.h',
'../platform/ios/MGLPointAnnotation.m',
'../include/mbgl/ios/MGLPolyline.h',
'../platform/ios/MGLPolyline.m',
'../include/mbgl/ios/MGLPolygon.h',
'../platform/ios/MGLPolygon.m',
'../include/mbgl/ios/MGLShape.h',
'../platform/ios/MGLShape.m',
'../include/mbgl/ios/MGLAnnotationImage.h',
'../platform/ios/MGLAnnotationImage.m',
'../include/mbgl/ios/MGLStyle.h',
'../platform/ios/MGLStyle.mm',
'../platform/ios/MGLCategoryLoader.h',
'../platform/ios/MGLCategoryLoader.m',
'../platform/ios/NSBundle+MGLAdditions.h',
'../platform/ios/NSBundle+MGLAdditions.m',
'../platform/ios/NSException+MGLAdditions.h',
'../platform/ios/NSProcessInfo+MGLAdditions.h',
'../platform/ios/NSProcessInfo+MGLAdditions.m',
'../platform/ios/NSString+MGLAdditions.h',
'../platform/ios/NSString+MGLAdditions.m',
'../platform/ios/vendor/SMCalloutView/SMCalloutView.h',
'../platform/ios/vendor/SMCalloutView/SMCalloutView.m',
'../platform/ios/vendor/Fabric/FABAttributes.h',
Expand Down Expand Up @@ -96,6 +97,8 @@
},

'include_dirs': [
'../include/mbgl/ios',
'../include/mbgl/darwin',
'../include',
'../src',
],
Expand All @@ -115,6 +118,8 @@

'direct_dependent_settings': {
'include_dirs': [
'../include/mbgl/ios',
'../include/mbgl/darwin',
'../include',
],
'mac_bundle_resources': [
Expand Down
54 changes: 44 additions & 10 deletions gyp/platform-osx.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,58 @@
'../platform/darwin/asset_root.mm',
'../platform/darwin/image.mm',
'../platform/darwin/nsthread.mm',
'../platform/darwin/reachability.m',
'../platform/darwin/NSException+MGLAdditions.h',
'../platform/darwin/NSString+MGLAdditions.h',
'../platform/darwin/NSString+MGLAdditions.m',
'../platform/darwin/MGLTypes.m',
'../platform/darwin/MGLStyle.mm',
'../platform/darwin/MGLGeometry_Private.h',
'../platform/darwin/MGLGeometry.mm',
'../platform/darwin/MGLShape.m',
'../platform/darwin/MGLMultiPoint_Private.h',
'../platform/darwin/MGLMultiPoint.mm',
'../platform/darwin/MGLPointAnnotation.m',
'../platform/darwin/MGLPolyline.mm',
'../platform/darwin/MGLPolygon.mm',
'../platform/darwin/MGLMapCamera.mm',
'../platform/osx/src/MGLAccountManager_Private.h',
'../platform/osx/src/MGLAccountManager.m',
'../platform/osx/src/MGLMapView_Private.h',
'../platform/osx/src/MGLMapView.mm',
'../platform/osx/src/MGLMapView+IBAdditions.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',
'../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': {
'cflags_cc': [
'<@(libuv_cflags)',
'<@(boost_cflags)',
'<@(variant_cflags)',
],
'libraries': [
'<@(libuv_static_libs)',
],
'ldflags': [
'-framework Foundation',
'-framework ImageIO',
'-framework CoreServices',
'-framework OpenGL',
'-framework ApplicationServices',
'$(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',
],
},

'include_dirs': [
'../include/mbgl/osx',
'../include/mbgl/darwin',
'../include',
'../src',
],
Expand All @@ -51,15 +83,17 @@

'link_settings': {
'libraries': [ '<@(libraries)' ],
'xcode_settings': {
'OTHER_LDFLAGS': [ '<@(ldflags)' ],
},
},

'direct_dependent_settings': {
'include_dirs': [
'../include/mbgl/osx',
'../include/mbgl/darwin',
'../include',
],
'mac_bundle_resources': [
'<!@(find ../platform/osx/src/resources -type f \! -name \'.*\')',
],
},
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <TargetConditionals.h>

#import "MGLTypes.h"

Expand Down Expand Up @@ -29,6 +30,13 @@ NS_ASSUME_NONNULL_BEGIN
* This string is displayed in the callout for the associated annotation. */
@property (nonatomic, readonly, copy, nullable) NSString *subtitle;

#if !TARGET_OS_IPHONE

/** The string containing the annotation’s tooltip. */
@property (nonatomic, readonly, copy, nullable) NSString *toolTip;

#endif

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,12 @@ NS_INLINE NSString *MGLStringFromCoordinateBounds(MGLCoordinateBounds bounds) {
}

/** Returns radians, converted from degrees. */
NS_INLINE CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees)
{
NS_INLINE CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees) {
return (CGFloat)(degrees * M_PI) / 180;
}

/** Returns degrees, converted from radians. */
NS_INLINE CLLocationDegrees MGLDegreesFromRadians(CGFloat radians)
{
NS_INLINE CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) {
return radians * 180 / M_PI;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ NS_ASSUME_NONNULL_BEGIN
/** The subtitle of the shape annotation. The default value of this property is `nil`. */
@property (nonatomic, copy, nullable) NSString *subtitle;

#if !TARGET_OS_IPHONE

/** The tooltip of the shape annotation. The default value of this property is `nil`. */
@property (nonatomic, copy, nullable) NSString *toolTip;

#endif

@end

NS_ASSUME_NONNULL_END
Loading