Xamarin - Cannot use iOS Emulators? - xamarin

Visual Studio 2019
I recently upgraded Xamarin.Forms to version v4.5.0.530. This required me to upgrade xCode on the Mac to 11.4. This required me to upgrade the Mac OS to Catalina. OK I did all of that. Since then though:
If I run the project on the iPhone connected to the Mac it still WORKS fine (as before).
However, if I try and use one of the emulators on the PC (ipad etc) it FAILS to deploy with the following message:
Selected device is not a physical device. Please select a valid device before deploying the application.
Well obviously it is not a physical device!?!
Of course I am doing everything the same way I did it before the upgrade, choosing Debug, iPhoneSimulator, my iOS project, iPad Pro (9.7... etc)
So, it works on the physical iphone but not on any of the apple emulators (android phone/emulators work fine).
Has anyone any ideas why this might be?

It was a setting at Solution level. For some reason with 'iPhoneSimulator' selected at the top, against the iOS project 'iphone' was selected. Changed it to 'iPhoneSimulator' and all is good in the world again.

Related

Visual Studio Preview 2022 will not let my change deployment target

I just installed Visual Studio Preview for the MacOS yesterday. The simulators work fine, but I can't run on any devices I have (both IOS and Android). It keeps saying that the OS version is lower than the deployment target.
Image of the problem
It doesn't make sense; one of the devices I tried was a Galaxy A11 I just got, software version 10. The IOS device has software version 15.4.1. I can't even find what the current deployment target even is. I've checked the info.plist and AndroidManifest files with no success. Yeah I can use the simulators to work on the app but sooner or later I will need to test on a physical device. Can someone point me in the right direction?
If it helps I'm currently running macOS Monterey version 12.3.1.
EDIT: Forgot to mention that I've tried to add the Minimum System Version to the info.plist, but that didn't seem to change anything either.
I was able to determine that the device destinations in the drop-down shown in the question are driven off of whatever XCode command line tools you have set for use before starting VS for Mac.
Presumably if you check your physical device's OS version against the SDK version shown when you type this at the command line will show that the physical device's OS version is lower than the appropriate SDK version shown.
xcodebuild -showsdks

Mac Visual Studio 8.2.6.26 update not showing any iOS simulators, only Generic Simulator

Yesterday I updated my Visual Studio and Xcode. Immediately afterward I lost any listing of available iOS simulators for my Xamarin project in Visual Studio. I can plug my iPhone in however and deploy my project onto it just fine, but I'm used to working with Preview in VS and also running a simulator for quicker response.
I'm currently running the following versions:
• Updated to Xcode 11 (11A420a)
• Visual Studio Mac 8.2.6.26
• Mac OS 10.14.6
• iOS 13.0 on iPhone 7+
Now Visual Studio shows the only available simulator as being the Generic Simulator with a hammer, which doesn't launch anything that I can tell. When I look at the list to choose a simulator I see the message line: "Lower the 'Deployment Target' to see older simulators or check your Apple SDK path"
When I launch a test project directly from within Xcode, it offers iPhone 8, 8+, 11, 11 Pro and others as available simulators and those indeed work. In Visual Studio I have changed each Deployment Target from 6.0 to 12.2 and not one of those makes available any simulators.
I'm not sure what the Apple SDK path is about, how to check it and where it needs to be pointing.
Does anyone have any thoughts about what adjustments need to be made to regain my iOS simulators in Visual Studio Mac again after these updates?
Thanks so much :)
After trying a bunch of suggestions, this simple fix worked for me. First I changed my deployment target in the info.plist from 9.3 to 11. After checking that my Apple SDK path in VS was pointing at Xcode11 and the iOS SDK version on my Mac was 13.0, I simply force quit Visual Studio and Restarted my computer. Then I began to see iPhone8 & iPhone11 simulators. Goodluck.
Updating both XCode and Visual Studio for Mac worked for me.
Just updating XCode did not work.
I also fidgeted with the Deployment Target which I believe refreshed the simulators list.
UPDATE: I confirm again that when I go to info.plist and just click on the deployment target drop down, the simulators list gets update. Little funny.
Ran into this issue many times for the last updates. Nothing really helped, until I came across a Microsoft forum where someone mentioned the Apple SDK path needs a trailing slash, which is not added when using the Browse button to navigate to the Apple SDK Location.
So when using Visual Studio for Mac, navigate to Visual Studio -> Preferences -> Projects -> SDK Locations -> Apple and please note your Apple SDK Location should be something like:
/Applications/Xcode.app/
rather than
/Applications/Xcode.app
Changing the "Minimum System Version" did the trick for me.
Eg. I had 14.4 and I changed it to 14.0 and restart VS the all the simulators appreared.
I resolved the issue as well by going under the Visual Studio --> Check for Updates menu and switching the channel to "Xcode 11 Previews". Finally some updates were available and I updated everything normally. I also updated everything in the "Stable" and "Preview" channels as well. Now I have iPhone 8 and iPhone 11 simulators working, however I no longer have any of the other simulators like iPhone 7, etc. like I did before.
After updating Xcode via the app store, restart your machine. The simulators should reappear.
UPDATE
This didn't work for me after the latest update. However, setting the startup project to Android, then switching back to iOS was enough to repopulate the list for me after restarting my machine.
info.plist has an option called Minimum supported version which says which version of the iOS you are targeting.
in my case it was 10.3 earlier, when i have upgraded xcode (12.4) and vs for mac(8.9.6) to support iOS14. this caused the conflict between the xcode supported iOS version and plist version.
I changed it to 14 in plist for the Minimum supported version and it worked for me.
In summary check the xcode supported version and update the minimum supported version accordingly
Same here, just need to change 'Minimum system version' on your info.plist file in my case was 12.0 and then updated to 12.1 and vualaaaaa the simulator list refresh it.
I had the same problem when the iOS 14 updates were first installed. I had already installed both XCode and VS updates.
What I did is: I restarted the Mac and I had to install the XCode Command-line tools from VS separately. Then the simulators were visible.
What always works for me is connecting an iPhone device. After I connect it, the simulators appear. I guess connecting a physical device also refreshes the simulators list.
This time, nothing was working for me, until I deleted /Library/Caches/Xamarin/XMA and /Library/Caches/Xamarin/mtbs and restarted VS. That helped.
Here's the actual solution if updating everything else still doesn't work. Open terminal, type in "instruments -s devices" to see a list of all the installed simulators.
In your info.plist set "Minimum System Version" to match the lowest simulator version you have installed.
After plugging in my physical phone with the usb cable, the list of simulator devices appeared in like 2 seconds... Before plugging in my phone, only the generic simulator and my phone were shown as deployment options
Just restart of my Mac worked...

