Core Location

Obtain the geographic location and orientation of a device.


Core Location provides services for determining a device’s geographic location, altitude, orientation, or position relative to a nearby iBeacon. The framework uses all available onboard hardware, including Wi-Fi, GPS, Bluetooth, magnetometer, barometer, and cellular hardware to gather data.

The first time that your app requests authorization, its authorization status is indeterminate and the system prompts the user to grant or deny the request (as shown in Figure 1). The system records the user's response and does not display this panel upon subsequent requests.

Figure 1

Requesting authorization to use location services

Requesting authorization to use location services

After requesting permission and determining whether services are available, you start most services using the CLLocationManager object and receive the results in your associated delegate object.


First Steps

Before gathering location data, you must ask for permission to use location services and determine the availability of those services on the current device.

Choosing the Authorization Level for Location Services

Choose the appropriate level of access to location data for your app.

Determining the Availability of Location Services

Determine which location services are active and available on the user’s device.

class CLLocationManager

The object that you use to start and stop the delivery of location-related events to your app.

protocol CLLocationManagerDelegate

The methods that you use to receive events from an associated location manager object.

Location Updates

Getting the User's Location

Learn how to receive location data in your app.

class CLLocation

The latitude, longitude, and course information reported by the system.

struct CLLocationCoordinate2D

The latitude and longitude associated with a location, specified using the WGS 84 reference frame.

class CLFloor

The floor of a building on which the user's device is located.

class CLVisit

Information about the user's location during a specific period of time.

Region Monitoring

Configure geofences and receive notifications when the user's device crosses the fence's boundaries.

Monitoring the User's Proximity to Geographic Regions

Use region monitoring to determine when the user enters or leaves a geographic region.

class CLCircularRegion

A circular geographic region, specified as a center point and radius.

class CLRegion

A base class representing an area that can be monitored.


Ranging for Beacons

Detect that the device is in a beacon region, then use ranging to find the beacons within the region.

Determining the Proximity to an iBeacon Device

Learn how to detect beacons and determine the relative distance to them.

Turning an iOS Device into an iBeacon Device

Learn how to broadcast iBeacon signals from an iOS device.

class CLBeacon

Information about an observed iBeacon and its relative distance to the user’s device.

class CLBeaconRegion

A region used to detect the presence of iBeacon devices.

Compass Headings

Determine the device’s orientation relative to magnetic or true north.

Getting Heading and Course Information

Use a device’s orientation and course information for navigation.

class CLHeading

The azimuth (orientation) of the user’s device, relative to true or magnetic north.


Converting Between Coordinates and User-Friendly Place Names

Convert between a latitude/longitude pair and a more user-friendly description of that location.

class CLGeocoder

An interface for converting between geographic coordinates and place names.

class CLPlacemark

A user-friendly description of a geographic coordinate, often containing the name of the place, its address, and other relevant information.


struct CLError

A Core Location error.

enum CLError.Code

Error codes returned by the location manager object.

let kCLErrorUserInfoAlternateRegionKey: String

A key in the user information dictionary of an error relating to a delayed region monitoring response.

let kCLErrorDomain: String

The domain for Core Location errors.


class CLBeaconIdentityConstraint

Identity characteristics that can match one or more beacons.


See Also

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software