[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6966":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":16,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":29,"readmeContent":30,"aiSummary":31,"trendingCount":16,"starSnapshotCount":16,"syncStatus":32,"lastSyncTime":33,"discoverSource":34},6966,"SwiftLocation","malcommac\u002FSwiftLocation","malcommac","⚓️ Async\u002FAwait CLLocationManager Wrapper for Apple Platforms","",null,"Swift",3430,429,85,4,0,59.9,"MIT License",false,"master",true,[23,24,25,26,27,28],"cllocationmanager","location-services","locationtracking","swift","swift-library","swiftlang","2026-06-12 04:00:31","\u003Cp align=\"center\">\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\".\u002Fassets\u002Fswiftlocation-dark.png\" width=\"350\">\n  \u003Cimg alt=\"logo-library\" src=\".\u002Fassets\u002Fswiftlocation-light.png\" width=\"350\">\n\u003C\u002Fpicture>\n\u003C\u002Fp>\n\n[![Platform](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPlatforms-iOS%20%7C%20macOS%20%7C%20watchOS%20%7C%20tvOS%20-4E4E4E.svg?colorA=28a745)](#installation)\n[![Swift](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSwift-5.3_5.4_5.5_5.6-orange?style=flat-square)](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSwift-5.5_5.6_5.7_5.8_5.9-Orange?style=flat-square)\n[![Swift Package Manager](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSwift_Package_Manager-compatible-orange?style=flat-square)](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSwift_Package_Manager-compatible-orange?style=flat-square)\n\n**SwiftLocation is a lightweight wrapper around Apple's CoreLocation framework that supports the new Swift Concurrency model.**  \n\n*This means **no more delegate pattern to deal with, nor completion blocks**.  \nYou can manage location requests, region, and beacon monitoring directly using the new async\u002Fawait syntax.*\n\nWould you, for example, get the current user location?  \n*It's just 2 lines code away:*\n\n```swift\ntry await location.requestPermission(.whenInUse) \u002F\u002F obtain the permissions\nlet userLocation = try await location.requestLocation() \u002F\u002F get the location\n```\n\n# How it works\n\nSwiftLocation is quite straightforward to use.  \nSimply create your own `Location` instance and use one of the available methods.\n\n> [!IMPORTANT]  \n> Some APIs may not available under some of the supported platforms due to specific hardware constraints.\n\n- [How it works](#how-it-works)\n  - [What's new in 6.0](#whats-new-in-60)\n  - [Service Location Status](#service-location-status)\n  - [Authorization Status](#authorization-status)\n  - [Accuracy Authorization Level](#accuracy-authorization-level)\n  - [Request Location Permission](#request-location-permission)\n    - [Provide descriptions of how you use location services](#provide-descriptions-of-how-you-use-location-services)\n  - [Request Temporary Precision Permission](#request-temporary-precision-permission)\n  - [Continous Location Monitoring](#continous-location-monitoring)\n  - [Request One-Shot User Location](#request-one-shot-user-location)\n  - [Visits Monitoring](#visits-monitoring)\n  - [Significant Location Changes Monitoring](#significant-location-changes-monitoring)\n  - [Device Heading Monitoring](#device-heading-monitoring)\n  - [Beacon Ranging](#beacon-ranging)\n- [Testing Suite \\&  Mocked CLLocationManager](#testing-suite---mocked-cllocationmanager)\n- [Installation via SPM](#installation-via-spm)\n- [Support This Work ❤️](#support-this-work-️)\n- [License](#license)\n- [Contributing](#contributing)\n\n## What's new in 6.0\n\nThe new 6.0 milestone is a completely rewritten version designed to support async\u002Fawait optimally. We are also focused on supporting all CoreLocation features without creating an overwhelmed package.  \nAll the features are supported by a complete unit tests suite.\n\nThis new version is also distributed only via Swift Package Manager (5.5+) and it's compatible with all the Apple Platforms: iOS 14+, macOS 11+, watchOS 7+, tvOS 14+.\n\n*The features from version 5.x - geocoding, ip resolve, autocomplete - will be included as separate downloadable modules later in the development process.*\n\n## Service Location Status\n\nUse the `location.locationServicesEnabled` to get the current status of the location services.  \nIn order to monitor changes you can use the `AsyncStream`'s startMonitoringLocationServices()` method:\n\n```swift\nfor await event in await location.startMonitoringLocationServices() {\n print(\"Location Services are \\(event.isLocationEnabled ? \"enabled\" : \"disabled\")\"\n \u002F\u002F break to interrupt the stream\n}\n```\n\nYou can stop the stream at any moment using `break`; it will call the `stopMonitoringLocationServices()` automatically on used `Location`` instance.\n\n## Authorization Status\n\nYou can obtain the current status of the authorization status by using the `location.authorizationStatus` property.  \nIf you need to monitor changes to this value you can use the `AsyncStream` offered by `startMonitoringAuthorization()` method:\n\n```swift\nfor await event in await location.startMonitoringAuthorization() {\n  print(\"Authorization status did change: \\(event.authorizationStatus)\")\n  \u002F\u002F break to interrupt the stream\n}\n```\n\n## Accuracy Authorization Level\n\nThe `location.accuracyAuthorization` offers a one shot value of the current precision level offered by your application.  \nWhen you need to monitor changes you can use the `AsyncStream` offered by `startMonitoringAccuracyAuthorization()`:\n\n```swift\nfor await event in await location.startMonitoringAccuracyAuthorization() {\n  print(\"Accuracy authorization did change: \\(event.accuracyAuthorization.description)\")\n  \u002F\u002F break to interrupt the stream\n}\n```\n\n## Request Location Permission\n\nAlso the request location permission is managed via async await. You can use the `requestPermission()` method once you have properly configured your `Info.plist` file:\n\n```swift\n\u002F\u002F return obtained CLAuthorizationStatus level\nlet obtaninedStatus = try await location.requestPermission(.whenInUse)\n```\n\n### Provide descriptions of how you use location services\n\nThe first time you make an authorization request, the system displays an alert asking the person to grant or deny the request. The alert includes a usage description string that explains why you want access to location data.  \n\nYou provide this string in your app’s Info.plist file and use it to inform people about how your app uses location data.\n\nCore Location supports different usage strings for each access level. You must include a usage description string for When in Use access. If your app supports Always access, provide an additional string explaining why you want the elevated privileges. The following table lists the keys to include in your Info.plist and when to include them.\n\n| Usage key                                                 | Required when:                                                                   |\n|-----------------------------------------------------------|----------------------------------------------------------------------------------|\n| `NSLocationWhenInUseUsageDescription`              | The app requests When in Use or Always authorization.                            |\n| `NSLocationAlwaysAndWhenInUseUsageDescription` | The app requests Always authorization.                                           |\n| `NSLocationTemporaryUsageDescriptionDictionary`             | Used when you want to temporary extend the precision of your authorization level |\n|                                                           |                                                                                  |\n\n## Request Temporary Precision Permission\n\nIf the App does not require an exact location for all of its features, but it is required to have accurate one only for specific features (i.e during checkout, booking service, etc) — then App may ask for temporary accuracy level for that session only using the `requestTemporaryPrecisionAuthorization(purpose:)` method:\n\n```swift\n\u002F\u002F return CLAccuracyAuthorization value\nlet status = try await location.requestTemporaryPrecisionAuthorization(purpose: \"booking\")\n```\n\n## Continous Location Monitoring\n\nIf you need to continous monitoring new locations from user's device you can use the `AsyncStream` offered by `startMonitoringLocations()`:\n\n```swift\nfor await event in try await location.startMonitoringLocations() {\n    switch event {\n    case .didPaused:\n\t\u002F\u002F location updates paused\n    case .didResume:\n    \u002F\u002F location updates resumed\n    case let .didUpdateLocations(locations):\n    \u002F\u002F new locations received   \n    case let .didFailed(error):\n    \u002F\u002F an error has occurred   \n    }\n    \u002F\u002F break to stop the stream\n}\n```\n\n## Request One-Shot User Location\n\nSometimes you may need to get the user location as single value. The async's `requestLocation(accuracy:timeout:)` method was created to return an optionally filtered location within a valid time interval:\n\n```swift\n\u002F\u002F Simple implementation to get the last user location\nlet location = try await location.requestLocation()\n\n\u002F\u002F Optionally you can return a value only if satisfy one or more constraints\nlet location = try await location.requestLocation(accuracy: [\n    .horizontal(100) \u002F\u002F has an horizontal accuracy of 100 meters or lower\n], timeout: 8) \u002F\u002F wait for response for a max of 8 seconds\n```\n\nFilters include horizontal\u002Fvertical, speed, course accuracy and it offer the opportunity to set a custom filter functions as callback.\n\n## Visits Monitoring\n\nVisits monitoring allows you to observe places that the user has been.  \nVisit objects are created by the system and delivered by the CLLocationManager. \nThe visit includes the location where the visit occurred and information about the arrival and departure times as relevant.\n\nTo monitor visits you can use the `AsyncStream`'s `startMonitoringVisits()` method:\n\n```swift\nfor await event in await location.startMonitoringVisits() {\n    switch event {\n    case let .didVisit(place):\n    \u002F\u002F a new CLVisit object has been received.   \n    case let .didFailWithError(error):\n    \u002F\u002F an error has occurred\n    }\n}\n```\n\n## Significant Location Changes Monitoring\n\nThe `AsyncStream`'s `startMonitoringSignificantLocationChanges()` method starts the generation of updates based on significant location changes.\n\n```swift\nfor await event in await self.location.startMonitoringSignificantLocationChanges() {\n    switch event {\n    case .didPaused:\n    \u002F\u002F stream paused\n    case .didResume:\n    \u002F\u002F stream resumed\n    case .didUpdateLocations(locations):\n    \u002F\u002F new locations received\n    case let .didFailWithError(error):\n    \u002F\u002F an error has occured\n    }\n\t\u002F\u002F break to stop the stream\n}\n```\n\n## Device Heading Monitoring\n\nTo get updates about the current device's heading use the `AsyncStream` offered by `startUpdatingHeading()` method:\n\n```swift\nfor await event in await self.location.startUpdatingHeading() {\n\t\u002F\u002F a new heading value has been generated\n}\n```\n\n## Beacon Ranging\n\nBeacon ranging is offered by the `AsyncStream`'s `startRangingBeacons()` method:\n\n```swift\nlet constraint: CLBeaconIdentityConstraint = ...\nfor await event in await location.startRangingBeacons(satisfying: constraint) {\n\t\u002F\u002F a new event has been generated\n}\n```\n\n# Testing Suite &  Mocked CLLocationManager\n\nSwiftLocation is distribuited with an extensive unit testing suite you can found into the `SwiftLocationTests` folder.  \nInside the suite you will also found the `MockedLocationManager.swift` file which is a `CLLocationManager` mock class you can use to provide the testing suite for your application. By configuring and extending this file you will be able to mock results of location requests and monitoring directly in your host app.\n\n\n# Installation via SPM\n\nSwiftLocation is offered via Swift Package Manager.  \nAdd it as a dependency in a Swift Package, and add it to your `Package.swift`:\n\n```swift\ndependencies: [\n  .package(url: \"https:\u002F\u002Fgithub.com\u002Fmalcommac\u002FSwiftLocation.git\", from: \"6.0.0\")\n]\n```\n# Support This Work ❤️\n\nIf you love this library and wanna encourage further development **consider becoming a sponsor of my work** via [Github Sponsorship](https:\u002F\u002Fgithub.com\u002Fsponsors\u002Fmalcommac).  \n\n# License\n\nThis package was created and maintaned by [Daniele Margutti](https:\u002F\u002Fgithub.com\u002Fmalcommac).  \n\n- [LinkedIn Profile](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fdanielemargutti\u002F)\n- [X\u002FTwitter](http:\u002F\u002Ftwitter.com\u002Fdanielemargutti)\n- [Website](https:\u002F\u002Fwww.danielemargutti.com)\n\nIt was distribuited using [MIT License](https:\u002F\u002Fgithub.com\u002Fmalcommac\u002FSwiftLocation\u002Fblob\u002Fmaster\u002FLICENSE.md).\n\n# Contributing\n\n- If you need help or you'd like to ask a general question, open an issue.\n- If you found a bug, open an issue.\n- If you have a feature request, open an issue.\n- If you want to contribute, submit a pull request.\n\nRead the [CONTRIBUTING](CONTRIBUTING.md) file for more informations.\n","SwiftLocation 是一个轻量级的 Apple CoreLocation 框架封装，支持新的 Swift 并发模型。项目核心功能包括通过 async\u002Fawait 语法简化位置请求、区域和信标监控的处理过程，摒弃了传统的代理模式与完成闭包。适用于 iOS、macOS、watchOS 和 tvOS 等苹果平台上的应用开发，特别是需要高效且简洁地实现地理位置相关功能的应用场景。无论是获取用户当前位置还是进行持续的位置跟踪，开发者都能以更直观的方式编写代码，从而提高开发效率并减少错误。",2,"2026-06-11 03:09:53","top_language"]