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

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.

Related

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.Ios App terminates while starting (in Simulator and iPhone) only stating "The App has been terminated"

I am developing a Xamarin App for Android and iOS on windows. For iOS compiling, I pair with a Mac Mini.
I was forced to update MacOS, XCode, VisualStudio for Mac and therefore Xamarin. On Windows I also updated from Visual Studio 2015 to 2017.
After the updates, Android version works still fine.
The iOS App pairs, compiles and provisions successfully, but whe the App starts (either on simulator or real device), it shows the launch screen and after a few seconds quits back to home screen. It even says "successfully launched" but then terminates
The only logs I get are:
"The app has been terminated" -> on windows, in Debug Window
"Service exited due to SIGABRT" -> on mac, in simulator log file
I searched the web and tried lots of stuff:
Delete obj and bin folders
Clean, Rebuild, Restart VS, Restart Mac, Restart PC, Restart....
Deleted all Provisioning Files and Certificates, recreated them
Used Automatic provisioning, used Manual provisioning
Debug and Release Configuration
iPhone Simulator and Real Device
Sadly nothing worked and I cannot get more info why this happens.
Does somebody have or had the same issue and found a solution? Do you have suggestion what more I can try?
I would really appreciate any help.
Thanks
Edit:
As requested, a Screeshot of my build properties:
I am having the same issue. Restarting the device seems to be the only thing that works, but it's unreasonable to have to restart the device every time I want to run the debugger.
So I finally solved the problem...
I created a new iOS-Project from scratch, added the existing Xamarin.Forms project and copied the files from the original iOS project one by one. I also downgraded all firebase plugins from 5.x versions to the highest 4.x versions and xamarin forms from 3.x to 2.5.x and now the app runs in the simulator and bundle signing works also.
Thanks for your help, I hope my answer will help anyone with similar issues

Visual Studio 2017 / Xamarin fail to run app on iPhoneSimulator

** solved by trial and error, see comments **
Anyone who can help me troubleshoot the process of loading an iOS app into the XCode iPhoneSimulator?
Recently I set up the latest VS 2017 + Xamarin + XCode on my Mac Pro (MacOS 10.12.6 "Sierra"). I created a portable HelloWorld app with Xamarin, and it runs fine on the iPhoneSimulator, so everything is wired together correctly. I did also try a HelloWorld in XCode, it runs in the simulator too.
Today I loaded a sample app from GitHub, which is also a portable app supporting Android and iOS. After unloading the .Droid hive, I could successfully build it, no errors of any kind.
But if I try to run it in the iPhone simulator, the simulator starts, but then nothing happens any more, obvioulsly the app doesn't get executed, or an attempt to execute it is made, but fails silently. Other Xamarin apps appear on the iOS start screen, this one doesn't, it seems like it never reaches the simulator, or is rejected for some reason. System log shows nothing unusual. Usual steps to clean up the application and get an entirely new build (delete .obj and .bin and then rebuild all) have been tried, but no success.
Can anyone give me instructions ho I can do further troubleshooting? On Windows, I'd try to load the ready built apk into the simulator from a terminal window, sometimes this gives additional error infos, but on the Mac I have no idea how to accomplish this. What I can say though is that the build creates a ton of files in the debug directory (.exe, .dll, .pdb), but from ther I don't know how to proceed further.
The .Droid hive of the same application compiles and runs perfectly on my Windows host under the Android simulator.

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.

DEP3316 Error - Cannot deploy to Win10 Phone from Visual Studio 2015

I am unable to deploy an application via Visual Studio 2015 Update 2 to my Lumia 650. In the past it was possible but now I get the following error indicating to change the build configuration of a project or add an ARM device.
The build config is set to 'ARM', the device is connected via USB and my configuration manager looks like this.
The platform targets seem correct, so the config setting 'ARM' points to the platform target 'ARM'. I can run the app on my local computer, but I cannot deploy it to my phone. I also can't run the app in an emulator because if I choose the setting, VS does not change the caption and accept it. I don't have any more ideas.
If it helps I could provide my .sln file with all build configurations if desired. The only thing I did was checking out my source code to a new location on my hard drive. Since then I couldn't deploy anymore. Someone got any hints?
UPDATE:
I cannot deploy to my phone, run the app in an emulator or run the app in the simulator. The only thing that works is running on the local machine. Even all new apps I create cannot be deployed or run in an emulator or simulator. Visual Studio and SDK repair installation was made, no notable change.
If I load an old Windows Phone 8.1 RT or Silverlight project everything works normally, I can use the emulator and I can deploy it to the phone.
Right click your app in VS -> Properties -> Debugging
There is a combo box to select the target device. In my case there was no selection and I chose 'Device'. Now it works again.
https://dotblogs.com.tw/billchung/2016/04/03/051455

Resources