Is it possible to get the 'live' current l

2020-03-05 09:51发布

问题:

I'm trying to test out my location code with an iOS Simulator.

How can I make the iOS simulator use my -real- current location? So for example, i'm on a train using my MBP connected to the interwebs via my iPhone teathering. I then run the iOS Simulator and double click on my App.

Now .. as the train moves, I wish to see my lat/long coords change in my labels / console output. I'm not after code (i've done all that)... just not sure how to tell the iOS Simulator to use the real live location stuff.

I know the iOS simulator has the Debug->Location-> stuff -which is what i've been using so far.

Secondly, I understand that a MPB doesn't have a GPS (per say) but it DOES have Location aware services ... meaning it can (magically) guess a lat/long .. which i was hoping the iOS Simulator might leverage.

here's a screenie of an app I have installed on my MPB that does (correctly) get a good guess Lat/Long.

So is there another way I can get this to work?

UPDATE:

Is the correct answer here => do not use the iOS Simulator but run the code in `DEBUG|iPhone' active configuration .. which means (I hope I have this right..) I need to connect my iPhone to my MBP via the usb cable .. and then it deploys my app over the usb cable, to my iPhone .. and then uses the iPhone as the hardware device .. which include the GPS in it?

eg...

回答1:

iPhone Simulator does exactly that, it simulates your Geo location. By itself it doesn't know in real life where you are and hence cannot give you real coordinates.

In terms of documentation of what these functions do, I got this from Apple docs.

Location

Allows you to set the Core Location to be used by your app. Choose from the different location settings:

  • None. Does not return a location. Use for testing how an app responds when no location data is available.

  • Custom Location. Allows use of a custom latitude and longitude. Apple Stores. Uses the coordinates for an Apple Retail Store.

  • Apple. Uses the coordinates of the Apple Headquarters.

  • City Bicycle Ride. Simulates a bike ride in Cupertino, CA. This option simulates the device moving on a predefined route.

  • City Run. Simulates a run in Cupertino, CA. This option simulates the device moving on a predefined route.

  • Freeway Drive. Simulates a drive through Cupertino, CA. This option simulates the device moving on a predefined route.

You can read more about it here.