-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Include Mapbox SDK in existing OS X Application #3043
Comments
The big lift here @tkrajacic is that aside from iOS, Android, and Node.js, we don't have bindings atop the C++ code at all. This includes the Mac. So the Mac project (e.g. So, short version: you should be able to create an OS X app which creates its own e.g. It's not really in the cards right now for anything more advanced for OS X or Linux or bindings for Cocoa manipulation. I think that's the closest I can get you, but I'll let @kkaefer add any other details if he has them. |
Thanks for the great walkthrough. I just wonder - The iOS Bindings should be 99% reusable for OS X or not? |
It may be possible, with a bit of trial and error, to get it to work on OS X, but code changes would definitely be required because AppKit differs from UIKit in many ways. |
So if one would translate |
The ios/ directory contains the example application, while include/mbgl/ios/, platform/ios/, mbgl/platform/darwin/, and platform/darwin/ contain the actual library code. (The last two use only Foundation, so they should be compatible with OS X already.) The meat of the code is in MGLMapView.m. Note our use of SMCalloutView in platform/ios/vendor/ – on OS X, it’d be better to use NSPopover. |
There’s a lot of code that’s specific to UIKit in MGLMapView, MGLUserAnnotationView, etc. I haven’t tried, but #3043 (comment) sounds like a good summary of what would be required for the bare minimum to display a draggable/zoomable map. |
@tkrajacic, please take a look at the 1ec5-osx branch I just pushed. It adds a new MGLMapView class analogous to MGLMapView for iOS, plus a pure Cocoa osxapp. It’s exceptionally rough around the edges: in particular, it tends to spin up the fan even when idle, it crashes when you hit ⌘W, and annotations and the user dot aren’t yet implemented. But if you’re interested in hacking on it, run To integrate this library into a separate project:
Please note that OS X is not officially supported at the same level as iOS (yet?), but I hope this branch in a good enough state that you can run with it. Good luck! |
Wow, you guys are absolutely awesome! Setting aside even a few minutes to work on something that is clearly not the focus at all is ... well incredible. I'll buy you all a beer should I be in the area ;) I'll take it for a spin, but I'm swamped with other work at the moment. |
Had to include SystemConfiguration.framework as well and create a bridging-header since I am using Swift.
Seems that |
I forgot to mention that Bitcode is enabled, in case you're still using Xcode 6.x. Not sure if that's related at all to this error, though. |
I am using latest Xcode 7.1.1 I thought Bitcode wasn't available for OS X targets. No setting in |
Ah, you’re right. 😄 |
I’m not getting those warnings after a full |
The cleaning before building did the trick and got rid of the duplicate symbols. |
MGLMapView supports style from various locations. If you designed a style in Mapbox Studio, the “style ID” that begins with mapbox:// should work. If you want to load a local style, a relative URL or one beginning with asset:// would be relative to your application’s Resources folder. (Drag the JSON file into your project’s Supporting Files group.) If you’re using a Mapbox-hosted style, make sure your access token is set, either in the |
Yeah I thought the access token still had to be set via environment variable. Setting it via the manager works now. |
#3135 landed. |
Is it possible to easily™ include mapbox-gl in an existing OS X application.
I could build the sample app and re-use its Xcode project but that really is unwieldy.
I am using Swift and Storyboards which might pose another problem?
An SDK like the one for iOS would be nice (cocoapods or carthage would be even better) but I understand that this is not the focus right now.
Can I just link the build-products of the osx Xcode project statically and be done with it?
Kind of like with the prebuilt binaries for iOS.
Any hints or pointers?
Any help is greatly appreciated.
The text was updated successfully, but these errors were encountered: