Skip to content
A location service which A) authorizes location use and B) fetches the location name. Written in Swift 4.
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


LocationService is a simple, drop-in location manager for iOS written in Swift 4.

It does two things:

  1. Handles authorization
  2. Fetches the name of a user's current location

It is written so whichever object holds reference to the service (a ViewController, ViewModel, etc) does not have to import CoreLocation or its delegate methods.

It can be expanded upon and improved -- please feel free to submit a pull request if you have changes that make it better!



For authorization, it only accepts When In Use as being properly authorized.
You can customize this yourself in the CLLocationManagerDelegate method.

Location Name

The service defaults to fetching the subLocality and locality as its first priority. It then goes futher up the location hierarchy, until country. If it can't fetch any of the above, it errors out.
These priorities can be changed in LocationService's reverseGeocode(...) method.

Example Usage

final class ViewController: UIViewController {

	let locationService = LocationService()

	var locationName: String? 

// ... 

	func requestLocationName() {

		locationService.requestLocationName({ locationName, error in
			if let name = locationName {
				self.locationName = name
			} else if let error = error {
				// Handle error here

You can’t perform that action at this time.