I am using Xcode version 4.5.1 and OS X version 10.8.2.
I downloaded the CurrentAddress sample project (ver 1.2) and when I run it the first time it prompts "'CurAddress' Would you like to use your current location", to which I say OK. I cannot figure out from where the code is getting the location that it ends up using, which is in or near San Francisco, lat 37.7858, long -122.406. I have looked all over the project and cannot see where these values are coming from. Thanks for any help.
this comes from CLLocationManager, which either will get that data from the GPS sensor in your iphone device, or from the GPS simulation built in in iPhone Simulator.
San Francisco is the default GPS simulation track, near Apples Headquarter.
If you are running in simulator, go to simulator debug menu -> Location -> you can set any location here. If I am correct, your CLLocationManager should pick the current location in simulator from here. In device, it should pick the current location, if the same is enabled.
Related
I am testing a Xamarin Forms app on Android and iOS using Xamarin.UITest. Since the application depends on the GPS location, I need to set a fake location. I do this using
App.Device.SetLocation(latitude, longitude)
...where latitude and longitude are variables of type double which contain the desired coordinates.
This works fine on Android but fails on the iPhone Simulator with the following exception:
SetUp : Xamarin.UITest.XDB.Exceptions.DeviceAgentException : Unable to set location
ExitCode: 4
-d,--device-id <device-identifier> iOS Simulator GUID or 40-digit physical device ID
set-location <latitude,longitude>
Expected lat,lng: Got 48,135831,11,573423
I did some research and found a thread on the Xamarin Forums which says that it might help to round the fake coordinates to only 4 digits after the decimal point but it didn't help. Apart from that, I tried to hardcode the coordinates and to use floats instead of doubles but neither of the attempts worked.
What's going on there and how can it be fixed?
Here's my setup:
Xamarin.UITest version 2.2.4
iOS Simulator running iOS 9.3 on an iPhone 6
Host computer: Mac mini running MacOS High Sierra 10.13.6
The same issue occurred several months ago with the following setup:
Xamarin.UITest version 2.2.1
iOS Simulator running iOS 11.2 on an iPhone X
Host computer: Mac Mini running MacOS High Sierra (10.13.3)
At the time, I just left it alone, but now is the time where I need a fix.
Expected lat,lng: Got 48,135831,11,573423
It appears to be a bug in that Xamarin is using your local locale to convert those doubles to strings when they send them to simctl (and simctl is expecting decimal point-based strings or quoted decimals and thus it is parsing those are 4 separate numbers).
In your test code before setting the location, change the culture to en-US and set it back later to your actual culture if needed.
Something like this should work:
var currentCulture = CultureInfo.DefaultThreadCurrentCulture;
CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("en-US");"
// do some location setting / testing
CultureInfo.DefaultThreadCurrentCulture = currentCulture;
My App tracks your location.
With iOS8 I had to change how it was starting location services.
I got this working with
[self.locationManager requestAlwaysAuthorization];
and adding NSLocationAlwaysUsageDescription to the plist file.
The app now gets your location when run on a device, but not in the simulator.
Any clues on how to get this to work in the simulator? It used to!!!
In the iOS Simulator, select Debug > Location, then choose your location.
I decided to post this in case anyone else had the same issue. I got the simulator to respond to location changes again by adding NSLocationWhenInUseUsageDescription back into the plist file. I had removed it since my app needs the Always permission instead of WhenInUse. By adding this back to the plist the simulator is now happy. I did not have this issue on the physical device, just the simulator.
I've made Appcelerator Titanium Module for fetching device's rotaion and location. Source can be found on GitHub.
The problem is that it fetches only one cached location but device motion data is OK and it is refreshing.
I don't use delegate, I pull that data in my Titanium Javascript Code.
If I set "City Run" in Simulator -> Debug -> Location nothing happens. The same cached location is returning.
Pulling of location is OK because I tried with native app wich does this:
textView.text = [NSString stringWithFormat:#"%f %f\n%#",
locationManager.location.coordinate.longitude,
locationManager.location.coordinate.latitude,
textView.text];
And it is working in simulator and on device.
But the same code as you can see on GitHub is not working as Titanium module.
Any ideas?
EDIT:
I am looking at GeolocationModule src and I see nothing special there.
As I said, my code in my module has to work since it is working in native app. "Only" problem is that it is not updating location and it always returns me that cached location.
The answer is to put ENSURE_UI_THREAD at the top of function that starts location updating.
For 5.0, i use the clgeocoder and clplacemark, but i get "1 stockton street" everytime. I believe 1 stockton st is the address of an apple store in s.f. The Mk classes work for the same program for younger version simulators.
Why is the 5.0 simulator defaulting to the store's location?
Check out the Location Simulation section in the release notes for Xcode 4.2
You can also simulate movement using a GPX file, check this out Simulate Location including movement in Xcode 4.2 / iOS5
Earlier versions of iOS simulator have no location while iOS 5 Simulator have the ability to simulate location (note the location arrow at the bottom of xCode screen). I don't know how you simulate location changes in your code, but it may happen, that simulator activity interrupts your location changes chain.
I'm having a problem with location on simulator.
It is working when I run the app on my device but it does not work when I run it in the iOS(5) Simulator.
Any solution?
Location services not working in simulator since 4. You can set current location latitude/longitude via Simulator menu -> Debug -> Location -> Custom location...