Does Xamarin IOS Simulator Require XCode?

Well , im new to IOS app development i've heard about Xamarin cross-platform app-development, so my setup is ==>
Visual Studio Enterprise Update 1 Installed.
Xamarin For Visual Studio 2015 Downloaded (Now about to install).
Xamarin IOS simulator downloaded.
Now as i have xamarin simulator i don't need to buy a mac or get a hosted-mac , that's clear now i just wanna confirm do i need XCode ? i mean i have xamarin simulator but still i'm confused about XCODE for windows how can i get that should it be getting installed automatically or do i need to give it another shot.
I'm confused about all this .
I just don't* have the budget to buy a MAC and i want to do APP development just (Debugging ) deployment will be done latter please tell me what should i do or give me the proper instruction thanks.
You need to run Xcode on a mac to build Xamarin apps for iOS. A Windows install of Xamarin on Visual Studio will allow you to connect to a mac to do the build remotely, but you still need a mac available that has Xcode installed on it to do the build.
You can download Xcode from the Mac App Store. You will also need the mac to upload the final package to the iOS App Store if you're going to release it there.
An other option is to use a cloud based Mac server, there are several companies that rent them out on hourly/monthly basis for this purpose (MacinCloud being one that I've heard of).
XCode needs and can only be installed onto a MAC OSX system.
Once you have XCode installed, you can use its iPhone simulator to emulate the iOS apps you make on your windows pc.
You need to connect to the MAC by using the MAC Agent on Visual Studio. This connects remotely to the MAC and allows you to debug the app to be emulated onto the virtual iOS device being simulated on your MAC OSX system.
You can use MAC Cloud based server but also, you can use a real iOS device such as an iPhone to debug apps directly onto the device.

Can we use an Ipad Pro to compile xamarin ios projects with Visual Studio on a windows machine?

The xamarin documentation mention that we need an MacBook connected to the network to be able to compile a xamarin ios project on a windows machine.
However can we use an IPAD Pro for this also ? Otherwise I have to buy a MacBook just to connect to my network ?
https://developer.xamarin.com/guides/ios/getting_started/installation/windows/connecting-to-mac/
No. You need a Mac running a current version of OS X to act as a build host. An iPad Pro does not run OS X.
As Dylan S mentioned, getting a cloud hosted mac (like macincloud.com) would be the best solution for you. From what i've seen they got pretty reasonable plans and their website seems pretty informative

Deploying cordova to Xcode in vmware

I have just started using cordova and ionic with vs2015. I am running this on a windows 10 machine. I have built the android side and put to store.
I have a version of mac running via vmware on the windows machine. I have tried copying the xcode project file across manually and building, butrun into bui;d errors. Is there a way of linking vs2015 ios build directly to the xcode on the vmmachine.
If not may some guidance on building and copying the correct parts for xcode.
Cheers
Sounds like you need to run your app on the iOS Simulator
Make sure that you have installed the remote agent on a Mac that meets all system requirements, and that you have started the remote agent.
Make sure that you have specified iOS processing, the host name or IP address, port, and security PIN in Visual Studio.
With your app open in Visual Studio, choose iOS from the Solution
Platforms list. If you don’t see this list, choose Solution
Platforms from the Add/Remove Buttons list to display it.
In the simulator list, choose Simulator – iPhone or another iOS
simulator.
Selecting the iOS Simulator Press F5 to start the app.
If the remote agent is set up correctly, Visual Studio deploys the app to the iOS Simulator on your Mac.
iOS Simulator running on a Mac
Tip If you are running a version of the iOS Simulator with a Retina display on a lower-resolution Mac with a non-Retina display, you may need to scale the emulator to 50% so the app will fit on the screen (choose Window, Scale).
If you have configured the remote build agent on your Mac as described in the article Install tools for iOS, you can build and run your app on an iOS device that is connected to your Mac or PC.

Resources