Open jedberg opened 1 year ago
I see the same issue on 13.5.1. 2023 MacBook Pro, M2Max
Same issue on 13.5.2. 2023 M2 Max.
This issue persists on 14.1.1 unfortunately - cannot get location.
Same issue on 14.1.2
same issue on macOS Sonoma 14.2.1
Trying to compile source code didn't change anything. I will try to follow this workaround and see if it does anything.
EDIT :
Impossible for me to replace the /var/db/locationd/clients.plist file (operation not permited even through a sudo su shell) After getting into recovery mode to get a superuser shell, and replacing the file, it was automatically rolled back to original after a reboot. Maybe did something wrong with my clients.plist file ?...
Anyway
I found a workaround using applescripting:
Implement core CLLocationManager module, ask for location rights, querry the location of the device once () and compile the script to an app with File > Export. You now have your MyApp.app. From there, run your app a first time, grant access to location, and from a terminal call /myapp.app/Contents/MacOS/applet to get your lat/long printed out
Could you please provide me with the AppleScript?
Could you please provide me with the AppleScript?
Sorry for the delayed response, Here`s the apple script that I found here.
You need to export it with the App format, then launch it a first time as an app, and allow it to access your location. From here, you can use the embedded script through your terminal (.../yourapp.app/Contents/MacOS/applet)
Note that it outputs your coordinates through an error that you can filter using regex.
use framework "CoreLocation"
use framework "Foundation"
use scripting additions
property this : a reference to the current application
property nil : a reference to missing value
property _1 : a reference to reference
property CLLocationManager : a reference to CLLocationManager of this
property kCLLocationAccuracyBest : a reference to 3000.0
--------------------------------------------------------------------------------
property running : false
property result : missing value -- Lat./long. or error description
property number : 0 -- Error code
property seconds : 10 -- Maximum time to allow script to run
--------------------------------------------------------------------------------
# IMPLEMENTATION:
my performSelectorOnMainThread:"getLocation" withObject:nil waitUntilDone:true
return my result
--------------------------------------------------------------------------------
# HANDLERS & SCRIPT OBJECTS:
to getLocation()
set locationManager to CLLocationManager's new()
locationManager's setDelegate:me
locationManager's setDesiredAccuracy:kCLLocationAccuracyBest
set my running to true
set started to current date
locationManager's startUpdatingLocation()
repeat while my running
delay 0.5
if (current date) - started > my seconds then exit repeat
end repeat
end getLocation
on locationManager:locationManager didUpdateLocations:locations
local locationManager, locations
locationManager's stopUpdatingLocation()
set my running to false
set my result to (locations's valueForKey:"coordinate") as record
set coordinateText to "{" & quoted form of ("latitude:" & (my result's latitude) & ", longitude:" & (my result's longitude)) & "}"
do shell script "echo " & coordinateText
end locationManager:didUpdateLocations:
on locationManager:locationManager didFailWithError:err
local locationManager, err
tell err's code()
set my number to it
set my result to item (it + 1) in my enum's kCLError
set my running to false
end tell
end locationManager:didFailWithError:
script enum
property kCLError : {¬
"Location Unknown", ¬
"Denied", ¬
"Network", ¬
"Heading Failure", ¬
"Region Monitoring Denied", ¬
"Region Monitoring Failure", ¬
"Region Monitoring Setup Delayed", ¬
"Region Monitoring Response Delayed", ¬
"Geocode Found No Result", ¬
"Geocode Found Partial Result", ¬
"Geocode Canceled", ¬
"Deferred Failed", ¬
"Deferred Not Updating Location", ¬
"Deferred Accuracy Too Low", ¬
"Deferred Distance Filtered", ¬
"Deferred Canceled", ¬
"Ranging Unavailable", ¬
"Ranging Failure"}
property CLAuthorizationStatus : {¬
"Not Determined", ¬
"Restricted", ¬
"Denied", ¬
"Authorized (Always)", ¬
"Authorized When In Use"}
end script
---------------------------------------------------------------------------❮END❯
I tried your script approach, and the best I can get after reviewing all your instructions is "Denied"
This seems like a major issue for Apple developers... is it even possible to get the Location from a CLI? Does there need to be a application server setup to accept and run in the background the only way to access the Location API now?
I tried your script approach, and the best I can get after reviewing all your instructions is "Denied"
This seems like a major issue for Apple developers... is it even possible to get the Location from a CLI? Does there need to be a application server setup to accept and run in the background the only way to access the Location API now?
Make sure you set keys Authorized, Whitelisted for /usr/local/Caskroom/corelocationcli/4.0.2/CoreLocationCLI record. With this danger in mind I finally made it work on my Sonoma 14.3.1, service isn't listed in location services though 🤔
Instead of hacking, I am suggesting that my users install this command-line accessible tool:
Instead of hacking, I am suggesting that my users install this command-line accessible tool:
Hi. And how do you set up location with your tool? My understanding it is just for quering various types of info from location API, but not for setting location.
You need to export it with the App format, then launch it a first time as an app, and allow it to access your location. From here, you can use the embedded script through your terminal (.../yourapp.app/Contents/MacOS/applet)
@PTac-h This script works great and taught me some things about AppleScript but I'm stuck on actually getting the location output in a useful format.
When I run that in the Script Editor I get the coordinates, and when I run the .app directly from Finder I can authorize the app and see that it works. I can run getLocation.app/Contents/MacOS/applet
without a permission error... but the trouble is that running it in that way produces no output! I can't get any log "..."
lines to appear in stdout/stderr when running the .app.
My current janky workaround is to just write the lat/lng to a file and read that..but that's non-ideal. How are you able to read the output directly from the packaged .app?
Also experiencing this issue. Is this app still being maintained?
Resigned and reuploaded https://github.com/Homebrew/homebrew-cask/pull/192209/files
Resigned and reuploaded https://github.com/Homebrew/homebrew-cask/pull/192209/files
Thanks for this @fulldecent. Unfortunately updating to 4.0.3
via Homebrew didn't fix the issue. There still isn't a way to enable location services for CoreLocationCLI because it doesn't appear on the list.
Workaround (Ventura, Intel): as before, I've used Platypus to create an app bundle from CoreLocationCLI
, named the app CoreLocationCLI, deep-codesigned the bundle with an Apple Development certificate, which you can get through Xcode—but maybe an ad-hoc signature also works—, launched the app once, and it shows up in System Settings > Privacy & Security > Privacy > Location Services, where I can enable it, if it isn't already. (In my case, it was already enabled, because I had used the trick before.) Then I just ran ln -s /usr/local/Caskroom/corelocationcli/app/CoreLocationCLI.app/Contents/Resources/script /usr/local/bin/CoreLocationCLI
and replaced Homebrew's symlink of CoreLocationCLI, and it's available in Terminal and shell scripts.
It's basically what locatinator seems to do: for working location services, you need an app around the command line tool to use the latter, with the app being either signed & notarized, if you want to distribute it, or at least signed locally with a dev or ad-hoc signature.
Maybe there is there a way to get this into Homebrew too, while linking so the command line is still in the right spot
If the Homebrew caskroom allows for a post-install script, you could distribute the app as an unsigned bundle, then (after installation) ad-hoc sign the app, link the command line tool into the relevant bin directory, and launch the app once to register it with the system, so the user can enable (reenable) it in Location Services.
It might also be possible to put the CoreLocationCLI into the app's Resources folder as an autonomous file, and use the app itself only to deliver a prompt for the users to notify them that they need to enable Location Services for the app and its embedded command line tool. (This could be done with a simple shell script using osascript
… and it's dead easy to build an app from a shell script with Platypus. Of course you can always tweak it with a nice icon, version number in the Info.plist etc. 😉)
I just upgraded to MacOs Sonoma 14.0 Beta (23A5286i). I've been running corelocationCli for many years, and usually when I upgrade OSs I have to reinstall it using Brew. However this time was different.
At first it actually worked just fine for a day. Then it stopped working, and I was getting "The operation couldn’t be completed. (kCLErrorDomain error 0.)" despite wifi being on.
In an attempt to fix the issue, I did my usual of running 'brew reinstall --cask corelocationcli' (so I have the latest version as of 7/18/2023)
Now I'm getting "Location services are disabled or location access denied. Please visit System Preferences > Security & Privacy > Privacy > Location Services"
However, Location services are on. But also, CoreLocationCLI is no longer in the list of things I can enable.
Thanks!