Book Image

Xamarin Cross-platform Application Development

By : Jonathan Peppers
Book Image

Xamarin Cross-platform Application Development

By: Jonathan Peppers

Overview of this book

<p>Developing a mobile application for just one platform is becoming a thing of the past. Companies expect their apps to be supported on both iOS and Android, whilst leveraging the best native features of both. Xamarin’s tools help solve this requirement by giving developers a single toolset to target both platforms.</p> <p>"Xamarin Cross-platform Application Development" is a step-by-step guide for building professional applications for iOS and Android. The book walks you through building a chat application, complete with a backend web service and native features such as GPS location, camera, and push notifications.</p> <p>This book begins with iOS and Android application fundamentals, then moves on to sharing code, and eventually digs deeper into native functionality. By the end of the book, readers will have successfully built a cross-platform application ready for submitting to app stores. You will gain an in-depth knowledge about the concepts of building cross platform applications.</p> <p>"Xamarin Cross-platform Application Development" also covers native iOS and Android APIs, unit testing, building a real web service with Windows Azure, push notifications, interacting with the camera and GPS, leveraging Java and Objective-C libraries, and finally app store submission. Towards the end of the book you will feel confident in developing your own Xamarin applications.</p> <p>"Xamarin Cross-platform Application Development" will teach you everything you need to know to develop an end-to-end, cross-platform solution with Xamarin.</p>
Table of Contents (18 chapters)
Xamarin Cross-platform Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using preprocessor statements


When using file linking or cloned projects files, one of your most powerful tools is the use of preprocessor statements. If you are unfamiliar with them, C# has the ability to define preprocessor variables such as #define IPHONE, and then using #if IPHONE or #if !IPHONE.

The following is a simple example of using this technique:

#if IPHONE
  Console.WriteLine("I am running on iOS");
#elif ANDROID
  Console.WriteLine("I am running on Android");
#else
  Console.WriteLine("I am running on ???");
#endif

In Xamarin Studio, you can define preprocessor variables in your project's options under Build | Compiler | Define Symbols, delimited with semicolons. These will be applied to the entire project. Be warned that you must set up these variables for each configuration setting in your solution (Debug and Release); it can be an easy step to miss. You can also define these variables at the top of any C# file by declaring #define IPHONE, but they will only be applied within...