We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

App crashes on iOS with Could not initialize an instance of the type 'UIKit.UIImage': the native 'initWithContentsOfFile:' but works on UWP

Hi Team.

I have a simply SFCombox im my project. It works well on Windows UWP but crases on iOS after load with

Could not initialize an instance of the type 'UIKit.UIImage': the native 'initWithContentsOfFile:' method returned nil.

Please see trace below.

if i comment out the combobox code in xaml file App works.

Any idea what went wrong ?

I am on 20.4.0.50 , Xamarin Forms 5.0.0.2545 and iOS 16.3.1 

Thanks for any advice

Andreas





[0:] An error occurred: 'Could not initialize an instance of the type 'UIKit.UIImage': the native 'initWithContentsOfFile:' method returned nil.

It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.'. Callstack: ' at Foundation.NSObject.InitializeHandle (System.IntPtr handle, System.String initSelector) [0x0008f] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.2.0.2/src/Xamarin.iOS/Foundation/NSObject2.cs:626

  at UIKit.UIImage..ctor (System.String filename) [0x00027] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.2.0.2/src/Xamarin.iOS/UIKit/UIImage.g.cs:105

  at Syncfusion.iOS.ComboBox.SfComboBox.OnDropDownButtonSettingsChanged () <0x114360a28 + 0x00094> in <ef14c659bcf545fb99e08be560fc7789>:0

  at Syncfusion.iOS.ComboBox.SfComboBox.set_DropDownButtonSettings (Syncfusion.iOS.ComboBox.DropDownButtonSettings value) <0x1143606f0 + 0x00042> in <ef14c659bcf545fb99e08be560fc7789>:0

  at Syncfusion.iOS.ComboBox.SfComboBox.SetDropDownButton () <0x114354d10 + 0x00098> in <ef14c659bcf545fb99e08be560fc7789>:0

  at Syncfusion.iOS.ComboBox.SfComboBox.InitialSetUpView () <0x114359f78 + 0x007ac> in <ef14c659bcf545fb99e08be560fc7789>:0

  at Syncfusion.iOS.ComboBox.SfComboBox.Setup () <0x11434c030 + 0x00002> in <ef14c659bcf545fb99e08be560fc7789>:0

  at Syncfusion.iOS.ComboBox.SfComboBox.set_Frame (CoreGraphics.CGRect value) <0x11434b228 + 0x00190> in <ef14c659bcf545fb99e08be560fc7789>:0

  at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr)

  at UIKit.UIControl..ctor () [0x00039] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.2.0.2/src/Xamarin.iOS/UIKit/UIControl.g.cs:66

  at Syncfusion.iOS.ComboBox.SfComboBox..ctor () <0x1143308c0 + 0x004d0> in <ef14c659bcf545fb99e08be560fc7789>:0

  at Syncfusion.XForms.iOS.ComboBox.SfComboBoxRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e) <0x114327890 + 0x00042> in <ef14c659bcf545fb99e08be560fc7789>:0

  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x00172] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:296

  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:158

  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240

  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:119

  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51

  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x0012e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:283

  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:158

  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240

  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:119

  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51

  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x0012e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:283

  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:158

  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240

  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:119

  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51

  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x0012e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:283

  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:158

  at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240

  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:119

  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51

  at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x0008f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:252

  at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr)


3 Replies

VV Vijayakumar Viswanathan Syncfusion Team February 24, 2023 06:21 AM UTC

Hi Andres,

Thanks for contacting Syncfusion support.

We have checked the reported scenario using the iOS 16.2 simulator (XCode 14.2) and it was not reproducing on our end. To better understand the root cause and assist with resolving the issue, it would be helpful if you could provide more detailed information about the scenario in which our control was used, including a sample demonstrating the issue with replication steps.

Could you please confirm whether the reported scenario occurs only in iOS 16.3.1  or in all versions? We have attached the tested sample for your reference. 


Regards,

Vijayakumar V


Attachment: TestComboBoxSample_40df019a.zip


AW Andreas Wegener February 24, 2023 12:28 PM UTC

Hi Vijayakumar.

Thanks for the response.

I was able to fix it by sorting the

FinishedLaunching function to


global::Xamarin.Forms.Forms.Init();

LoadApplication(new App());

SfComboBoxRenderer.Init();

SfCheckBoxRenderer.Init();

Xamarin.FormsMaps.Init();


After that i deleted all bin and obj folder an deployed the app again

we can close the issue



VV Vijayakumar Viswanathan Syncfusion Team February 27, 2023 03:38 AM UTC

Hi Andres,

We are pleased to hear that the reported issue has been resolved on your end. We will close this issue, please let us know if you have any other queries by creating a new forum incident.


Thanks,

Vijayakumar V

.


Loader.
Live Chat Icon For mobile
Up arrow icon