I am using this tool https://mapstogpx.com/mobiledev.php to generate a gpx file with waypoints in order to simulate a vehicle trip. It works almost perfect except that from time to time the device's real location is being received among the locations from the gpx file.
Has anyone encountered this problem and knows how to solve this?
I am using Xcode 8.3.2 and testing on an iPhone SE with iOS 10.3.1
Product -> Scheme -> Edit Scheme -> Run -> Options (See image where you should get)
under this is Core Location -> Default Location - Set this to non and TADA :)
Problem solved.
(If you dont see Core Location under Options you have to run your project first)
I have upgraded the geolocation plugin in cordova 3.5 to fix the issue in iOS 8 by following this post.
http://shazronatadobe.wordpress.com/2014/09/18/cordova-ios-and-ios-8/
After running the app in iOS8 simulator, I am getting the notification 'Allow "MyApp" to access your location while you use the app?' But it still shows the error locationManager::didFailWithError (null) after allowing the location service to use the app. I have tried to close the simulator and run it again and again. Also it seems that location service is active (Settings > Privacy > Location services > MyApp > While Using) by checking the settings in the simulator. By running the same app in iOS 7 simulator is working fine and able to detect the lat/lng.
FYI: I am using Xcode 6 to build the application.
Any help/suggestion will be helpful.
it sounds strange but it really works at least on my Xcode 6 Project. Make also sure to add the required Keys to your Projectname-info.plist file (e.g NSLocationWhenInUseUsageDescription -> as a Key)
Next check your scheme (Product -> Scheme -> Edit Scheme -> Allow Location Simulation)
If you are using a gpx file you can also mark it as a default location.
Now you can start your simulator by pressing the run button (play symbol). As soon as your application started you will get notified for the permission.
The final fix now is to go to iOS Simulator -> Debug -> Location and change the location by choosing one out of the list except the custom location. Wait a little and change it back to custom location if it didnt change back by itself.
It worked for me,
hope for you too
regards
Schreda
In iOS Simulator -> Debug -> Location, choose one
that will be alright,
I'm testing an iOS app with the simulator in xCode 5.x. The root view is a UIWebView that loads an external URL. The external page requests geolocation information, but I cannot get it to work in the simulator. The prompt appears to share location info, but the external page is unable to receive them.
I've tried setting a custom location in Debug > Location... but nothing changes.
I've tried multiple devices in the simulator, such as iPhone 3.5 and iPad.
If I load the app in an actual device, it works fine.
What am I missing?
-e
+1 to #Farhan for a helpful tip. Here's what solved my problem:
There are two places where simulator location gets set:
The Scheme (see Farhan's answer).
In the Simulator under Debug > Location
I played with the Default Location setting in the scheme and it didn't work. Mine is currently set to "None" which is unclear as to whether that means there is no location data provided or whether it defaults to the location of the host machine.
In the simulator under Debug > Location, it was also set to none. I tried using some of the presets, but it still didn't work. What eventually made it start working for me is I changed it to "Custom location" and entered the latitude and longitude of where I am located. Only then did it start working correctly.
This post has some helpful screenshots of what I'm describing.
This is a handy tool for getting latitude and longitude.
Update
The solution I described above still works, but in the project I'm currently working on it doesn't seem to retain the settings, so I have to keep re-selecting my custom location. This gets tedious, so I created a new preset location using gpx file. Turns out this is really easy. Just use this tool to generate the file and download it. Then when you edit the schema, under Default Location, choose the "Add GPX file to project..." (and select the file you downloaded). That's it. For whatever reason, this setting does seem to get remembered when I re-run the simulator.
You might need to enable it for your specific build. To do that.
In your Xcode go to Product > Scheme > Edit Scheme... 2 - In the Run projectName/ Debug
Select "Run XXXX.app / Debug" > Select "Allow Location Simulation" and select a default location.
I had the same issue - try this:
Check your Location Settings in the Simulator. Press CMD-Shift-H to exit app, go to Settings->Privacy and select 'While Using the App'. You also need to have set NSLocationWhenInUseUsageDescription key in Info.plist.
To use custom location (adding your own lat/lon coordinates), with the simulator selected, go to the options at top and select 'Features' option
Once you select the 'Customer Location' option you can enter your Lon lat details here.
Voila!
Delete app from simulator
Set coordinates from Debug/Location/Custom Location
After Hardware/Reboot simulator
If you are still faced with this issue, note that it's caused by a bug in the iOS simulator, I had already updated the custom location in the "Features > Location > Custom location..." as seen in Jim Tierney's answer but when I restarted the app, the simulator doesn't take the new custom location into consideration.
To resolve this, simply open the "Maps" app on the simulator, and make sure it's showing the custom location you selected by tapping on the location icon at the top right.
Minimize it to the background, reopen your app, stop the app and start the app, now the location would show you the expected result.
Xcode supports GPX files but it is important to note that the GPX file needs to contain waypoints. Tracepoints don't work, so make sure to only use "wpt" tags in your GPX.
I am also facing the same issue. The location package worked fine on Android, but on iOS devices, it didn't get the location information. So I solve this by changing the location from Simulator Settings.
Solution:
From Simulation Bar > Features > Location > Apple (Select this)
This solves my issue !!
Now I can get location data.
For me, the problem was that "Debug Executable" wasn't checked on the scheme I was running. Once I enabled this, everything started working normally again with the location simulation.
I am using a Custom Location under Debug --> Location --> Custom Location
While this setting does work just fine for me, the simulator frequently changes my setting from Custom Location to None. This reverting does not appear to have a pattern as I may run the same project 5 or 10 times without the setting reverting. Other times it changes the Location to None every 1 or 2 times I run the simulator.
Is there a way to lock the setting in so I do not have to fight with it?
Have you tried setting a default location? May be it is set to none.
Edit your scheme > Select "Run XXXX.app / Debug" > Select "Allow Location Simulation" and select a default location.
The accepted answer it is a solution, solved your problem, but for other developers that are facing this issue, there is also a easier solution where you don't need a GPX file or to select one of the locations provided as default:
In your Xcode go to Product > Scheme > Edit Scheme...
In the Run projectName/ Debug, go to Options and Deselect "Allow Location Simulation".. yes uncheck it!
Press OK
Run your app in the simulator
On simulator menu choose Debug > Location > Custom Location
Specify latitude/longitude coordinates
Now the simulator will keep this as default location. Actually the Allow Location Simulation on Xcode, together with the option none is the reason for "forgetting" the location you added before.
From now on, your simulator will always remember the last custom location!
I am developing an app that depends on GPS data and works only in New York City. It will display "out of range" if the user is 30 miles away from Manhattan. The problem is that I am 8 hours away from New York City and can't really test the App functionality.
In Android, you can have DDMS send your device or AVD a mock location by simply pushing the lat and long coordinates. The App will then react to the location changes. I can't seem to find a way to do that in iOS.
Does anyone know how to simulate location on iOS?
Thanks
In Xcode 4.2 with the new iOS 5 SDK it is possible to simulate locations in the simulator. Launch your app in the simulator, click the Debug menu option go to Location and then click Custom Location…. The simulator should then allow you to enter longitude and latitude.
FakeGPSUtility works fine for iOS7, can say nothing nothing about iOS8. Can be installed either manually or from CocoaPods.
Manual installation:
Drag the FakeGPSUtility folder into your Xcode project;
Define 'DEBUG' in target build configuration;
Add MapKit and CoreLocation frameworks into your target.
The answer is a bit outdated so NOW you can easily simulate a location with Xcode like this:
Just run your project and press the arrow. If a location is active, it turns blue.
There are some preset locations and the last option is Add GPX File which could be any location you want. Just create one like this: New -> File -> GPX File