Note Notes on this page indicate areas where Xamarin.Forms has diverged from the material presented in the book. One of the most unpleasant jobs in programming is porting a code base from one platform to another, particularly if that platform involves a different programming language. There is a temptation when porting the code to refactor it as well, but if both platforms must be maintained in parallel, then the differences between the two code bases will make future maintenance more difficult. Cross-platform mobile development This problem is common when targeting mobile platforms. Currently, there exist two major mobile platforms, the Apple family of iPhones and iPads running the iOS operating system, and the Android operating system that runs on a variety of phones and tablets. Another significant platform is Microsoft's Universal Windows Platform (UWP), which allows a single program to target both Windows 10. A software vendor that wishes to target these platforms must deal with different user-interface paradigms, three different development environments, three different programming interfaces, and—perhaps most awkwardly—three different programming languages: Objective-C for the iPhone and iPad, Java for Android, and C# for Windows. The C# and.NET solution Although Objective-C, Java, and C# are all derived from the C programming language, they have evolved by very different paths. C# is the most recent of these languages and has been maturing in very useful ways. Moreover, C# is closely associated with an entire programming infrastructure called.NET, which provides support for math, debugging, reflection, collections, globalization, file I/O, networking, security, threading, web services, data handling, and XML and JSON reading and writing. Xamarin currently provides tools to target the native Mac, iOS, and Android APIs using C# and.NET. These tools are called Xamarin.Mac, Xamarin.iOS, and Xamarin.Android, collectively known as the Xamarin platform. These are libraries and bindings that express the native APIs of these platforms with.NET idioms. Developers can use the Xamarin platform to write applications in C# that target Mac, iOS, or Android. But when targeting more than one platform, it makes a lot of sense to share some of the code among the target platforms. Xamarin is one of the best emerging toolkits for app development. Due to its cross-platform feature more than half of the code can be reused for building android, iOS, and Windows applications. The Xamarin Profiler a graphical interface for the Mono log profiler, and supports profiling Android, iOS, tvOS, and Mac applications on Mac, and Android, iOS, and tvOS applications on Windows. The Xamarin Profiler has a number of instruments available for profiling — Allocations, Cycles, and Time Profiler. ![]() This involves separating the program into platform-dependent code (generally involving the user interface), and platform-independent code, which generally requires only the base.NET framework. This platform-independent code can either reside in a Portable Class Library (PCL), or a shared project, often called a Shared Asset Project or SAP. Note Portable Class Libraries have been replaced by.NET Standard libraries. All the sample code from the book has been converted to use.NET standard libraries. Introducing Xamarin.Forms When targeting multiple mobile platforms, Xamarin.Forms allows even more code sharing. A single program written for Xamarin.Forms can target these platforms: • iOS for programs that run on the iPhone, iPad, and iPod touch • Android for programs that run on Android phones and tablets • the Universal Windows Platform to target Windows 10. Note Xamarin.Forms no longer supports Windows 8.1, Windows Phone 8.1, or Windows 10 Mobile, but Xamarin.Forms applications do run on the Windows 10 desktop. There is also preview support for the,,, and platforms. The bulk of a Xamarin.Forms program exists in a library or an SAP. Each of the platforms consists of a small application stub that calls into this shared code. The Xamarin.Forms APIs map to native controls on each platform, so that each platform maintains its characteristic look and feel: The screenshots from left to right show an iPhone and an Android phone: On each screen, the page contains a Xamarin.Forms for displaying text, a for initiating actions, a for choosing an on/off value, and a for specifying a value within a continuous range. All four of those views are children of a on a.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2019
Categories |