How to view Xamarin.iOS and Xamarin.Android classes from PCL

Asked 2 years ago, Updated 2 years ago, 87 views

Xamarin.iOS and Xamarin.Android have the same class functionality.
This class is implemented slightly differently depending on the characteristics of each device.
I would like to refer to these classes from PCL and generate an instance.

However,
because the above class cannot be found during implementation and compilation. This will result in an error.

Use each PCL resource from Xamarin.iOS and Xamarin.Android resources I can refer to it, but can't I do the opposite?
If you know, please let me know.

ios android c# xamarin

2022-09-30 21:17

1 Answers

Here,

The answers in may be helpful.

However, this method is to "generate instances on Android or iOS, and use the common interface of the generated instances on the PCL side", so

I'm going to refer to these classes from PCL and generate an instance

It may not fit the purpose of .
(Strictly speaking, it is not possible to generate instances of classes on each platform side from the PCL side.)

Another method is called "Bait and Switch."

There are three assembly (DLL file name) classes with exactly the same name for reference from the PCL project, for reference from the Android project, and for reference from the iOS project.

For PCL projects, see 1. for Android projects and 3. for iOS projects.

Then, since the class implemented in 2. is used to run Android apps and 3. is used to run iOS apps, PCL seems to call each platform-specific implementation.

Please refer to the links below for more information on this technique.


2022-09-30 21:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.