Adding Syncfusion.XForms.Core and core:OnPlatformOrientationThickness causes iOS App to fail to run

On my initial page in my Xamarin.Forms iOS app I use the following code to position the layout.
xmlns:core="clr-namespace:Syncfusion.XForms.Core;assembly=Syncfusion.Core.XForms"
Margin="{core:OnPlatformOrientationThickness PhonePortrait='20,32',
PhoneLandscape='150,32',
TabletPortrait='200,50',
TabletLandscape='300,50',
Desktop='30'}"
If I do this, the app will not load the initial page, throwing the error:
Foundation.MonoTouchException: 'Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Application windows are expected to have a root view controller at the end of application launch.
If I remove these lines and set the Margin manually, it works fine. I would add it also works on the Android with the above code. So this appears to be an iOS only problem.
I have tried several versions of the Syncfusion libraries, and several versions of the Xamaring.Forms libraries, but the problem is the same.
I have ensured the Syncfusion.Xamarin.Core nuget is included on the both the common library and the iOS app. Are there any other libraries I need to include?
I plan to use the OnPlatformOrientationThickness often through my app, but I cannot seem to make it work in even the simplest of cases. Can you please help where I am going wrong.
Many thanks

5 Replies 1 reply marked as answer

SP Sakthivel Palaniyappan Syncfusion Team July 27, 2020 10:32 AM UTC

Hi Mark,

Greetings from Syncfusion.

We have prepared a sample with our understanding and we have checked the issue in Syncfusion.Xamarin.Core with NuGet Package (18.2.0.46). We have set the OnPlatformOrientationThickness in the code behind and it has been set correctly. Since the Margin API is for the ContentView we have applied to it and ensured the same. Please check with the sample with which we have ensured,

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PlatformSample-2046990583

Please check with the above sample and if still exists,

 * Please modify the above sample with the issue reproducing steps,
 * Provide additional details of the issue and also provide video representation of the issue if possible since we are unaware of the exact application scenario.

The above will help us identify the problem and provide the solution at the earliest possible.


Regards,
Sakthivel P.



MA Mark July 28, 2020 03:18 AM UTC

In the example you sent, you do not actually use the core namespace, which is why I think your sample runs.

I think I have traced the problem, it appears you are not able to use the core namespace unless another Sf control is used on the form as well, i.e. an SfButton. 

It appears to me the Core libraries are only initialised and ready to use when another SF control is used also.  In my example I just needed a method provided in the core class, without any other Sf components.


SP Sakthivel Palaniyappan Syncfusion Team July 28, 2020 07:28 AM UTC

Hi Mark,

Thanks for the response.

We would like to let you know that we have used only the Core namespace and have set the Margin in the MyView.cs page. Please have the below code snippet,

Code Snippet:

 
using System;  
using System.Collections.Generic; 
using Syncfusion.XForms.Core; 
using Xamarin.Forms; 
 
namespace PlatformSample 
{ 
    public partial class MyView : ContentView 
    { 
        OnPlatformOrientationThickness onPlatformOrientationThickness; 
 
        public MyView() 
        { 
            InitializeComponent(); 
            onPlatformOrientationThickness = new OnPlatformOrientationThickness(); 
            onPlatformOrientationThickness.PhonePortrait = new Thickness(10, 20); 
            this.Margin = onPlatformOrientationThickness.PhonePortrait; 
        } 
    } 
} 

If the sample differs please provide the modified sample with the issue reproducing steps since we are unaware of the application scenario at our end which will help us to provide the solution at the earliest.

Regards,
Sakthivel P.
 


Marked as answer

SS Swetha Srikumar Syncfusion Team July 28, 2020 09:07 AM UTC

From: Mark Townsend
Sent: Tuesday, July 28, 2020 3:33 AM
To: Syncfusion Support <[email protected]>
Subject: RE: Syncfusion support community forum 156380, Adding Syncfusion.XForms.Core and core:OnPlatformOrientationThickness causes iOS App to fail to run, has been updated. 
My code this in xml, not code behind.  It did not work, but when I remove the Sf lines from the xml it ran. The only way I could get it to run was by adding another SF control to the view.  Just like I did in the example I sent you. 
Mark Townsend  



SP Sakthivel Palaniyappan Syncfusion Team July 29, 2020 10:20 AM UTC

Hi Mark,

We would like to let you know that in iOS in order to initialize the assembly we have to call a renderer in AppDelegate as below,

Code Snippet:
 
 
SfBorderRenderer.Init();  

We don't require any other control to be initialized in XAML to achieve your requirement. Please check with the same and let us know if you have any concerns.

Regards,
Sakthivel P.
 


Loader.
Up arrow icon