What are the release / debug sub configurations for? - xamarin

In Visual Studio Mac / Xamarin Studio there's a drop down menu inbetween the device picker and the platform picker.
This is it...
Apart from selecting release or debug, what do all the different versions do? And, in particular, why am I able to select this...
This clearly doesn't make any sense. i.e. that the configuration is specific to an iPhone simulator but it's to be deployed on to an Android simulator.
Incidentally, I'm asking this because my Android build no longer installs properly and is double it's previous size.

Related

development app is deployed on IPhone, but I cannot start it

I have an app in Xamarin that I want to test on a physical IPhone (normally I test it on Android). I'm connected to a Mac, the development certificate is working and everything is deployed to the point that the app is actually installed on the IPhone itself. The issue however is that when I press the icon to start the app, it tries to start it and then is closes right after that (like it crashes or something).
I'm using Visual Studio for Windows, and it is stated that: "XAML Hot Reload encountered a problem and failed to start. Verify the Mono Interpreter for is enabled in the project settings, clean and rebuild the solution.". Mono Interpreter is enabled, I cleaned the solution and rebuild it multiple times. There are no errors given.
The app that is installed now shows the Xamarin icon and Xamarin splash screen (so not the custom one I designed). I don't mind that, but I'm not sure if that has something to do with this.
Does someone know what is wrong here and how to fix it?
Visual Studio for Windows version 17.4.1
iOS version 15.5
Note: this issue is only with the development and deployment directly from Visual Studio from Windows. When the app is distributed to the users (in App Center) the app works as it should.

Can't run a Xamarin App in iPhone Simulator from Visual Studio For Mac

