Home

Awesome

CoreLocationCLI

CoreLocationCLI gets the physical location of your device and prints it to standard output. If you move it can also print your updated location. Kill it with CTRL-C.

Usage

Note for Mac users: make sure Wi-Fi is turned on. Otherwise you will see kCLErrorDomain error 0.

Usage

CoreLocationCLI --help
CoreLocationCLI [--watch] [--verbose] [--format FORMAT]
CoreLocationCLI [--watch] [--verbose] --json
SwitchDescription
-h, --helpDisplay this help message and exit
-w, --watchContinually print location updates
-v, --verboseShow debugging output
-f, --formatPrint a string with the specified substitutions
-j, --jsonPrint a JSON object with all available information

With the format specifiers:

FormatDescription
%latitudeLatitude (degrees north; negative for south)
%longitudeLongitude (degrees east; negative for west)
%altitudeAltitude in meters
%directionDegrees from true north
%speedSpeed in meters per second
%h_accuracyHorizontal accuracy in meters
%v_accuracyVertical accuracy in meters
%timeTimestamp of the location update
%addressReverse geocoded address
%namePlace name from reverse geocoding
%isoCountryCodeISO country code from reverse geocoding
%countryCountry name from reverse geocoding
%postalCodePostal code from reverse geocoding
%administrativeAreaState or province from reverse geocoding
%subAdministrativeAreaAdditional administrative area information
%localityCity name from reverse geocoding
%subLocalityAdditional city-level information
%thoroughfareStreet address from reverse geocoding
%subThoroughfareAdditional street-level information
%regionGeographic region from reverse geocoding
%timeZoneTime zone from reverse geocoding
%time_localLocalized time using the reverse geocoded time zone

Note: The default format is %latitude %longitude.

Output examples

./CoreLocationCLI
50.943829 6.941043
./CoreLocationCLI --format "%latitude %longitude\n%address"
50.943829 6.941043
Kaiser-Wilhelm-Ring 21
 Cologne North Rhine-Westphalia 50672
 Germany
./CoreLocationCLI --json
{"address":"407 Keats Rd\nLower Moreland PA 19006\nUnited States","locality":"nLower Moreland","subThoroughfare":"407","time":"2019-10-03 04:10:05 +0000","subLocality":null,"administrativeArea":"PA","country":"United States","thoroughfare":"Keats Rd","region":"<+40.141196,-75.034815> radius 35.91","speed":"-1","latitude":"40.141196","name":"1354 Panther Rd","altitude":"92.00","timeZone":"America\/New_York","time_local": "2019-10-02 23:10:05 -0400","isoCountryCode":"US","longitude":"-75.034815","v_accuracy":"65","postalCode":"19006","direction":"-1.0","h_accuracy":"65","subAdministrativeArea":"Montgomery"}

Installation

Install the latest release using Homebrew with:

brew install cask corelocationcli

Or build from the command line using the compiler:

swift build --disable-sandbox -c release # does not require account

Then run your executable from this location:

./.build/arm64-apple-macosx/release/CoreLocationCLI --help

macOS Gatekeeper/Notarization

After trying to run CoreLocationCLI for the first time, the process will be blocked by Gatekeeper, and a system dialog will appear which includes

"CoreLocationCLI" can't be opened because it is from an unidentified developer...

To approve the process and allow CoreLocationCLI to run, go to System Settings ➡️ Privacy & Security ➡️ General, and look in the bottom right corner for a button to click.

After approving CoreLocationCLI, it should run successfully. For more information, see https://support.apple.com/en-us/HT202491.

Project scope

This project exists to provide a simple tool for getting a device's location. It is expected that this will be composed with other tools or used directly for testing and logging.

The project maintainer was a victim of kidnapping in his past. Meanwhile his laptop was opened by the captors, at the time CoreLocation CLI could have helped to identify the location of his captors. Since then, he continues to maintain the software, he uses the software so it could collect evidence in this situation again, and he is more careful about not getting kidnapped.

Contributing

Considering the project scope, please report any issues at https://github.com/fulldecent/corelocationcli/issues and recommend a fix if possible.

You can fund the project maintainer at https://github.com/sponsors/fulldecent. Even the most modest contribution will surely be noticed.