Chapter 9. Third-party Libraries

Xamarin supports a subset of the .NET framework, but for the most part includes all the standard APIs you would expect in the .NET base class libraries. Because of this, a large portion of C# open source libraries can be used directly in Xamarin projects. Additionally, if an open source project doesn't have a Xamarin or portable class library version, many times porting the code yourself can be very straightforward. Xamarin also supports calling native Objective-C and Java libraries, so we will explore these as additional means of reusing existing code.

In this chapter, we will cover the following:

  • The Xamarin Component Store
  • Porting existing C# libraries
  • Objective-C bindings
  • Java bindings

The Xamarin Component Store

The primary and obvious way to add third-party components to your project is via the Xamarin Component Store. The Component Store is fairly similar to NuGet on Windows, except that the Component Store also contains premium components that are not free. All Xamarin components are also required to include full sample projects and a getting started guide, while NuGet does not inherently provide documentation in its packages.

All Xamarin.iOS and Xamarin.Android projects come with a Components folder. To get started, simply right-click on the folder and select Get More Components to launch the store dialog, as shown in the following screenshot:

The Xamarin Component Store

At the time of writing this book, there are well over 100 components available to enhance your iOS and Android applications. This is a great place to find the most common components to use within your Xamarin applications. Each component is complete with artwork, possibly a demonstration video, reviews, and other information you would need before purchasing a premium component.

The most well-known and useful components are as follows:

  • Json.NET: This is the de facto standard for parsing and serializing JSON with C#
  • RestSharp: This is a commonly used simple REST client for .NET
  • SQLite.NET: This is a simple Object Relational Mapper (ORM) for working with local SQLite databases in your mobile applications
  • Facebook SDK: This is the standard SDK provided by Facebook for integrating its services into your apps
  • Xamarin.Mobile: This is a cross-platform library for accessing your device's contacts, GPS, photo library, and camera with a common API
  • ActionBarSherlock: This is a powerful ActionBar replacement for Android

Notice that some of these libraries are native Java or Objective-C libraries, while some are plain C#. Xamarin is built from the ground up to support calling native libraries, so the Component Store offers many of the common libraries that Objective-C or Java developers would leverage when developing mobile applications.

You can also submit your own components to the Component Store. If you have a useful open source project or just want to earn a little extra cash, creating a component is simple. We won't be covering it in this book, but navigate to http://components.xamarin.com/submit for full documentation on the subject, as shown in the following screenshot:

The Xamarin Component Store
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.252.23