CoreLocation: startUpdateLocation is unavailable

Hi,


I'm in the process of moving CoreLocation logic from my iPhone app to my WatchOS app but get compile errors for startUpdateLocation stating it's unavailable.

The actual compile error reads:

CoreLocation.CLLocationManager:53:14: note: 'startUpdatingLocation()' has been explicitly marked unavailable here

@objc func startUpdatingLocation()


What's the recommended way to get location updates for WatchOS extensions?


Cheers,

Kristoffer

There is a "What's New in Core Location" talk on Thursday afternoon at 1:30pm (San Francisco time), that says "Discover how to use Core Location with Apple Watch", so it's probably worth waiting for that.

Thanks for the tip! Hopefully the slides will be available shortly after the session as I'm not in SF.

The Apple website says that they will be "posting videos of all sessions throughout the week of the conference", which is promising.


I'm amazed that they post them so quickly these days (I remember having to wait weeks) but I'm still optimisticly hoping that both the videos and the slides will appear overnight each day. I have been watching the live streams today when I can, but the Core Location talk on Thursday is not in the Presidio, so unlikely to be streamed.

Weeks? Luxury! I remember when we had to Order the DVDs at WWDC and wait until the following year to get them. (No, really!)

This sounds like a Radar to me. I am having the same issue. I had compiled this for the WatchKit Extension under iOS 8 + WK. I'm guessing there is a bit of unimplemented foo between the seed 1 release and the conference demo seed (Usually a few builds later)


Work around seems to be temporarily to move that functionality over to the iOS app and WatchComm it across.

After a little digging; I looked at the headers in the SDK under the WatchSimulator.


This call and several other calls and properties throughout CoreLoc are marked: __WATCHOS_PROHIBITED


I'm not sure if this is just incomplete as of Dev Seed 1 or if there is an undocumented logic at play.

I also see this on CLLocation.speed and .course


So it's possible these are NYI. Hopefully we get more on Thursday

Accepted Answer

The watchOS developer library has a PotLoc sample which is sample code for using CoreLocation. https://developer.apple.com/library/prerelease/watchos/samplecode/PotLoc/Introduction/Intro.html#//apple_ref/doc/uid/TP40016176


In particular, use manager.requestLocation() and then implement the delegate method

optional func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [AnyObject])

I looked at using requestLocation but as that only performs one request rather than continous requests I was hoping there would be another way as I share the code for both the iPhone and Watch app.

I use a distance filter that only gives me locations when I've moved a certain distance which is really convenient so I guess I need to implement a similar setup for the watch, or as suggested above keep location functionality on the phone.

Benj4, might you be able to use an NSTimer event to call requestLocation? That doesn't help with distance filtering, but you could set it to every second or two and at least you'd get an update that way.

Watched the CoreLocation session video today and the correct way for periodic updates is to use WCSession from the watch to request the phone to do the location tracking.

As I already have a working iPhone app doing this I just have to create a simple interface my watch app can use to start/stop tracking.

CoreLocation: startUpdateLocation is unavailable
 
 
Q