Skip to content

Latest commit

 

History

History
115 lines (73 loc) · 3.16 KB

install.md

File metadata and controls

115 lines (73 loc) · 3.16 KB

iOS Installation

React-Native > 0.60.0

The following assumes, that you're using autolinking and installed

@rnmapbox/maps via npm or yarn.


Add the following to your ios/Podfile:

$RNMapboxMapsImpl = 'mapbox'
  pre_install do |installer|
    $RNMapboxMaps.pre_install(installer)
    ... other pre install hooks
  end
  post_install do |installer|
    $RNMapboxMaps.post_install(installer)
    ... other post install hooks
  end

You will need to authorize your download of the Maps SDK with a secret access token with the DOWNLOADS:READ scope. This guide explains how to configure the secret token under section Configure your secret token.

Set the $RNMapboxMapsImpl to mapbox aka v10 implementation see bellow for detailed instructions

Run pod install to download the proper mapbox dependency.

# Go to the ios folder
cd ios

# Run Pod Install
pod install

If you want to show the user's current location on the map with the UserLocation component, you'll need to add the following property to your Info.plist (see Mapbox iOS docs for more info):

<key>NSLocationWhenInUseUsageDescription</key>
<string>Show current location on map.</string>

You are good to go!

Read on if you want to edit your Mapbox version or flavor.


Mapbox Maps SDK (v10)

This is the version we recommend.

Check the current version of the SDK here.

Add the following to the beginning of your podfile

$RNMapboxMapsImpl = 'mapbox'

Using a custom version of the Mapbox SDK

You can also override the version to use. Warning: if you set a version, then later update, the rnamapbox/maps library it's possible that you'll end up using Mapbox older version than supported. Make sure you revise this value with @rnmapbox/maps updates. Also note that for 11.0 or later versions you'll need to set $RNMapboxMapsUseV11 = true, see bellow

# Warning: only for advanced use cases, only do this if you know what you're doing.
# $RNMapboxMapsVersion = '~> 10.12.0'

V11 support

We have experimental support for mapbox 11 beta.

Add the following to your Podfile:

$RNMapboxMapsUseV11 = true # use 11 version
$RNMapboxMapsVersion = '= 11.0.0-beta.5'

If using expo managed workflow, set the "RNMapboxMapsVersion" variable and the "RNMapboxMapsUseV11" variable to true. See the expo guide

Troubleshooting

Pod install fails on upgrade of @rnmapbox/maps with could not find compatible versions for pod "MapboxMaps"

Example message:

[!] CocoaPods could not find compatible versions for pod "MapboxMaps":
  In snapshot (Podfile.lock):
    MapboxMaps (= 10.15.0, ~> 10.15.0)

  In Podfile:
    rnmapbox-maps (from `../node_modules/@rnmapbox/maps`) was resolved to 10.0.15, which depends on
      MapboxMaps (~> 10.16.0)

Please use pod update MapboxMaps as suggested by cocoapods