Token导航 LogoToken导航TokenDH.com
开发需要联网github未标认证来源可访问许可证需确认审计通过

apple-corelocationApple corelocation 命令行

Agent Skill

apple-corelocation 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

912

周安装

38

GitHub Stars

6

下载量

304
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:apple-corelocation(Apple corelocation 命令行)
来源仓库:https://github.com/ios-agent/iosagent.dev
仓库路径:skills/apple-corelocation
安装命令:
npx skills add https://github.com/ios-agent/iosagent.dev --skill apple-corelocation
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/ios-agent/iosagent.dev --skill apple-corelocation

简介

apple-corelocation 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态进行整理。

  • 适用于 iOS/macOS 位置服务开发、地理围栏和 iBeacon 近场检测的场景。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装,需确认定位精度和后台权限。
  • 安装前建议检查维护状态,避免触发不必要的硬件调用或网络请求操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Apple CoreLocation Skill

Use this skill to write correct, modern CoreLocation code. CoreLocation provides services for geographic location, altitude, orientation, and proximity to iBeacons. It uses Wi-Fi, GPS, Bluetooth, magnetometer, barometer, and cellular hardware.

When to Read Reference Files

This SKILL.md contains the essential patterns and quick-reference API surface. For deeper implementation details, read the appropriate reference file:

TopicReference FileWhen to Read
Live Updates & async/await patternsreferences/live-updates.mdSwiftUI apps, async location streams, background activity sessions
Authorization & Permissionsreferences/authorization.mdPermission flows, Info.plist keys, authorization status handling
Region Monitoring & CLMonitorreferences/monitoring.mdGeofencing, condition monitoring, circular regions
Geocodingreferences/geocoding.mdAddress ↔ coordinate conversion, reverse geocoding, CLPlacemark
iBeacon & Compassreferences/beacon-compass.mdBeacon ranging, heading updates, magnetometer
Background Locationreferences/background.mdBackground updates, CLBackgroundActivitySession, power optimization
CLLocationManager APIreferences/location-manager.mdFull property/method reference for CLLocationManager

Modern CoreLocation (iOS 17+): Prefer Async/Await

Since iOS 17, CoreLocation supports Swift concurrency. Prefer the modern async API over the legacy delegate-based approach for new projects.

Getting Live Location Updates (Recommended Pattern)

import CoreLocation

let updates = CLLocationUpdate.liveUpdates()

for try await update in updates {
    if let location = update.location {
        // Process location
        print("Lat: \(location.coordinate.latitude), Lon: \(location.coordinate.longitude)")
    }
    if update.authorizationDenied {
        // Handle denied authorization
    }
    if update.authorizationRequestInProgress {
        // System is showing the authorization dialog
    }
}

The system automatically prompts for authorization when iteration begins if status is .notDetermined. No explicit requestWhenInUseAuthorization() call is needed with this pattern, but you may still call it for controlled timing.

Live Updates with Accuracy Configuration

// High accuracy (GPS, more power)
let updates = CLLocationUpdate.liveUpdates(.default)

// Power-efficient options
let updates = CLLocationUpdate.liveUpdates(.automotiveNavigation)
let updates = CLLocationUpdate.liveUpdates(.otherNavigation)
let updates = CLLocationUpdate.liveUpdates(.fitness)
let updates = CLLocationUpdate.liveUpdates(.airborne)

CLLocationUpdate Properties

  • location: CLLocation? — The location, or nil if unavailable
  • isStationary: Bool — Whether the device is stationary
  • authorizationDenied: Bool — Authorization was denied
  • authorizationDeniedGlobally: Bool — Location services disabled system-wide
  • authorizationRequestInProgress: Bool — Auth dialog is being shown
  • insufficientlyInUse: Bool — App lacks sufficient "in use" state
  • locationUnavailable: Bool — Location data temporarily unavailable
  • accuracyLimited: Bool — Accuracy authorization is reduced

SwiftUI Integration Pattern

@MainActor
class LocationsHandler: ObservableObject {
    static let shared = LocationsHandler()
    private let manager: CLLocationManager
    private var background: CLBackgroundActivitySession?

    @Published var lastLocation = CLLocation()
    @Published var isStationary = false

    @Published var updatesStarted: Bool = UserDefaults.standard.bool(forKey: "liveUpdatesStarted") {
        didSet { UserDefaults.standard.set(updatesStarted, forKey: "liveUpdatesStarted") }
    }

    private init() {
        self.manager = CLLocationManager()
    }

    func startLocationUpdates() {
        if self.manager.authorizationStatus == .notDetermined {
            self.manager.requestWhenInUseAuthorization()
        }
        Task {
            do {
                self.updatesStarted = true
                let updates = CLLocationUpdate.liveUpdates()
                for try await update in updates {
                    if !self.updatesStarted { break }
                    if let loc = update.location {
                        self.lastLocation = loc
                        self.isStationary = update.isStationary
                    }
                }
            } catch {
                print("Could not start location updates")
            }
        }
    }

