How to run UWP app on Simulator and simulate a location? - visual-studio

I need to test my UWP application using a simulated location.
I assume that I can do this by running the app on the simulator instead of the local machine, but there is a problem. When I select Simulator, the simulator opens but never finished initializing. It is stuck in a state with a series of dots running across the screen.
In the Visual Studio window, the last message I see is "Registering the application to run from layout". I don't know what that means.
I found some old posts that suggest I need to acquire or renew a license. I checked to make sure that Developer Mode was enabled on my machine and I also ran "Get-WindowsDeveloperLicense" from an elevated PowerShell account, but it did not fix the problem.
Thanks,
Frank

How do I start a UWP simulator?
Your system need to support Hardware-assisted virtualization and
Enable Hyper-v for emulator
Then switch the Solution Platforms to X86 or x64.
For more info please refer Run Windows Store apps in the simulator
simulate a location?
The Visual Studio 2015 simulator does not include the geolocation button. This is because the Windows 10 simulator does not include geolocation simulation. If you need to do this kind of simulation, you can use the Visual Studio 2013 simulator on Windows 8.1 or earlier operating systems.

Related

how to add windows phone emulator to the uwp project

Now I'm updating someone's UWP project.
I use Visual Studio 2017 on windows 10 64bit.
Building is successful.
But When I run this project, I got an error.
DEP6200: Bootstrapping failed.Device cannot be found.
SmartDeviceException - Deployment failed because no device was
detected.
I think, the reason is that I didn't use real windows phone.
So that I wanted to use windows phone emulator.
But I don't know how to add emulator to running option.
When I created new UWP project, I could find emulators which are connect to that project.
Anyone solved this issue?
You have to install Emulators.
Please take a look at this page and download them Windows Emulator archive .
Simply choose your emulator version that you want to debug your app and then Click INSTALL EMULATOR , After installation Restart Visual Studio .
To use emulator there are some prerequest, you can check it from here.
That's to say, first ,you need to make sure you followed the system requirements.
Then you have to install emulator like MKH said. And at last, set the CPU to ARM and choose the emulator you need, run the project and you will see the result.

Xamarin Android Simulator launching forever

I am using Visual Studio 2017 (version 15.4.5) & its default emulator for Android device.
I just try to run simple hello world of Xamarin Form. When I click to Debug
It's has just launch the Android Device, and stucking at it's forever, no deploy and Visual Studio's progress bar is always running... I have waiting more than 16 hours.
After all, I found a solution,
Open Regedit, under HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node node,
Create a new key named 'Android SDK Tools', create a variable name Path, the value point to 'C:\Program Files (x86)\Android\android-sdk'
enable Hyper-V
install Intel HAXM Drivers
use x86 system images
enable Host GPU
Use Fast Deployment (debug mode only)
https://university.xamarin.com/resources/working-with-android-emulators
https://learn.microsoft.com/en-us/xamarin/android/get-started/installation/android-emulator/google-emulator-manager?tabs=vswin
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/debugging/visual-studio-android-emulator

Xamarin workflow on Windows

