Get started
Swift SDK
Reference

Troubleshooting

Troubleshooting

The problems developers hit first with the Swift SDK, each with its fix.

MapView is unavailable

The package's Elements trait is off, or the target is not iOS. Turn the trait on where you depend on the package:

.package(url: "https://github.com/mountaya/sdk-swift", from: "0.1.0", traits: ["Elements"])

In Xcode, turn on Elements in the package's traits under Package Dependencies. On macOS, tvOS, watchOS or visionOS, hold the map's state with MapEngine and draw it yourself.

secret(key:) is unavailable in an app

A secret key belongs on a server, and an app build cannot name one. Mint session tokens on your server, and give the app a publishable key with a SessionTokenEngine (authentication).

The client throws a configuration error at launch

The key the app read is empty: Info.plist holds $(MOUNTAYA_PUBLISHABLE_KEY) unresolved. Check that your target's configuration file includes Local.xcconfig, and that the key is set there. Log what the app read:

import Foundation

let key = Bundle.main.object(forInfoDictionaryKey: "MOUNTAYA_PUBLISHABLE_KEY") as? String
print(key?.isEmpty == false ? "key found" : "no key in Info.plist")

The map stays empty

The Tile API refused your key, most often for a missing tiles scope. map.state.isAccessRequired turns true, and events() tells an .accessRefused with its status. Add the scope to the key under Organization → API keys in the Mountaya app.

Search or a Data API call answers 401

The Data API takes a publishable key only beside a session token. Give the client a SessionTokenEngine over your server's POST /session route (authentication).

A write answers 401

A write acts as a member. Mint its session for the studio-embedded product and name the member (act as a member).

A call answers 402

Your organization's agreement does not cover the call, or its billing needs a payment method. It is fixed in the Mountaya app's billing settings or with Mountaya, never in code: catch .api with kind == .billing and say so.

A webhook delivery never verifies

The body was decoded and encoded again before verification. Pass constructWebhookEvent the raw bytes your web framework received, and the endpoint's own secret, whsk_ included.

Navigation reads no position

DeviceLocationSource never asks for location access. Ask yourself, with a purpose string in Info.plist, and on the simulator pick a location under Features → Location:

import CoreLocation
import MountayaNavigation

@MainActor
func askForLocation(_ access: CLLocationManager, source: DeviceLocationSource) {
  access.requestWhenInUseAuthorization()
  print(source.recheckPermission().authorization)
}

Navigation says nothing

The engine was given no voice, or the device has none for the language. Hand it a SpeechNavigationVoice with a fallbackLanguage, and give it an onError to hear a refused audio session.

The build refuses the platform version

SwiftPM or Xcode names the floor your target falls short of. Raise the target's deployment version to the package's floor:

FloorVersion
Swift6.2.3 or newer
iOS and iPadOS17 or newer
Mac Catalyst17 or newer
macOS14 or newer
tvOS17 or newer
visionOS1 or newer
watchOS10 or newer

Next steps

Last updated