    func stopLocationUpdates() {
        self.updatesStarted = false
    }
}

Authorization Quick Reference

Info.plist Keys (Required)

KeyWhen to Use
NSLocationWhenInUseUsageDescriptionApp uses location while in foreground
NSLocationAlwaysAndWhenInUseUsageDescriptionApp needs location in background too
NSLocationDefaultAccuracyReducedRequest reduced accuracy by default

Authorization Status Values (CLAuthorizationStatus)

ValueMeaning
.notDeterminedUser hasn't been asked yet
.restrictedApp cannot use location (e.g., parental controls)
.deniedUser explicitly denied
.authorizedWhenInUseApp can use location while in foreground
.authorizedAlwaysApp can use location at any time

Requesting Authorization

let manager = CLLocationManager()

// For foreground-only access
manager.requestWhenInUseAuthorization()

// For background access (after getting "When In Use" first)
manager.requestAlwaysAuthorization()

// For temporary full accuracy (when user granted reduced accuracy)
manager.requestTemporaryFullAccuracyAuthorization(withPurposeKey: "MyPurposeKey")

Condition Monitoring with CLMonitor (iOS 17+)

let monitor = await CLMonitor("myMonitor")

// Add a circular geographic condition
await monitor.add(
    CLMonitor.CircularGeographicCondition(center: coordinate, radius: 200),
    identifier: "coffee-shop"
)

// Observe events
for try await event in await monitor.events {
    switch event.state {
    case .satisfied:
        print("Entered region: \(event.identifier)")
    case .unsatisfied:
        print("Exited region: \(event.identifier)")
    default:
        break
    }
}

Geocoding Quick Reference

let geocoder = CLGeocoder()

// Reverse geocode: coordinate → address
geocoder.reverseGeocodeLocation(location) { placemarks, error in
    if let placemark = placemarks?.first {
        print(placemark.locality ?? "Unknown city")
    }
}

// Forward geocode: address → coordinate
geocoder.geocodeAddressString("1 Apple Park Way, Cupertino") { placemarks, error in
    if let location = placemarks?.first?.location {
        print(location.coordinate)
    }
}

CLLocation Key Properties

PropertyTypeDescription
coordinateCLLocationCoordinate2DLatitude and longitude (WGS 84)
altitudeCLLocationDistanceMeters above sea level
horizontalAccuracyCLLocationAccuracyAccuracy in meters (negative = invalid)
verticalAccuracyCLLocationAccuracyAltitude accuracy in meters
speedCLLocationSpeedMeters per second
courseCLLocationDirectionDegrees relative to true north
timestampDateWhen the location was determined
floorCLFloor?Floor of a building, if available
sourceInformationCLLocationSourceInformation?Info about the location source

Power Optimization Guidelines

Choose the most power-efficient service for your use case:

  1. Visits service (startMonitoringVisits()) — Most power-efficient. Reports places visited and time spent. Good for: check-in apps, travel logs.
  2. Significant-change service (startMonitoringSignificantLocationChanges()) — Low power, uses Wi-Fi/cellular only. Good for: approximate location tracking.
  3. Standard location service (startUpdatingLocation()) — Configurable accuracy via desiredAccuracy. Good for: navigation, fitness tracking.
  4. Live updates (CLLocationUpdate.liveUpdates()) — Modern async API with configurable activity types. Good for: any new project on iOS 17+.

Desired Accuracy Constants

ConstantDescription
kCLLocationAccuracyBestForNavigationHighest precision, most power
kCLLocationAccuracyBestBest available accuracy
kCLLocationAccuracyNearestTenMetersWithin ~10 meters
kCLLocationAccuracyHundredMetersWithin ~100 meters
kCLLocationAccuracyKilometerWithin ~1 km
kCLLocationAccuracyThreeKilometersWithin ~3 km
kCLLocationAccuracyReducedDeliberately reduced accuracy

Platform Considerations

  • visionOS: Location services are limited. Background updates are not supported. Region monitoring methods do nothing for compatible iPad/iPhone apps running in visionOS.
  • macOS: Apps are not suspended in background, so no special background capability needed.
  • watchOS: Supports background location with capability. Use CLBackgroundActivitySession.
  • Widgets: Check isAuthorizedForWidgetUpdates for widget eligibility.

Common Pitfalls

  • Always check horizontalAccuracy — negative values mean the coordinate is invalid.
  • Do not assume location is immediately available after starting services.
  • Handle authorization changes gracefully; users can revoke at any time via Settings.
  • Geocoder requests are rate-limited; cache results and do not geocode on every location update.
  • The system can pause location updates automatically. Set pausesLocationUpdatesAutomatically and activityType to help CoreLocation make good decisions.
  • For background updates on iOS: add the "Location updates" background mode capability AND set allowsBackgroundLocationUpdates = true on the location manager.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.37%
按下载量换算101

Claude

31.24%
按下载量换算95

Cursor

19.16%
按下载量换算58

Gemini CLI

8.37%
按下载量换算25

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills