xamarin.ios datetime crashes on device - ios

I made a very simple Xamarin.iOS app but my app crashes immediately when i launched it on the device: iPhone 4 and iPhone 5.
In the simulator and on the iPhone 5s device it works correctly.
Whenever I use a DateTime object my app crash.
I use following versions of Xamarin.iOS:
Xamarin Studio
Version 4.2.3 (build 59)
Runtime:
Mono 3.2.6 ((no/9b58377)
Package version: 302060000
Xamarin.iOS
Version: 7.0.7.2 (Business Edition)
Build date: 2014-17-02 17:43:23-0500
The relevant code (I started with a utility template from xamarin):
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var testDateTime = DateTime.Now;
Console.WriteLine (testDateTime.ToString ());
}
In XCode i become this error: Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Does anyone know a soloution for this type of error?

This issue is caused by using a DateTime object with Xamarin when the region settings were Swiss German. The bug is fixed by Xamarin and will be released later.
In the meantime there is a workaround:
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("de-DE");
Thank you for the great Support Rolf & Xamarin.

Related

Appium getClipboardText() is not working in Android newer version (i.e. >10)

getClipboardText() is giving null value (only for Android-10 devices) even after setting some value to clipboard using setClipboardText(). Setting value is working fine both for android and ios & getting clipboard value is not working in newer version of Android. But it’s working fine in Android-9 versions.
Nothing is getting printed on console.
if (Constants.isAndroidTest) {
sData = ((AndroidDriver<WebElement>) oDriver).getClipboardText();
} else {
sData = ((IOSDriver<WebElement>) oDriver).getClipboardText();
}
This was a problem before Nov 2019 but got fixed in newer versions. Try upgrading your appium version.
Problem Statement : Unless your app is the default input method editor (IME) or is the app that currently has focus, your app cannot access clipboard data on Android 10 or higher.
Reference : https://developer.android.com/about/versions/10/privacy/changes#clipboard-data

Xamarin IOS debug, app crashes with no error

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.

ProjectName.iOS Could not register the assembly 'OpenTK-1.0'

I am pretty new in the Xamarin world and I need some help starting the iOS simulator on iPhone X (12.2) or whatever iPhone version.
For example, when I try to start iPhone X (12.2) simulator and start debugging, I get the following error:
ProjectName.iOS[7769:94324] Could not register the assembly 'OpenTK-1.0': System.TypeLoadException: Could not resolve type with token 01000010 from typeref (expected class 'ObjCRuntime.DeprecatedAttribute' in assembly 'Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065')
...
Unhandled Exception:
System.ArgumentOutOfRangeException: Token 0x2001513 is not valid in the scope of module Xamarin.iOS.dll
Parameter name: metadataToken
I only started to get this error after I have updated my Mac Mini to 10.14.5 Mojave and updated Xcode to 10.2.1 I have updated Mono on both windows and mac. I have made this update in order to be able to debug on my iPhone which updated to 12.3
The thing is that I can debug on my iPhone 6S with no problem, but when I try to debug on the iPhone simulator, that error pops out.
Currently I am using Visual Studio Professional 15.9.12 (latest version at this time).
Any thoughts?
Thanks!
I have updated my Xamarin Forms, I used version 3.6, I have updated it to version 4.0 and ran a clean and rebuild, the problem solved by itself. I am not sure what exactly caused the problem, but this update seems to have fixed the problem for me.

Errors: XPC connection interrupted | Terminating since there is no system app

I recently updated to Xcode 8.1 and coding in Swift 3.
I am developing an iOS app and I get the following errors when the iPad Simulator is placed in the Landscape orientation. I do not get the errors when I use the iPhone Simulator in the Landscape orietation.
XPC connection interrupted | Terminating since there is no system app.
On Xcode 8.0, I did not get these errors. I have restarted my Mac Mini and Reset the Simulator to see if that would clear the errors. Neither worked.
I experienced this behaviour in 2 cases when migrating the code to swift 3:
Forgot to add #escaping:
sendReceipt(completion: #escaping (Receipt) -> () ){
// var to retain the closure
self.completion = completion
}
Adding a value to a Lazy var.
lazy var foo : Example = { return Example() }()
// later in another method
foo = Example()
I found that when I upgraded to Xcode 8.1, I could only target iOS 9.2 (error went away) and not iOS 9.0 as I had done previously.
I did not put an Apple bug report in the system.

On iOS device UIViewController returns System.Reflection.TargetInvocationException instead of actual View

I'm upgrading an existing game to work with iOS 9.2. I'm using Xamarin Studio v5.10.1 (build 6) and Xamarin iOS v9.4.0.0 (I'm current on the Stable and Beta channels).
I've got this piece of code in my UIViewController contructor.
public MainViewController() : base
{
mainView = (MainView)this.View;
mainView.mvc = this;
InitializeDate();
InitializeGame();
GameLoop();
}
On the simulator running iOS 9.2 everything works correctly–this.View returns an instance of MainView which is stored in the instance variable mainView.
On the device, an iPhone 5S running iOS 9.2, this.View throws a System.Reflection.TargetInvocationException (the inner exception is a System.NullReferenceException).
On versions of iOS prior to 7.0 this code ran on the device without throwing the exception.
Moving the code above into ViewDidLoad or ViewWillAppear did not help on the device–the exception is still thrown.
I can post the stack trace if anyone thinks it will be helpful.
Thanks in advance.

Resources