Skip to content

Prerequisite

For all of our examples, you will need:

  • an API key,
  • knowledge in Swift/iOS development,
  • one style (default)

Get the library

There are several ways to get this library:

Installation (CocoaPods)

Add this to your Podfile:

ruby
target 'YourApp' do  
  pod 'MapMetrics-iOS', '~> 0.0.1'  # Use the latest version  
  # OR
  pod 'MapMetrics-iOS', :git => 'https://github.com/MapMetrics/MapMetrics-iOS', :tag => '0.0.1'
end

Run:

bash
pod install

Required Build Settings (Sandbox Fix)

To prevent rsync.samba deny(1) errors, users must add these settings:

Option A: Automatic Fix (via Podfile)

Add to your Podfile:

ruby
post_install do |installer|  
  installer.pods_project.targets.each do |target|  
    target.build_configurations.each do |config|  
      # Disable sandbox restrictions  
      config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO'  
    end  
  end  
end

Then run:

bash
pod install

Option B: Manual Fix (Xcode Settings)

  1. Open your project in Xcode.
  2. Go to Target → Build Settings.
  3. Search for ENABLE_USER_SCRIPT_SANDBOXING.
  4. Set to NO for all configurations (Debug/Release).

Verify Installation

Import in your code:

swift
import MapMetrics

Clean Build (if issues persist):

bash
rm -rf ~/Library/Developer/Xcode/DerivedData/*

Troubleshooting

IssueSolution
Sandbox deny(1) errorsEnsure ENABLE_USER_SCRIPT_SANDBOXING=NO is set.
pod install failsDelete Pods/ and Podfile.lock, then retry.
Version conflictsRun pod update MapMetrics.

Example Podfile (Complete)

ruby
platform :ios, '12.0'  

target 'YourApp' do  
  use_frameworks!  
  pod 'MapMetrics-iOS', '~> 0.0.1'  

  post_install do |installer|  
    installer.pods_project.targets.each do |target|  
      target.build_configurations.each do |config|  
        config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO'  
      end  
    end  
  end  
end

Example Usage

Here's how to integrate MapMetrics into your project:

swift
class ViewController: UIViewController, MLNMapViewDelegate {
    var mapView: MLNMapView!

    override func viewDidLoad() {
        super.viewDidLoad()

        mapView = MLNMapView(
            frame: view.bounds,
            styleURL: URL(string: "<YOUR_STYLE_URL_HERE>")
        )
        mapView.delegate = self
        view.addSubview(mapView)
                mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        mapView.delegate = self
        
        // This is a better starting position 
        let center = CLLocationCoordinate2D(latitude: 20.0, longitude: 0.0) // More centered globally
        mapView.setCenter(center, zoomLevel: 2, animated: false) // Lower zoom to see more area
        view.addSubview(mapView)

    }
}