In short: I am unable to run my app in the iPhone Simulator. There is no "Play button" (the triangle), only a Debugger button (hammer):
As you can see above I have "Generic Simulator". When I click on it, there is no list of various iPhones/iPads to choose from:
If I choose Android, I am able to run the app:
I have XCode installed. I ran XCode once.
I also installed the Command Line tools.
I created a new Xamarin Forms App:
Here are my iOS build options:
I am able to run the Simulator separately:
Creating an App in XCode and running in the Simulator works:
info.plist:
Prefrences -> SDK Locations -> Apple
Build -> Configurations:
Here is the kicker though. If I run a Xamarin App on my Windows machine using the iPhone Simulator on the Mac, it works!
What do I need to do so I can run my app inside the Simulator vis Visual Studio for Mac?
Few options you can worth to check. #WorldOfBasti suggested options plus following.
Configuration
Right click on the solution -> options -> Configurations -> Configuration manager -> ProjectName.iOS with Debug|iPhoneSimulator should be checked or if configuration "ProjectName.iOS with Debug|iPhoneSimulator" is not available then add this from General tab
Apple SDK path
Check Apple SDK path is set properly (Preference -> SDK Location -> Apple). It should have green tick mark with Xcode version and SDK path location.
Minimum system version (Deployment Target)
Change Deployment Target to minimum version (ie, lower than your simulator version)
Switch debug <-> release
Today I have also faced same issue which you are facing. I have switched debug to release, iOS to Android. Then reverted back to iOS and debug from the top device selection status bar. Then Simulator option was appearing. So, might be UI updated issue in Visual studio for mac. Please give a try.
I assume that you tried the basics things like restarting your Mac, etc. So here are a few things, that might solve your problem:
Check your build configurations, here is a good video
Close VS for Mac, start Xcode and create a test project which you run on a simulator. If it works try again in VS for Mac
Close VS for Mac, goto Xcode -> Preferences -> Accounts and download the manual profiles of your developer account. Try again in VS for Mac
Clean your project: In VS for Mac, goto Build -> Clean All. Then Close VS for Mac, goto your project folder and delete in "yourprojectname" and "yourprojectname".iOS all bin and obj folders. Try again
If all of this doesn't work, I would try to reinstall it (if you have any important projects, make a backup):
Uninstall VS for Mac and Xcode
Install Xcode again from the App Store
Install Visual Studio for Mac
Hopefully it works..
Looking at the Visual Studio for Mac logs, specifically the IDE log, I found this line ... 'The target name of simulated device could not be added because it's already cached'.
You are welcome to read through all of this ... but you may just want to go down to the Addendum 2 (final?) and see if that works for you ... it ends up being simpler and quicker than anything else I have found.
So, at first, I started clearing the cache with a 'xcrun simctl erase all' command from Terminal, and when I started Visual Studio for Mac I could run a Xamarin App, but launching the simulator took quite a bit of time.
So hare's something I found works that you might want to try ...
Close iOS Simulator on Mac (if any).
Close ALL copies of Visual Studio that are connected to the Mac ... either on the Mac itself or on another computer connected to the Mac (if any).
Start Visual Studio for Mac.
If you can't run a Xamarin App, Close Visual Studio for Mac.
Launch the Simulator manually (I have it in the Dock, so I just click it) ... wait for it to fully startup.
Now close the Simulator (from the Simulator menu).
Now restart Visual Studio for Mac.
If you still can't see the simulator devices to run on ... try the above steps one more time (this time you should only have to close Visual Studio for Mac followed by manually starting the Simulator, waiting for it to start, and then quitting the Simulator and finally restarting Visual Studio for Mac).
It still isn't great, but this has (so far) always worked for me. And the Simulator starts up substantially quicker then if I did a 'xcrun simctl erase all' command from Terminal.
Addendum: Most of the time the above works. But occasionally I still have to clear the cache from the Terminal with 'xcrun simctl erase all' command.
Also: I have also found (although maybe it's just my imagination) that clearing out the Visual Studio for Mac temporary .binlog files that are written in the 'T' folder will sometimes fix the problem (if you look at an IDE log from Visual Studio for Mac; right after the 'The target name of simulated device could not be added because it's already cached' message, you should see some .tmp files being created. The directory where they were created is the 'T' folder I'm talking about). I sometimes delete the tmp*.binlog and tmp*.tmp as a last ditch effort before using the 'xcrun simctl erase all' command to try to get back to where Visual Studio for Mac will see the iOS Simulator Devices.
Finally: This is really starting to feel like a bug in Visual Studio for Mac startup (or possibly during a iOS project load). The reason I say that is I can ALWAYS see the iOS Device list from Visual Studio for Windows (as long as I can connect to the Mac). In addition, I can leave Visual Studio for Mac running (even hidden) and test an app on the iOS Simulator from Windows, then, leaving the iOS Simulator Running on the Mac, run an App on Visual Studio for Mac. If there really were a 'caching issue' with the Simulator it seems to me I should have problems running anything on the Mac after using the iOS Simulator from Windows, but it always works. For now, I'm working on a single Xamarin Project on the Mac (and I don't use the Mac for anything else), So I just let Visual Studio for Mac 'open at login' (Dock setting) and automatically 'load previous solution on startup' (Visual Studio for Mac setting), hide Visual Studio for Mac (Dock Setting) and if I need it, Visual Studio for Mac is already loaded and able to see iOS Devices to run Apps on with a quick click on the Dock Icon.
Addendum 2 (final?): I have now found that if I just close a solution that I have open that shows 'Generic Simulator' and re-open it without exiting Visual Studio for Mac (sometimes I have to do it multiple times ... I think I've counted up to 5 times before it finally worked), it will start showing the device list and I can run the iOS app in the Simulator. I don't even have to close the Simulator if it's already running, which saves a bunch of time.
It still feels like a bug to me, I don't see why I would have to close/open a solution multiple times to get the iOS devices listed and be able to run an iOS app. What really gets me is if I reboot the Mac, don't open the Simulator and start Visual Studio for Mac, then open a solution, I still have to go through the close/re-open solution steps... sometimes more than once. The simulator is not set to auto start or anything like that. But, at least, it's getting simpler, and takes less time, to get to a point where I can run an iOS app.

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.

Xamarin Native iOS breakpoints not getting hit VS2017

I cannot hit a breakpoint in VS when debugging any native iOS app through VS2017 Pro. I have trawled the Xamarin/Stack forums and seen this has been a problem in the past and I have tried the suggestions but they relate to a 3.xxx version of Xamarin. Even an out-the-box new project untouched except for placing a breakpoint still does not hit, the build server pops up the simulator and runs as expected. Android is fine
This was working, I have recently downgraded from Enterprise to Pro but think this may be a red herring. I have 2015/13 pro installed with the same problem.
Is this an issue build server side or the windows side? I get the following generated in my bin App.app, App.exe, App.pdb but no app.mdb i do get the referenced dll.mdb files.
Current vs setup...
Microsoft Visual Studio Professional 2017 (2)
Version 15.1 (26403.7) Release
VisualStudio.15.Release/15.1.0+26403.7
Microsoft .NET Framework
Version 4.6.01586
Installed Version: Professional
...
Visual Studio Tools for Universal Windows Apps 15.0.26403.07
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.
Xamarin 4.4.0.34 (3f99c5a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin.Android SDK 7.2.0.7 (b16fb82)
Xamarin.Android Reference Assemblies and MSBuild support.
Xamarin.iOS and Xamarin.Mac SDK 10.8.0.174 (7656cc6)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
The Mac
Xamarin Studio 6.3
VS for Mac 7
See this similar answer: Xamarin iOS debugger not hitting breakpoints
Also, make sure you don't have a firewall blocking Port 10000.
I ran into something similar, and it turns out my debug settings for my physical device had some defaults that prevented debugging from working. This may not fix your issue, but you might want to at least check your project settings for a few things.
Under iOS Build I changed my Linker Behavior from Link All to Link Framework SDKs Only. Also, for some reason in a default debug profile, the Strip native debugging symbols option on that same page was checked. Make sure it's unchecked.
This one was already enabled for me but you should verify anyway: double check that on the page iOS Debug that Enable Debugging is checked.
I faced a similar issue but on Android application: I solved by uncheck the option "Code Optimization" from Project >> Options >> Build and set the DebugType to Full
Same here, windows 10, VS 2017 -> MAC -> iPhone
Somtimes I got Debug-Log and can hit breakpoints but mostly not.
A solution / workaround which at least works for me.
Problem:
Setup: Windows 10 with VS2017, Mac-Book, iPhone connected to Mac-Book.
Debug-Log / Breakpoint-Hitting seams to work sometimes (seldom) / non deterministic.
Solution / workaround:
Verify: In case no Debug-Log occurs (e.g. no "Loaded assembly:..." lines etc.) the "Choose Device" drop-down box in the "Tools >> iOS >> Device Log" window shows TWO times the name of the iOS-device.
Stop the debug and explicitly stop the app on the iOS-device (if necessary also delete it for re-deploy)
Via "Tools >> iOS >> Xamarin Agent" disconnect from your Mac and then reconnect again.
Verify: the "Choose Device" drop-down in the "Tools >> iOS >> Device Log" window now shows only ONE times the name of the iOS-device.
Debug the App - it now should work.
See also XamarinForum
Hope it also works for you.
Erdega

Xamarin Forms project set Startup Project

I'm building a Xamarin Forms application for Android and iOS.
How can i set iOS as startup project? I've read that your suppose to rightclick and set it as startup project. But i can't find the option?
Please help me.
You need to change your configuration options to something you have connected. This happens if you were originally debugging directly on an iPhone connected to your Mac, and now the iPhone is gone. Xamarin Studio doesn't switch automatically to the iPhone Simulator when a device is not detected, instead removes the option to use that project as a startup project.
To fix, do this:
Right click on the iOS project and go to Options
Under Build->Output, select the "All Configurations" under the drop down
Under the Platform drop down, select "iPhone Simulator"
Click Ok to save
Now on the top left corner of Xamarin Studio where you can set Debug or Releas, make sure you set it to Debug | iPhoneSimulator and NOT to Debug | iPhone
... and only then, you'll be able to select "Set As Startup Project".
So much depends on your operating system and which environment you are using. If you are on Xamarin Studio on a Mac, right clicking should work fine. Can you possibly give us a bit more information?
Do you have XCode and iOS SDKs from Apple installed? Do you have an iOS development account? You need both of these things, then click on the project's options and pick a development account to use for the project.
You may not have the iOS license and may not be able to run the iOS project at all, although in such cases on my machine the project is grayed out and clearly labeled.
Are you on Windows? If so you won't be able to run iOS projects. The shortcut labels indicate Mac, so does the context menu shape.
Have you been able to run any iOS projects? Try creating a new blank solution with just an iOS project in it to see if it runs.
There is a chance this is a bug with Xamarin's localization in your language (Swedish?)
Try switching your locale to US/English and file a bug with Xamarin or at least send them an email

Resources