Skip to content

Upgrading from Mapbox Maps SDK for iOS v3.7.x to v4.0.x

Minh Nguyễn edited this page May 17, 2018 · 6 revisions

Mapbox Maps SDK for iOS v4.0.0 is the first major version of this SDK since 2015. To upgrade, follow the installation instructions. If you use CocoaPods or Carthage, update the version to ~> 4.0, then run pod update or carthage update.

Version 4.0.0 contains a number of important changes. There are several backwards-incompatible changes to be aware of as you upgrade, which are discussed below.

Runtime styling

We made a number of improvements to give you more control over the appearance of a map’s style. These improvements required us to make the following backwards-incompatible API changes to MGLStyleLayer and its subclasses:

  • The layout and paint properties on subclasses of MGLStyleLayer are now of type NSExpression instead of MGLStyleValue. MGLStyleValue has been removed. The “Migrating to Expressions” guide shows you how to migrate your runtime styling code to NSExpression. The “Predicates and Expressions” guide contains full details on how to write expressions that are compatible with style layers.
  • A small number of NSPredicates written for v3.7.x may need to cast feature attributes to the correct type, as described in this section of the predicate guide.

Additionally, MGLRasterSource was renamed MGLRasterTileSource and MGLVectorSource was renamed MGLVectorTileSource. Xcode automatically provides fix-it suggestions for these changes.

Swift class methods

If your application is written in Swift, you’ll need to account for the following class methods being converted into class properties. Xcode automatically provides fix-it suggestions for these changes as well:

Old New
MGLStyle.streetsStyleURL() etc. MGLStyle.streetsStyleURL etc.
MGLOfflineStorage.shared() MGLOfflineStorage.shared
MGLAccountManager.setAccessToken("pk.…") MGLAccountManager.accessToken = "pk.…"

Other changes

Any classes, methods, or properties that were deprecated in v3.7.6 are no longer available. See your project’s build errors for details about replacements.

The MGLStyle.localizesLabels property has been replaced by an -[MGLStyle localizeLabelsIntoLocale:] method that applies the same effect. See this guide for more details.

The SDK no longer supports 32-bit simulators, such as the iPhone 5 and iPad 2 simulators. The SDK continues to support 32-bit devices, but note that the minimum iOS deployment version will increase to iOS 9.0 in a future release. 32-bit simulator support was temporarily restored in v4.0.1 for CocoaPods compatibility, but it will be removed at some point in the future along with 32-bit device support.

If you have any questions, please contact Mapbox’s support team.

You can’t perform that action at this time.