iOS Simulator Reverts Location Setting - ios

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!

Related

A gear icon appeared in my Xcode app icon project and I cannot run it anymore

I've added a framework and a library (spring) to perform animations with buttons, etc.
Now instead of one app icon to launch, in x-code, I got three, and can launch them all except the main one. The main app icon it's now a gear, and I cannot run it because x-code don't let me select any device to launch it. I can only select my mac, as you can see in image...
There is also another thing. The yu.app in product folder turns to red only when I'm in the main app. When I choose spring it turns black again. Anybody know how to fix this issue?
Do following
1 - Navigate to manage scheme
2 - Remove older scheme
3 - Create new scheme
For removing files of older scheme you need to remove derived data.
From XCode Window > Projects > Select Your Project > delete derived data
All the answers here suggest a way which may work but not the proper solution.
Just select your scheme, go to Edit Scheme. Go to Run. In Executable dropdown select the correct app and it will start working. No need to create new scheme or delete any scheme.
Navigate to Manage Schemes add a new scheme for your app target yuApp and remove any outdated schemes.

Simulate fake location on real iOS device

I want to simulate fake location on my iPhone 5S device using specific longitude and latitude. Is there a way to do this in XCode. I tried using the simulate location feature by adding a GPX file in XCode but it's not working. Thank you in advance.
It is possible.
You only have to:
1) plug your device to the computer.
2) run an app in the real device (it is the same which application). It is only to have the menu enabled.
3) in Xcode (not in the simulator) Go to menu: Debug -> Simulate Location and select one or add a GPX file.
It will simulate the location not only for the application executed but for all of them.
I suppose that the phone must be in developer mode but if you run apps from Xcode it must be anyway.
I've tested it from Xcode 6 in an iPhone 4 iOS 7.1.2
Hope it helps
In addition to the method for setting a simulated location at runtime as mentioned in this answer, you can set/change the default simulated location for a default device/configuration prior to runtime in Xcode at:
Product (menu) > Scheme > Edit Scheme > Options (tab) > Default Location

Geolocation is not working in iOS 8 simulator

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,

iOS Simulator location not working

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.

Xcode can build a project but can't run it on simulator

When I download a project from the web, sometimes it can be built but doesn't run (XCode -> Product -> Run is disabled, in grey). This never happens when I create projects myself. What could be the problem? Is it somehow connected with version?
I'm new to iOS development and download projects from the web for studying purposes. It's a pity not to be able to test them on the simulator.
Generally, if you can't Run a project, either:
It doesn't have a build scheme that knows how to "run". Check at the top next to the Run/Stop buttons that there's a profile name and target device shown. If the box says No Scheme then click on it and create a New Scheme. If there IS a scheme, click on the drop-down menu (left divider in Xcode 4.2+, anywhere on the box otherwise) and go to Edit Scheme to make sure the scheme was set up correctly for Running
It doesn't have a build configuration set. You should see this in the Run section of your build scheme. Check there's one selected. If the list is empty, go to the Project icon at the top of the leftmost pane, select the Project, go into the Info section, and create a build configuration, although there should already be at least one if you can build the project
It doesn't have a runnable target at all, which might mean you've got a project which compiles to a static library or framework for use in OTHER projects. If this is the case, you should see the icon for your build Target as a yellow toolbox (framework), or a little white building (a "library", although to me it looks more like the United States Supreme Court Building).
The target isn't valid for the Simulator, which means you might need to add i386 to the list of Architectures and Valid Architectures on the Target before you can run it
The target isn't valid for the currently connected device. For this one, check the Deployment Target number is set back enough to be valid for the device's version of iOS
Xcode can't see the connected device. Try unplugging and plugging it back in. If it still doesn't recognize it, you may have not added it to Xcode (Window -> Devices -> Select the device -> Use for Development)
Make sure that in your Edit Scheme (click on your project name next to stop button -> Edit Scheme), in the Info tab of the Run menu selection, that your .app is selected as the Executable. I had this issue and "None" was selected, happened after refactoring the project's name and reconfiguring the build targets.
you may download a project that the deployment setting (the ios version) is higher than the one your xcode support. if this is your situation, you has two options to sovle the problem.
try run the project in a older deployment option. follow these instructions (
if the project just setting to a higher version but not using any feature of the higher version. this approach should work):
select project file in xcode > select the target you are going to run > select summary tab > in section 'iOS Application Target' > in the combo box about 'Deployment Target' select the version that your Xcode support.
and then you could select and run the project in the simulator.
if the project dose use features in the higher version, then you should update your Xcode in order to run the project.
Hope this helps!
In my case the issue was really simple, I needed to check "Launch: Automatically" check in "Product > Scheme > Edit scheme > Run" menu.
When this setting wasn't checked I cannot find App icon in simulator to launch application.
In My Case Sole by Go->Project->Architectures->Architecture=select standard architectures(armv7,arm64)...
same as
Go->Target->Architectures->Architecture=select standard architectures(armv7,arm64)...

Resources