mapkit-geo
MapKit & GeoToolbox
PlaceDescriptor (GeoToolbox)
Standardized place representation that works across mapping services.
import GeoToolbox
import MapKit
// From address
let place = PlaceDescriptor(
representations: [.address("121 James's St\nDublin 8\nIreland")],
commonName: "Obelisk Fountain"
)
// From coordinates
let tower = PlaceDescriptor(
representations: [.coordinate(CLLocationCoordinate2D(latitude: 48.8584, longitude: 2.2945))],
commonName: "Eiffel Tower"
)
// Multiple representations
let statue = PlaceDescriptor(
representations: [
.coordinate(CLLocationCoordinate2D(latitude: 40.6892, longitude: -74.0445)),
.address("Liberty Island, New York, NY 10004")
],
commonName: "Statue of Liberty"
)
// From MKMapItem
let descriptor = PlaceDescriptor(item: mapItem)
// Access properties
let coord = descriptor.coordinate // CLLocationCoordinate2D?
let address = descriptor.address // String?
let name = descriptor.commonName // String?
Third-Party Place IDs (SupportingPlaceRepresentation)
// Attach third-party identifiers
let place = PlaceDescriptor(
representations: [.coordinate(coord)],
supportingRepresentations: [
SupportingPlaceRepresentation(service: .googleMaps, identifier: "ChIJ..."),
SupportingPlaceRepresentation(service: .here, identifier: "here:..."),
SupportingPlaceRepresentation(service: .foursquare, identifier: "4b...")
],
commonName: "My Place"
)
// Extract specific service ID
func getGooglePlaceID(from descriptor: PlaceDescriptor) -> String? {
descriptor.supportingRepresentations
.first(where: { $0.service == .googleMaps })?
.identifier
}
Convert PlaceDescriptor → MKMapItem
func convertToMapItem(descriptor: PlaceDescriptor) async throws -> MKMapItem? {
if let coord = descriptor.coordinate {
let placemark = MKPlacemark(coordinate: coord)
let item = MKMapItem(placemark: placemark)
item.name = descriptor.commonName
return item
}
if let address = descriptor.address {
let geocoder = CLGeocoder()
let placemarks = try await geocoder.geocodeAddressString(address)
if let first = placemarks.first {
return MKMapItem(placemark: MKPlacemark(placemark: first))
}
}
return nil
}
SwiftUI Map
import MapKit
struct MapView: View {
@State private var position: MapCameraPosition = .automatic
let places: [PlaceDescriptor]
var body: some View {
Map(position: $position) {
ForEach(places.indices, id: \.self) { i in
if let coord = places[i].coordinate {
Marker(places[i].commonName ?? "Place", coordinate: coord)
}
}
}
.mapStyle(.standard(elevation: .realistic))
}
}
References
More from makgunay/claude-swift-skills
macos-app-structure
macOS application architecture patterns covering App protocol (@main), Scene types (WindowGroup, Window, Settings, MenuBarExtra), multi-window management, NSApplicationDelegateAdaptor for AppKit lifecycle hooks, Info.plist configuration (LSUIElement for menu bar apps, NSAccessibilityUsageDescription), entitlements for sandbox/hardened runtime, and project structure conventions. Use when scaffolding a new macOS app, configuring scenes and windows, setting up menu bar apps, or resolving macOS-specific lifecycle issues. Corrects the common LLM mistake of generating iOS-only app structures.
31macos-permissions
macOS permission handling for Accessibility (AXIsProcessTrusted), Screen Recording, Full Disk Access, input monitoring, camera, microphone, location, and contacts. Covers TCC (Transparency Consent and Control) database, graceful degradation when permissions are denied, permission prompting patterns, opening System Settings to the correct pane, detecting permission changes, and the privacy manifest (PrivacyInfo.xcprivacy) requirement. Use when implementing features that require system permissions, building permission onboarding flows, or handling denied permissions gracefully.
17appkit-bridge
Bridging AppKit components into SwiftUI macOS apps. Covers NSViewRepresentable and NSViewControllerRepresentable protocols for hosting AppKit views in SwiftUI, NSHostingView/NSHostingController for hosting SwiftUI in AppKit, NSPanel for floating windows, NSWindow configuration (styleMask, level, collectionBehavior), responder chain integration, NSEvent monitoring (global and local), NSAnimationContext for AppKit animations, NSPopover, NSStatusItem for menu bar, and NSGlassEffectView for AppKit Liquid Glass. Use when SwiftUI lacks a native equivalent, building floating panels, custom window chrome, or integrating legacy AppKit components.
15swiftui-core
Core SwiftUI patterns for macOS and iOS development including navigation (NavigationSplitView, NavigationStack), state management (@State, @Binding, @Environment, @Bindable with @Observable), the new customizable toolbar system (toolbar IDs, ToolbarSpacer, DefaultToolbarItem, searchToolbarBehavior, matchedTransitionSource, sharedBackgroundVisibility), styled text editing (TextEditor with AttributedString, AttributedTextSelection, transformAttributes, textFormattingDefinition), and layout patterns. Use when building any SwiftUI view, implementing navigation, managing state, creating toolbars, or building rich text editors. Corrects common LLM errors like using deprecated NavigationView, wrong state wrappers, and outdated toolbar APIs.
14global-hotkeys
System-wide keyboard shortcut registration on macOS using NSEvent monitoring (simple, app-level) and Carbon EventHotKey API (reliable, system-wide). Covers NSEvent.addGlobalMonitorForEvents and addLocalMonitorForEvents, CGEvent tap for keystroke simulation, Carbon RegisterEventHotKey for system-wide hotkeys, modifier flag handling (.deviceIndependentFlagsMask), common key code mappings, debouncing, Accessibility permission requirements (AXIsProcessTrusted), and SwiftUI .onKeyPress for in-app shortcuts. Use when implementing global keyboard shortcuts, hotkey-triggered panels, or system-wide key event monitoring.
11swiftui-webkit
Native SwiftUI WebKit integration with the new WebView struct and WebPage observable class. Covers WebView creation from URLs, WebPage for navigation control and state management, JavaScript execution (callJavaScript with arguments and content worlds), custom URL scheme handlers, navigation management (load, reload, back/forward), navigation decisions, text search (findNavigator), content capture (snapshots, PDF generation, web archives), and configuration (data stores, user agents, JS permissions). Use when embedding web content in SwiftUI apps instead of the old WKWebView + UIViewRepresentable/NSViewRepresentable bridge pattern. This is a brand new API — do NOT use the old WKWebView wrapping approach.
10