0

I am new to the Xamarin and trying to create Liveswitch project (https://help.frozenmountain.com/docs/liveswitch/release-notes)

Project this : Liveswitch demo project have Xamrine project which had below structure:

Shared project (it has Chat.shproj) 
Android project
iOS project

I wanted to create Xamrine Project

Xamarin Project (this has Chat.csproj) 
Android Project 
iOS project

When i try to use. Xamarin Project (this has Chat.csproj) and code app.xaml.cs like below :

#if __ANDROID__
using Android.Content;
#endif

    using FM.LiveSwitch;
    using System;
    using Xamarin.Forms;

    namespace Chat
    {

         public partial class App : Xamarin.Forms.Application
            {
        #if __IOS__
                public App()
                {
        #else
                public App(Intent screenshareIntent)
                {
        #endif
                    InitializeComponent();
        #if __IOS__
                    MainPage = new NavigationPage(new SessionSelector());
        #else
                    MainPage = new NavigationPage(new SessionSelector(screenshareIntent));
        #endif
                    AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                }

It shows me error that Intent not found. i.e it is not allowing me to write conditional coding for method definition for Android and iOS in different way.

But in Shared project it is allowing me to write it. Is there any way i can do that in Xamarin project ? I am using visual studio for MAC version 8.5

Other problem is if i user Shared project and try to use

LoadApplication(new App(screenCaptureIntent));

MainActivity.cs not able to find files in the sharedproject. How can i connect files of shared project with files in android and iOS project in Xamarine.

ios developer
  • 3,363
  • 3
  • 51
  • 111
  • 4
    your Xamarin project is most likely a .NET Standard library. You cannot use conditional compilation because the project is always built for the same framework. It does not know if it is an Android or iOS project at compile time. The shared project in the demo is mostly likely an older Shared Project which has been deprecated in favor of .NET Standard. Forms contains multiple different methods for utilizing platform specific behavior other than conditional compilation. – Jason Mar 26 '20 at 17:50
  • Thank you for the reply. which method is best to use in this case to avoid conditional coding for the method ? – ios developer Mar 26 '20 at 18:18
  • 1
    @iosdeveloper Seems like you are referring old PCL project code. Its not supported anymore. have a look at [Xamarin Forms Samples](https://github.com/xamarin/xamarin-forms-samples) which make use of .Net Standard shared project as opposed to PCL – Morse Mar 26 '20 at 21:31

0 Answers0