Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.prism.byescaleira.com/llms.txt

Use this file to discover all available pages before exploring further.

Location & Maps

PrismCapabilities wraps Core Location and MapKit into type-safe, Sendable APIs. Request permissions, track location, monitor geofences, and display maps without managing CLLocationManager delegates.

Location Client

Permissions

Request Location Permission
import PrismCapabilities

let client = PrismLocationClient()

// Check current status
let permission = client.permissionStatus
// .notDetermined, .restricted, .denied, .authorizedWhenInUse, .authorizedAlways

// Request authorization
try await client.requestWhenInUseAuthorization()

Current Location

Get Current Location
let location = try await client.currentLocation(
    accuracy: .best
)

print("Lat: \(location.latitude)")
print("Lng: \(location.longitude)")
print("Alt: \(location.altitude ?? 0)m")
print("Accuracy: \(location.horizontalAccuracy)m")

Continuous Tracking

Stream location updates using AsyncStream:
Track Location
for await location in client.startUpdating(accuracy: .nearestTenMeters) {
    print("\(location.latitude), \(location.longitude)")
}

Accuracy Levels

LevelDescription
.bestHighest accuracy — GPS
.nearestTenMeters~10m precision
.hundredMeters~100m precision
.kilometer~1km precision
.threeKilometers~3km — lowest power

PrismLocation

All location data uses the PrismLocation struct:
public struct PrismLocation: Sendable {
    public let latitude: Double
    public let longitude: Double
    public let altitude: Double?
    public let horizontalAccuracy: Double
    public let timestamp: Date
}

Geofencing

Monitor enter/exit events for circular geographic regions:
Geofence Monitoring
let region = PrismGeofenceRegion(
    id: "office",
    latitude: 37.7749,
    longitude: -122.4194,
    radius: 200  // meters
)

try await client.startMonitoring(region: region)

for await event in client.geofenceEvents {
    switch event {
    case .entered(let region):
        print("Entered \(region.id)")
    case .exited(let region):
        print("Exited \(region.id)")
    }
}
iOS limits geofence monitoring to 20 regions per app. Choose your regions wisely.

Map Client

PrismMapClient provides MapKit utilities for geocoding and search:
Geocoding
let mapClient = PrismMapClient()

// Forward geocode
let coordinates = try await mapClient.geocode(
    address: "1 Apple Park Way, Cupertino, CA"
)

// Reverse geocode
let placemark = try await mapClient.reverseGeocode(
    latitude: 37.3349,
    longitude: -122.0090
)
print(placemark.locality ?? "Unknown city")
Search Nearby
let results = try await mapClient.search(
    query: "coffee",
    near: PrismLocation(latitude: 37.7749, longitude: -122.4194),
    radius: 1000
)

for place in results {
    print("\(place.name)\(place.distance)m away")
}