Example application showing usage of Mapbox Vision SDK.
brew install SwiftGen
(6.0 or later)brew install carthage
(0.36.0 or later)
In order to fetch and use Vision SDK, you will need to obtain two tokens at tokens page in your Mapbox account:
- Public token: create a token that includes the
vision:read
scope - Secret token: create another one with the
vision:download
anddownloads: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.
git clone https://github.com/mapbox/vision-ios-examples.git
cd vision-ios-examples
- Open
Cartfile
and uncomment two lines concerning Vision:binary "https://api.mapbox.com/downloads/...
github "mapbox/mapbox-vision-ios"...
- Put your secret token instead of
<ADD-TOKEN-HERE>
inCartfile
carthage update --platform ios --use-netrc
open demo.xcodeproj
- Put your public token into the value of the
MGLMapboxAccessToken
key within theInfo.plist
file - Run the application
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.