** 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.
Related
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.
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.
I'm new to flutter, after native coding Android and ios, in Android Studio and XCode.
In flutter, I'm writing the code in Android Studio, and testing from there. This all works well for android devices. When I test on ios devices, if I run the app from android studio onto my iphone, it takes age to build. If however, I open the runner project in xcode, and run it from there, it works fine. What I am asking is, does it make any difference if I test my ios device by running the project from xcode or not?
Thanks for the basic question, I'm new to flutter!
I find it odd that it builds so much more quickly directly from Xcode, as all the other two IDEs are doing are building with Xcode via terminal commands, but to answer your question, the output to the device/emulator will be the same either way.
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
I've got a Xamarin Forms app that previously worked well on both android and iOS simulator. After updating VSCode and XCode on Mac, I'm not able to launch it again.
The app builds well, with no errors, but with a warning that says:
Warning MSB3245: Could not resolve this reference. Could not locate the assembly "Xamarin.iOS". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. (MSB3245)
Nevertheless, it compiles, but when I launch the app on debug (or release) mode, it launches the iOS simulator, and then I can see the pause and stop buttons on VSCode as it was running, but the app is not installed in the iOS simulator and I see no changes on the simulator, just the main screen of iOS.
No breakpoints are active and, if in Windows I connect Visual Studio 2017 to a MAC virtual machine, I can launch the app, but it's pretty slow, so I need it to work on the MAC VM.
I've also tried to reinstall XCode and to reset settings on iOS simulator with no luck.
Any thoughs on what could be causing this problem?
First, make sure that all the tool versions are up to date. If the problem persists, you can delete two folders of bin and obj under the iOS project. They retain the old version of compilation information. Once the deletion is complete, you can rebuild your project.
I've solved it. It seems that visual studio didn't have permission to open the default projects folder (I don't know why this changed when I updated it). I've changed the default folder to another path, in my case, Downloads folder, and now the problem has gone. Pretty strange though.