Xamarin Tutorial

What is Xamarin?

Xamarin is a unique framework designed for cross-platform mobile app development. It is an emerged a system of three mobile platforms (iOS, Android, and Windows) to build native applications within a single language- C#.
  • Using Xamarin, you will end up getting apps with native API, native access, and native performance.
  • Using Xamarin, you can do the same things in C# language which you do in Objective-C, Swift, or Java.

Need of Xamarin framework

Before Xamarin, developers think about the native languages for the app development of iOS, Android, and Windows Phones such as Objective-C or Swift for iOS apps, Java for Android apps, and C# or XAML for Windows Phones’ apps. A company needs to hire the developer’s team with the knowledge of native languages. This approach was expensive, has a high maintenance level of keeping resources of the three platform plus cons also as the developers can’t share the code between the three platforms. After having cons by following the Siloed Approach, developers started following another approach of making Web-based apps. This second approach ends as beneficial for saving money and considers writing code once for all. But this also has some cons of not having perfect performance always and not easy to access all native features of the platform always. Xamarin designed as best of the above two approaches making developers able to share code between the platforms using C# as a single language with an ending of the native app.

Xamarin framework Family

There are three members in the Xamarin family:
  • iOS
  • Android
  • Forms
Let’s know these three members: Xamarin.iOS and Xamarin. Android is the UI toolkits used to create native iOS and Android applications with the help of each platform's API and the Mono.NET framework. Xamarin.Forms provide access to developers for a complete cross-platform UI toolkit to build interfaces that work on any device by which they can create a single user interface across all the devices and can share more code without modifying the UI for every platform.

Features of Xamarin framework

Xamarin is overall power combination of native platforms performs with its characteristics such that every platform has its own feature set and the ability to build their native applications makes them different from each other.
  1. Complete Binding for the underlying SDKs– Xamarin exists with full strongly-typed bindings for the underlying platform SDKs in iOS and Android. During development, these bindings offer easy navigation, robust compile-time type checking with fewer run-time errors resulting in higher quality applications.
  2. Objective-C, Java, C, and C++ Interop– Using Xamarin, developers can invoke Objective-C, Java, C, and C++ libraries directly and also get power to use a wide array of third-party code structured in advance. This thing lets them take benefit of iOS and Android libraries existence written in Objective-C, Java, or C/C++. Developers also have Xamarin binding projects to easily bind native libraries of Objective-C and Java using a declarative syntax.
  3. Modern Language Constructs– Xamarin applications written in a single language – C# and constructed with modern enhancements over Objective-C and Java such as Dynamic Language features, Functional Constructs like Lambdas, LINQ, Parallel Programming features, sophisticated Generics, etc.
  4. Amazing Base Class Library (BCL)– Xamarin applications use a bundle of classes (.NET BCL) enriched with exhaustive and streamlined features such as powerful XML, Database, IO, String, Serialization, Networking support, and many others.
  5. Modern Integrated Development Environment (IDE)– Xamarin enriched with modern IDEs (Visual Studio for Mac on Mac OS X and Visual Studio on Windows) that featured with code auto-completion, a comprehensive project template library, a sophisticated Project and Solution management system, integrated source control, and more.
  6. Mobile Cross-Platform Support– Xamarin provides enlightened cross-platform support for all the three major mobile platforms of iOS, Android, and Windows Phone in which applications can be written to share code up to its 90%. Both the development cost and time to market get reduced for mobile developers by using the Xamarin. Mobile library that offers a unified API to access common resources across the three popular mobile platforms.
With the robust and comprehensive feature set, Xamarin fills a void for those application developers who desire to enjoy cross-platform mobile applications development with a single language.

Advantages and Disadvantages of xamarin

PROS of Xamarin Xamarin offers a great environment to the developers for making apps and saves time and resources. It simplifies the development operations with some of the most significant advantages as follows:
  • A single tech stack for faster development: Xamarin is a unique tech stack for faster development using which the developers utilize C# and shared codebases for each mobile platform ( iOS, Android, and Windows) that cover up to 90% of each platform’s specific language, API, and data structure, wrap them in a .NET layer that enables a cross-platform development. Application Development with Xamarin enables developers to accomplish much more with less.
  • Rapid prototyping: Forms provides access to developers for a complete cross-platform UI toolkit to build interfaces that work on any device by which they can create a single user interface across all the devices and can share more code without modifying the UI for every platform.
  • Native performance and user experience: Xamarin makes it possible for developers to access each native API and the complete use of native UI, Bluetooth, and SDKs, etc. The fact is that Xamarin can take full advantage of a system and hardware-specific APIs, both the software-built apps and the apps compiled in each platform’s preferred language will run in a similar way. The users can’t find the difference between the Xamarin built-in app and a native app because there is not any.
  • Reduced time to market: Developing apps with shared codebases saves time that can typically utilize in translating, rewriting or recompiling code to work on different platforms. This convenience shaves the development life-cycle, enabling apps development for all three major platforms at the same instance such that feature parity won’t trickle down slowly from the most popular platform to the least and makes apps deployment fully prepared to all of the platforms at once.
  • Less maintenance: Xamarin built-in apps require less work to update and maintain such that changes made to source file at once can be applied directly to the apps, no need to update the source code of apps individually.
  • Apps for all platforms: Xamarin solves the problem in a case if you found a killer desktop that requires a mobile version or vice-versa, using it developers can create apps for both mobile and desktop experiences at the same instance. With Xamarin, the development teams also cut back on a decision whether to develop apps for just one single mobile platform can be handled simultaneously.
  • Easy to keep updated: Xamarin usually takes 1-3 days for all three platforms if to catch up to the latest features, and that’s why new platform-specific features can be immediately introduced to your apps once it gets updated.
CONS of Xamarin
  • It’s expensive for enterprises: Xamarin is free of cost for the individuals and small organizations, however, expensive for enterprises that need to purchase a license for Microsoft's Visual Studio and the cost of these licenses adds quickly depending on the size and needs of the developers.
  • Without specific wrappers, Xamarin doesn’t support all open-source libraries for Andriod and iOS.
  • Not suitable for apps with heavy graphics. Xamarin does not support implementation for the apps with heavy graphics like creating games need rich UX/UI for which it becomes unsuitable.
  • Larger App Size. Xamarin-based apps are larger (Release up to 3-5 megabytes, debugging around 20 megabytes) in comparison with the native ones.
Also Read: Commonly Asked Xamarin Interview Questions and Answers for Fresher
Reference: https://www.c-sharpcorner.com/article/introduction-to-xamarin-for-beginners/