This guide contains the steps required to contribute to the development of this project.
- Setting Up a Development Environment
- Updating Dependency Versions
- Running Unit Tests On Devices
- Running Integration Tests
- Making an Example
This project runs on Apple's Metal rendering framework. Prerequisites for running the test app in simulators:
- macOS 10.15 or later
- Xcode 12.5.1+
This project:
-
requires a valid ~/.netrc file with a Mapbox secret token to download binary dependencies. Note: A public token (pk.*) is not sufficient for downloading binary dependencies.
-
reads a Mapbox access token from a file at
~/mapboxto enable tests and apps to access Mapbox APIs. -
uses SwiftLint to enforce a style guide. Install it with
brew install swiftlintand check for lint by runningswiftlintin the root of the repository. -
uses Swift Package Manager to manage dependencies for development. CocoaPods is supported for consuming the SDK.
-
uses Carthage to manage binary dependencies that are automatically downloaded when running xcodegen.
-
Install pre-commit hooks
brew install xcodegen swiftlint carthage
pip install pre-commit
pre-commit install # Installs the pre-commit hooks- uses CircleCI and Firebase Test Lab for continuous integration.
Clone the git repository:
git clone [email protected]:mapbox/mapbox-maps-ios.git && cd mapbox-maps-ios- Run
xcodegenin the root of the repo to generate the Xcode project. - Open the resulting
MapboxMaps.xcodeprojin Xcode and and build theMapboxMapstarget.
In order to use the debug app, run the DebugApp scheme.
- Update the dependency versions in
Package.swift - Open
Package.swiftin Xcode and resolve dependencies. This updatesPackage.resolved. Close that Xcode workspace. - Open
Apps/Apps.xcworkspacein Xcode and resolve dependencies. This updates a differentPackage.resolvedfile in theApps.workspacebundle. Close that Xcode workspace. - Update the dependency versions in
MapboxMaps.podspec - Update the dependency versions in
scripts/release/packager/versions.json
- Follow the Building the Maps SDK steps above.
- Test the
MapboxTestHostscheme.
Integration tests typically require a Metal device, so these tests can only run locally and on Firebase Test Lab. They are skipped when running on CI inside of a VM and when running on simulators < iOS 13 (iOS 13+ has a simulated Metal device.)
There is a host application, so MapViewIntegrationTestCase fetches the
existing window and view controller before adding the MapView to it.
- These tests can be run on devices.
- Tests will be skipped on simulators < iOS 13
There is no host application, so MapViewIntegrationTestCase creates its
own UIWindow and root view controller, before adding the MapView to it.
- These tests cannot be run on devices.
- Tests will be skipped on simulators < iOS 13
- Tests will be skipped entirely on CircleCI because of the VM (no Metal).
-
IntegrationTestCaseis a base class that fetches the access token for use in tests. It checks for the token in the following locations and uses the first one that it finds:-
UserDefaultsunder the keyMBXAccessToken. This allows setting a value when running tests from the command line. -
Info.plistunder the keyMBXAccessToken. The value for this key is populated automatically when running tests viaMapboxTestHostif you have adeveloper.xcconfigfile in the root of the repo that looks like:MAPBOX_ACCESS_TOKEN = pk.myaccesstoken -
a resource in the test bundle named MapboxAccessToken. This file is generated at build time via a pre-action on the scheme when running tests using
MapboxMaps. The pre-action pulls the token from~/mapboxor~/.mapbox.
-
-
MapViewIntegrationTestCasesubclasses the above, and sets theMapView. Closures are used to expose key map events to subclasses. Please don't add tests to this class. -
ExampleIntegrationTestis an example of using the above, that sets a style then waits for the load to finish.
- Check out this project to get more information about adding examples to our project.
Internal events of MapboxMaps can captured in Xcode Instruments using signposts. Most useful examples of them:
- Rendering calls
- Gestures points of interests
In order to enable them, set MAPBOX_MAPS_SIGNPOSTS_ENABLED environment variable to your Profile Scheme.