I'm aware that a Mac or a Mac service e.g. MacInCloud.com is necessary for building and submitting iOS apps.
My question is about the actual workflow of building an app on Windows using Xamarin on Visual Studio 2017.
We need to write code, test and debug throughout development cycle. How does this work with Xamarin running on Windows? How would I actually see what my mobile app looks like or behaves during the actual development cycle?
While developing my web apps in Visual Studio, there are many trips back and forth to the browsers and back to VS in order for me to see the results of my code. How does this work with Xamarin running on Windows? Is Xamarin Live Player the only option for development cycle? Is there a solution through MacInCloud or similar services so that tethering a device to dev machine is not necessary?
I'm just trying to understand how a healthy development cycle is created for Xamarin developers on Windows.
I will answer your question in few section: Coding, Debug, Test
Coding
You will be using Visual Studio to write your codes. iOS and Android code will be written in C#. You will get access to UI Designer for both iOS and Android to edit the layout files and storyboard/xibs. For 3rd party library, there is NuGet to serve your needs.
Debug
You can use Xamarin Live Player without connection to a Mac/MacInCloud for basic preview. However, some features of iOS is not available in Xamarin Live Player (e.g. xibs files not supported...).
If you setup with connection to a Mac, you will be able to see a list of Simulator that available in the Mac you connected to. By default, if you debug it, the simulator will still show up in the Mac. Then you will need to VMWare or remote into the Mac to check the simulator output. If you have Visual Studio Enterprise license, you can get access to a Remote iOS Simulator feature. You will need to turn the option ON. After that, you will able to see a remote iOS Simulator showing in your Windows machine without the needs to remote into Mac machine anymore. For debugging in actual iOS devices, you will still need to plug your device into the Mac. Previously (more than 1 years ago), Xamarin announce that they are working on "iOS USB remoting" to allow you to plug in iOS device into Windows machine and debug on it. But it is not release until now.
For Android, you can get access to Android Emulator Manager to add emulator to debug or you can deploy apps to physical phone just like what you can do with Android Studio.
Test
I will be referring to Xamarin.UITest for this part. You will be able to write UITest code in C# inside Visual Studio. Xamarin have product "Xamarin Test Cloud" to allow you to upload test code and binary and then run your test in cloud periodically. If you want to run the test locally in your machine, you will only able to run Android UITest in windows machine. To run iOS UITest locally, you will only able to run it in Mac machine. Using a Mac, you can also run Android UITest.
You can use a simulator/emulator instead of a device. For iOS, the simulator would run on the Mac Build Host that you are connected to. You can select the option for "Remote iOS simulator" in Visual Studio -> Xamarin.iOS options and you'll be able to interact with the simulator without having to RDP/VNC/look at the mac. For android, you can just run an emulator in Window and interact with it like that. Using your web apps comparison, you would use a simulator/emulator instead of browser but, for the most part, the process would be similar.
I have been developing a Xamarin MVVM app targeted at iOS and Android. I initially did the iOS development on Windows with VS 2022 and an iPhone attached via USB. I knew that I was going to have to eventually move to the Mac for final provisioning but I ended up taking that painful step earlier than planned because certain Xamarin features were just not working on Windows. First I could not get my app icon to be anything other than the Xamarin default and then Xamarin.Essentials.FilePicker would not select a file:
https://github.com/xamarin/Essentials/issues/1710
So after a week of struggling I finally got my project building and deploying on the Mac. However, I am not nearly as comfortable working on the Mac as I am on Windows where I have all my familiar development tools. So then the question was how to share the project files between the PC and the Mac so that I could edit and compile on the PC and then move to the Mac for final testing.
At first I tried iCloud but I could never get the files to sync reliably between the shared folder on the PC and the Mac. I am used to Dropbox and OneDrive, which work as expected. iCloud not so much.
So what I have been doing is committing and pushing the changes to github and then pulling the changes into the project on the Mac. It is quick and has the added benefit of version control using an offsite server. I am happy with this workflow and publishing the app on the Apple Store should be an easy task when that time comes.
Update:
This process is still working for me. I have taken the additional step of doing the release configuration on VS Mac and publishing my app to App Store Connect. That experience was convoluted and frustrating but it now works and I have people testing my app via TestFlight.
One hiccup is that when selecting Automatic iOS Bundle Signing in the project properties on VS Windows, this change gets pushed to the Mac side and causes a build error under Debug until I select the Automatic provisioning profile on the Mac. Somehow it gets set to the Wildcard profile on the Windows side.

Debugging Xamarin.iOS project without physical mac

My idea is to use macincloud to build xamarin project. And I'd like to debug it also.
On xamarin's site it's written that "Xamarin.iOS applications can be debugged with the built-in debugger in Xamarin Studio or Visual Studio." But it's still not clear if the device, for example iPad can be connected to Windows machine? Or It has to be connected to Mac only?
Device has to be connected to the Mac. If we are connecting to a mac remotely, we can use a Simulator and and view the result using a RDP client like TeamViewer. I'm not sure if that is possible with MainCloud. You can also go for Xamarin Test Cloud if that is feasible for you.
No, it's not possible to deploy to device and debug with MacinCloud. You can however launch a simulator and debug your app inside the emulator.
If you want to deploy to your ipad you can use publish your app with TestFlight service and install TestFlight builds on your iPad.
See more details at Developing iOS Apps in Visual Studio with MacinCloud
There are two possible ways how to do it. First one is more proper but it's in preview version - Microsoft introduced Xamarin Live Player.
Second way is to have your own virtual machine of macOS on Windows machine. Here is the tutorial how to do it.

testing a website in windows phone 7 simulator

I'm trying to test a mobile website I'm building using Windows Phone 7, but I can't figure out how to do it. It seems that the SDK wants me to build an application first in order to use the emulator, but I'm not building an app, I simply want to test compatibility of my mobile site with windows phones. How do I do this?
If you install the free Windows Phone SDK you can run an emulator in standalone mode (i.e. without Visual Studio running).
Search for "Windows Phone Emulator" from the Start menu and just launch that directly.
Once in the emulator about the only thing you can do is launch IE Mobile.
(To enter URLs and other text using your real computer keyboard instead of the onscreen keyboard tap your "Pause/Break" to toggle keyboard mode)
You should be able to run emulator without building an app
try C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Tools\XDE Launcher\XdeLauncher.exe
If now start visual studio and make an app f.e. Silverlight for Windows 7. Emulator will be loaded with debbuger attached. If you stop the app in VS, emulator should be still there. It has preinstalled IE which you can use to test.
Mind that it's better to test your web app on a real device.

Resources