/vision-ios-examples

Primary LanguageSwiftOtherNOASSERTION

Secret-shield enabled

Mapbox Vision SDK Examples

Example application showing usage of Mapbox Vision SDK.

Dependencies

  1. brew install SwiftGen (6.0 or later)
  2. brew install carthage (0.36.0 or later)

Tokens

In order to fetch and use Vision SDK, you will need to obtain two tokens at tokens page in your Mapbox account:

  1. Public token: create a token that includes the vision:read scope
  2. Secret token: create another one with the vision:download and downloads:read scopes

In order to use your secret token, you will need to store it a .netrc file in your home directory. Depending on your environment, you may have this file already, so check first before creating a new one.

To set up the credentials required to download the SDK, add the following entry to your .netrc file:

machine api.mapbox.com 
login mapbox
password <INSERT API TOKEN>

You'll also need your secret token while editing Cartfile during installation.

Installation

  1. git clone https://github.com/mapbox/vision-ios-examples.git
  2. cd vision-ios-examples
  3. Open Cartfile and uncomment two lines concerning Vision:
    • binary "https://api.mapbox.com/downloads/...
    • github "mapbox/mapbox-vision-ios"...
  4. Put your secret token instead of <ADD-TOKEN-HERE> in Cartfile
  5. carthage update --platform ios --use-netrc
  6. open demo.xcodeproj
  7. Put your public token into the value of the MGLMapboxAccessToken key within the Info.plist file
  8. Run the application

Contribution

We use secret-shield tool which runs as a pre-commit hook. In order to enable it you should install it with:

npm install -g @mapbox/secret-shield

Then you have to add a pre-commit git hook. The simplest option is to copy the following script into a vision-ios-examples/.git/hooks/pre-commit:

#!/bin/sh
secret-shield --pre-commit -C verydeep --enable "Mapbox Public Key" --disable "High-entropy base64 string" "Short high-entropy string" "Long high-entropy string"

Don't forget to make it executable:

chmod +x .git/hooks/pre-commit

As an option you can Integrate hook via git hooks manager (like Husky or Komondor). More information about installation is available here.