SwiftLocation:功能完善的位置管理及简单易用的 Beacon 监视器

SwiftLocation:功能完善的位置管理及简单易用的 Beacon 监视器 - 敏捷大拇指 - SwiftLocation:功能完善的位置管理及简单易用的 Beacon 监视器


Easy Location Services and Beacon Monitoring for Swift

SwiftLocation is a lightweight library you can use to monitor locations, make reverse geocoding (both with Apple and Google's services) monitor beacons and do beacon advertising. It's really easy to use and it's compatible both with Swift 2.2, 2.3 and 3.0.


Pick the right version:

  • Official Swift 2.2 is in master (and develop)
  • Swift 2.3 branch ishere.
  • Swift 3.0 branch ishere.
  • Old unsupported Swift 2.0 branch is here

Main features includes:

  • Auto Management of hardware resources : SwiftLocation turns off hardware if not used by our observers. Don't worry, we take care of your user's battery usage!
  • Complete location monitoring: you can easily monitor for your desired accuracy and frequency (continous monitoring, background monitoring, monitor by distance intervals, interesting places or significant locations).
  • Device's heading observer : you can observe or get current device's heading easily
  • Reverse geocoding (from address string/coordinates to placemark) using both Apple and Google services (with support for API key)
  • GPS-less location fetching using network IP address
  • Geographic region monitoring (enter/exit from regions)
  • Beacon Family and Beacon monitoring
  • Set a device to act like a Beacon (only in foreground)


Before using SwiftLocation you must configure your project to use location services. First of all you need to specify a value for NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription into your application's Info.plist file. The string value you add will be shown along with the authorization request the first time your app will try to use location services hardware.

If you need background monitoring you should specify NSLocationAlwaysUsageDescription and specify the correct value in UIBackgroundModes key (you can learn more here )

SwiftLocation in your next big project? Tell it to me!

I'm collecting all the apps which uses SwiftLocation to manage beacon or location. If you are using SwiftLocation in your project please fill a PR to this file or send an email to hello@danielemargutti.com .

From SwiftLocation 0.x to 1.0

Several changes are made from 0.x branch to 1.0 especially from the side of the location manager. It's pretty easy to align your project with this news version. Since 1.0 we will keep the API stable and any change will use @available metatag of Swift to keep you in track.

Changes are:

Renamed Methods

  • LocationManager.shared. is now replaced by Location.
  • BeaconManager.shared. is now replaced by Beacon.
  • Each request is conform to Request protocol. Where allowed you can use start() , pause() or cancel() a running request.
  • observeLocations() is now replaced with getLocation() (and it allows you to specify a custom timeout)
  • observeInterestingPlaces() is now replaced with getInterestingPlaces()
  • Reverse geocoding services are now under the reverse function umbrella ( reverse(location:...), reverse(address:... and reverse(coordinates:...) )

Other Changes

  • Accuracy now include IP Address Scan ( .IPScan ) to get the current location ( locateByIPAddress() was removed). It works as usual, without asking sensor authorization to the user.
  • observeHeading() is now replaced with getHeading . Heading services now works correctly and allow you to specify a frequency ( HeadingFrequency : .Continous(interval) to receive new heading at specified time intervals; .TrueNorth(minDegree) and .MagneticNorth(minDegree) allows you to receive events only when a specified deviation from the last catched heading is reported).
  • Hea