Understanding Xamarin

As a complete newbie to Xamarin and a new member of mobile app development, I have some questions about Xamarin and how it works, which I couldn't find on the Internet

  • How does Cross-platform Xamarin work? Is it used? I was told that Xamarin said that Xamarin is a cross-platform solution for mobile solutions, but when I start, I see that it actually encourages you to create separate projects for iOS and Android. I understand that this gives us more power, and there are always Xamarin Forms if we want to use the cross-platform interface. In this case, however, I would expect Portable Class libraries to handle all the backend logic, while native projects are only used for the user interface. But when I started, the most basic library for accessing mobile functions (Xamarin.Mobile) is not PCL compatible. What is the use of PCL even in this case?

  • How are cross-platform applications typically created in Xamarin? What is the role of PCL and how can we use cross-platform material?

  • Is there a built-in Xamarin API that allows you to make most of the platform for mobile devices independently? It seems we need to download new libraries from nuGet for every little thing we want to do, which is pretty painful.

  • I hate asking about it. But the only real advantage of Xamarin is that we can code in C # instead of native languages? What I expected is a real cross-platform common code base. If unity can do this, why can't Hamarin do this?

+5
source share
3 answers

As someone who has worked with Xamarin (certified) for over 2 years, I will try to answer your questions:

1) Xamarin is a .NET platform that compiles native code for both platforms. 2 years ago you created projects for each type of your application (Android, iOS, etc.). In practice, this meant that you write "Actions for android" (in the .NET way to do something, but with the same native Android types) and UIViewControllers for iOS. Xamarin.Forms has not been working for a long time and is a solution that will allow you to share the user interface codec, as well as business logic.

2) Depending on the application, either Xamarin.Forms or its own route are selected. In the case of a native route, you will create views for each platform (Android AXML and iOS Storyboarding). In addition, a PCL containing all the business logic will be added. So you can call

var authResult = AuthService.Login(username,password); var settings = SettingsService.GetUserLocalDbSettings(); 

with both iOS and Android, and the business logic for logging in is only once. Xamarin.Forms also allows you to share the user interface by creating XAML layouts in your Xamarin.Forms project. They are converted to the right screen in any OS. Note. This only works with simple layouts (head lists, tabs, etc.). Complex layouts take longer in forms until you switch to native.

3) Xamarin is the only environment that allows you to write .NET for these platforms. There are many available plugins available (for example, connection check). Install them in your own projects and in PCL, and you can check if the application has the ability to connect from PCL or not). Hamarin is a hammer, Nuget offers nails.

4) You can share a lot of code (PCL). My honest experience is that most of the time you will build layouts (views) for both platforms. Business logic (logging in, saving items to an SQLite database) requires the least amount of time to build. UI / design, however, requires much more patience. So yes, you can share all the business logic (since the libraries used respect the PCL profile).

5) Protip: Xamarin offers several free university studies since they were part of Microsoft.

+12
source

I agree with the comment made by Lex Lee above that you seem to be completely new not only in the Xamarin space, but also in the C # development space, but still try to add to the above Eric J, which I think he missed in your answers.

Answer to question 1:

How does Cross-platform Xamarin work? Is it used? People have already answered me, in front of me.

What is the use of PCL even in this case? You did not find the use of PCL because you did not try to use it correctly. This is not for accessing a mobile function from a common code. It is used to write code that is common to all sample platforms for this type of code, maybe "Web Service call", "Business Logic", etc.

Answer to question 2: This is a very general question, the answer of which is given many times by many people. The best place to learn more about Xamarin is by following the Xamarin Developer's Guide

Answers to Question 3: As already mentioned, Lex Li Nuget is the core of the .Net distribution, and you should use it not only for this reason, but also because it simplifies development and deployment. Like: 1) You do not need to worry about where to store the DLL (GAC / Local)
2) No need to store a specific version of the DLL, for fear of losing it, all versions are stored on Nuget servers, and Visual Studio automatically downloads the one that is mentioned in you. Package configuration. 3) You can use the preview version of any DLL in one project and the Stable version in another without worrying about any collision.

Answers to question 4: I think that all the advantages are already mentioned in the answers above, I would ask you to first try to work with Xamarin sincerely, and then start talking about it.

0
source

Unless you learn Xamarin as part of a larger C # ecosystem, questions and answers will be difficult to digest.

1 and 2: view of the worst questions. So many use Xamarin. PCL dies if you really know how C # and .NET go. The standard and standard .NET library will be in the future and is already supported by the latest beta versions of Xamarin.

3: NuGet is the core of the .NET package distribution (e.g. npm for JavaScript), and every C # programmer should use it. If you can't get used to it, well, nobody forces you to start your own tool chain.

4: Then why not use Unity? What are you waiting for? Xamarin has its target user groups, and these guys really appreciate that only shared code should be shared. People really love the platform-specific user interface, as it fits nicely into their own platforms.

-2
source

All Articles