When I run app with debug from Visual Studio in IOS Emulator, app launches, shows splash screen and then crashes.
Visual Studio continue showing normal behavior like it is still attached to debug process and everything go according to plan.
When I launch that same app on emulator manually, it works perfectly.
Debug log always as this:
Loaded assembly:
/Users/admin/Library/Developer/CoreSimulator/Devices/40C63365-3924-44EA-9145-AAF5F59D170F/data/Containers/Bundle/Application/FED2C1CB-FD8E-441A-856C-66981DB384B5/WebtutorMobileX.iOS.app/Xamarin.iOS.dll
[External] Loaded assembly:
/Users/admin/Library/Developer/CoreSimulator/Devices/40C63365-3924-44EA-9145-AAF5F59D170F/data/Containers/Bundle/Application/FED2C1CB-FD8E-441A-856C-66981DB384B5/WebtutorMobileX.iOS.app/System.dll
[External] Loaded assembly:
/Users/admin/Library/Developer/CoreSimulator/Devices/40C63365-3924-44EA-9145-AAF5F59D170F/data/Containers/Bundle/Application/FED2C1CB-FD8E-441A-856C-66981DB384B5/WebtutorMobileX.iOS.app/Mono.Security.dll [External]
After that app crashes and nothing happens. Visual Studio stays in blessed ignorance.
No errors whatsoever.
This began after I upgraded to 4.7.0.1179 and XCode 11.6. Visual Studio 2019 16.6.5.
Changing iOS Linker settings to "Link Framework SDKs Only" has fixed it for me (if someone still has this problem in 2022).
VS for Mac 17.3.8 - XCode 14 - XF 5.0.0.2515
Put a try/catch block in the Main.cs file in the xamarin.ios project and a breakpoint in the catch block, it usually tells you what wrong in this kind of crash.
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
try
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate");
}
catch (Exception ex)
{
//Breakpoint here
}
}
}
Visual Studio Version 16.7.4 + Xamarin IOS 14.0, debug working again.
Related
(Microsoft Windows 10 VS2022)
I have a basic Xamarin App that I have been working with and deploying on my Android Phone. (works great on Android.)
I created a Apple Developer Account and added those details into Visual Studios 2022.
I plugged in an iPad and started debugging.
The app launches and Hot Reload at the bottom says Launch succeeded.
But the screen only shows the Blue default Xamarin page that initially loads as default. It never goes past that - I don't get any errors. And all my breakpoints set at all spots on the App.xaml.cs page and AppShell.xaml.cs page never get triggered.
Is it a navigation issue with my AppShell.xaml.cs?
Or what could I be missing? Where do I look to see where it is hanging?
public App()
{
MainPage = new AppShell();
}
public partial class AppShell : Xamarin.Forms.Shell
{
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute(nameof(MainPage), typeof(MainPage));
}
}
It appears I may have found the solution.
I updated the iPad (only one revision back; it's at 15.4 now)… I don't think that was the issue.
I think I had not "Built" the app prior to debugging. This resulted in a bad version being stored on the iPad. (You must delete the app with each change.)
To help - If you have a Windows machine developing on Apple iOS:
When developing on a Windows (win) 10 machine. You have to do a full build First!
Build - Build Solution.
Then debug/deploy on apple device.
Every change made - you must delete the app off the Apple device, Build, and re-deploy. This is the only way I can get it to work.
I try to use HockeyApp on a iOS project with xamarin forms.
It's working fine on android, but I can't get it working on iOS.
Here's my AppDelegate code for HockeyApp:
var manager = BITHockeyManager.SharedHockeyManager;
manager.Configure("----");
manager.CrashManager.Init();
manager.LogLevel = BITLogLevel.Verbose;
manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
manager.StartManager();
manager.Authenticator.AuthenticateInstallation();
if (BITHockeyManager.SharedHockeyManager.CrashManager.DidCrashInLastSession)
{
runInSafeMode = true;
Thread.Sleep(5000);
}
Then, later in my code I throw an NotYetImplementedException.
The exception is correctly catched and send to the server on android, but I can't get it working on iOS.
BITHockeyManager.SharedHockeyManager.CrashManager.DidCrashInLastSession is always false.
I also tried without the debugger attached as I read that the debugger catch exception before the SDK, still not working.
Any ideas ?
EDIT : Additional informations
I tried Visual Studio Mobile Center, working fine on android, same issue with iOS, HasCrashedInLastSessionAsync always to false
I moved the throw exception outside of the main method, just in case of, still the same problem, exception looks like not detected by the API
I disabled the debugging in addition of not attaching the debugger, I also tried to compile in Release, nothing new.
I removed the call to Init and AuthenticateInstallation, still the same problem.
Where do you put your Hockey Init code?
I got it working with global::Xamarin.Forms.Forms.Init(); after the Hockey Init in my FinishedLaunching method.
Something like this:
var manager = BITHockeyManager.SharedHockeyManager;
...
manager.StartManager();
global::Xamarin.Forms.Forms.Init();
I've two weird issues with Xamarin.iOS:
1) NavigationController.PushViewController does work correctly with Debug enabled and NOT with debug disabled.
2) With debug disabled the app crashes after about 60 seconds, but not crash log on the device.
First I noticed the difference between Debug and AdHoc build. But now when I use AdHoc build and turn on 'Enabling debug' it magically works, without further adjustments to settings. Debug symbols are removed and Debug info is set to None.
I saw two other similar questions on this forum and forums.xamarin from a couple of years ago with no answers. I tried different linker and compiler and GC settings on the project but they were not helpful.
Hope someone can help me out.
You can use one hack to get more information about the crash from a device. Since all your code is executable through mono runtime, you can easily catch lots of crashes by wrapping your UIAplication.Main function into a try-catch block, and save the exception string somewhere on the device.
in Main.cs
public class Application {
static void Main(string[] args) {
try {
UIApplication.Main(args: args, principalClassName: null, delegateClassName: typeof(AppDelegate).Name);
} catch (Exception e) {
// save e.ToString() somewhere
}
}
}
I'm trying to install Xamarin.Mobile in a PCL iOS project by NuGet and i'm gotting this error!
Could not install package 'xamstore-xamarin.mobile 0.7.1'. You are
trying to install this package into a project that targets
'Xamarin.iOS,Version=v1.0', but the package does not contain any
assembly references or content files that are compatible with that
framework. For more information, contact the package author.
This is my AppDelegate
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
Xamarin.FormsMaps.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
My SDK version is 10.1.
Xamarin.Mobile is working fine in Android Project.
Any idea how to fix this ?
Use the Microsoft Resolution of problems.
Clean your Solution and Rebuild again.
The Xamarin.Mobile NuGet package is not compatible with a PCL, hence the error. This DLL is meant to be installed into an iOS/Android/Windows app project. There is no cross-platform API for PCL use.
You could use this with a Shared Library instead. Or, you'll need to work in each platform project.
Instead of add the package of Xamarin.Mobile with NuGet, you can try adding Xamarin.Mobile as a component.
Right click the Components folder:
Search and select Xamarin.Mobile on Xamarin Components window:
It might work!
I have a monodroid application that terminates without any notice. When it hits an exception the application just terminates. It was deployed to the device using "Start without debugging" from Visual Studio. When I run it with the debugger in visual studio I do get a break on an exception. Is this normal behaviour for the application to just terminate?
Yes, this sounds perfectly normal. If your application encounters an unhandled exception it will crash, terminating completely. You can take a look at the Android Debug Log to see a log of what happened, including the stacktrace produced from any crashes of the application.