Inspired by Scott Hanselman’s recent blog on what .NET Developers ought to know to start 2017 I thought I would take it a step further to create a small guide for Xamarin developers creating iOS, Android, and macOS apps in .NET. So I sat down with Chris Hardy and put together a list of Xamarin specific terms and resources.
Before we start, you should totally go read Scott’s awesome blog as it has tons of awesome information. Also, to make this post consumable I broke it down into need/should/nice to know sections and have it broken into iOS and Android too!
When you are ready to get started with Xamarin head to http://developer.xamarin.com, which is absolutely the best place to get started and has been since I started mobile development in 2011. Now, let’s do this!
Where to Start?
Looking to download, learn, watch, and find out more about Xamarin, here are your go to places:
- http://xamarin.com & http://xamarin.com/download: Go read and download Xamarin!
- http://university.xamarin.com/self-guided: Free self-guided training from Xamarin University.
- Xamarin Workbooks: Enables developers to test out APIs interactively.
- http://xamarinshow.com: A weekly development show on CH9 hosted by yours truly.
- http://open.xamarin.com is where Xamarin’s open source initiatives are shown<
Need To Know: Xamarin
- What is Xamarin? The Xamarin platform enables developers to create purely native iOS, Android, and macOS applications in C#, F#, or even VB.NET with 100% native API access and ability to share logic with other .NET applications.
- We have one .NET super optmized runtime that brings .NET to iOS, Android, macOS, IoT, Linux, PS4, Xbox, you name it. It implementes .NET APIs and plays with .NET Standard so you don’t have to worry about the implmentation under the hood.
- “Traditional” Xamarin Development: Sometimes refered to as Native Xamarin development gives developers ability to share business logic of their applications and build out native User Interfaces for each platform with 100% access to every API.
- Xamarin.Forms Development: Offers developers a cross-platform user interface abstraction over iOS, Android, and Windows. UIs can be built in XAML or code behind and the native controls are laid down at run time for each platform. Also offers MVVM (Model-View-ViewModel) features such as data binding and commanding. Native APIs can be accessed via the platform projects and dependency services.
Cross-platform Shared code
There are several ways of sharing code across your different apps:
- PCL (Portable Class Library): often refered to as a Pickle, offers developers the ability to create a “Class Library” that targets multiple platforms. This library actually acts as a reference assembly that exposes an intersection of APIs available on each platform. The more platforms you pick the smaller the API surface available.
- Shared Project: The easiest way to share code across platforms. Acts as “file linking” to share code with platform targets. Advantages are that all platform target APIs are available so you can conditional compile, but can lead to messy code and also doesn’t generate an assembly, the files are linked into the platform project.
- .NETStandard or “netstandard”: The next evolution that seeks to replace PCL and offer developers a truly cross-platform library that can be run on any runtime that implements the API such as Mono, .NET Framework, and .NET Core.
Library Sources
There are a plethora of APIs available in .NET and each platform, but sometimes you want more! Here is where you get them.
- NuGet: NuGet is the package manager for the Microsoft development platform including .NET. The NuGet client tools provide the ability to produce and consume packages. The NuGet Gallery is the central package repository used by all package authors and consumers.
- Component: A Component and the Component Store is a hand curated libary gallery and manager for Xamarin platforms. It offers free and paid libraries that can be installed directly to iOS and Android applications and are created by both Xamarin and several numbers of component creators.
- Plugins: Plugins for Xamarin and Windows to put it simply, are amazing. Enablying you to access native features from a cross-platform API right from your shared code! They are an open source initiative so there are tons of great plugins availble including geolocation, connectivity, and photos. Each plugin is availble under MIT license and can be installed in any iOS, Android, Windows, PCL, or .NETStandard Library via NuGet.
Libraries
There are some really great libraries created by or supported by Xamarin:
- MonoGame: MonoGame is an efficient, flexible, cross platform API for developing 2D and 3D games. It provides the foundation for many cross-platform game engines, but can be used directly in games without being wrapped in a game engine.
- UrhoSharp: UrhoSharp is a cross-platform high-level 3D and 2D engine that can be used to create animated 3D and 2D games and scenes for your applications using geometries, materials, lights and cameras. UrhoSharp - works across mobile, desktop, HoloLens and VR.
- SkiaSharp: SkiaSharp provides a rich and powerful 2D graphics API that can be used to render into 2D buffers. You can use these to implement custom user interface elements and 2D graphics that can be incorporated into your application. SkiaSharp is a .NET binding to the Skia library and inherits the features and power of this library.
- CocosSharp: CocosSharp is an easy to use library for 2D games using C# and F#. It is a .NET port of the popular Cocos2D engine.
Need To Know: iOS
- Extensions: Extensions are widgets that are presented by iOS in standard contexts, such as within the Notification Center, when the user requests a custom keyboard, or when they are photo editing. All Extensions are installed in conjunction with a Container app and are activated from a particular Extension Point in a Host app.
- watchOS: watchOS is a version of iOS that is designed for Apple Watch devices.
- tvOS: Apple has released the 4th generation of the Apple TV hardware featuring a redesigned, touch-enable remote, running the new tvOS operating system (based on iOS9).
- Provisioning Profiles: When you want to put an app on a device or put it in the App Store, you must get a developer account and create a provisioning profile that links your devices, accounts, and machines together.
Need To Know: Android
- Android Wear: Android Wear is a version of Android that is designed for wearable devices such as smartwatches.
- Keystore: Used to sign your android application to ship to app stores.
- Understanding APIs & SDKs: Compile, Minimum, Target, oh my goodness so much to learn and super important. Checkout my short video to walk you through.
Should Know: Xamarin
- Linker: Used to reduce the size of an application for iOS and Android employes static analysis of your app to determine which assemblies are used, which types are used, and which members are used. It will discard anything that is not used :)
- IL - An intermediate language is what is created when compilation occures. As Scott wrote and is a great C# is Apples, IL is Apple Sauce, and the JIT/AOT and Runtime makes Apple Juice
- AOT - Ahead of Time Compilation: Takes IL and compiles it into native code with the intention of executing the resulting binary file natively. This is what Xamarin.iOS uses.
- JIT - Just in Time Compilation: Takes IL and compiles it preperation for running as native code. This is what Xamarin.Android uses.
Should Know: iOS
- Storyboard: Storyboard lets the developer define both view controllers and the navigation between them on a design surface and offers WYSIWYG editing of the application’s user interface.
- XIB: The iOS View XIB template allows adding a stand-alone .xib file that can be attached to some backing class.
- Registrars: Code that exposes managed code to Objective-C. It does this by creating a list of every managed class that derives from NSObject.
Should Know: Android
- Dalvik & ART: Android runtime (ART) is the managed runtime used by applications and some system services on Android. ART and its predecessor Dalvik were originally created specifically for the Android project.
- Multi-Dex: Android app (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536. Multi-Dex creates multiple DEX files for an APK, and should be avoided if possible.
- ABI (Application Binary Interface): A single APK can contain machine code to support multiple different architectures. Each collection of architecture-specific code is associated with an Application Binary Interface (ABI).
- ACW & MCW: Android & Managed Callable Wrappers, this is what enables the .NET side of things to talk to the Java side and vise versa.
- AVD: Android Virtual Devices, are your emulators for Android that you use to debug your apps on.
- HAXM (Hardware Accelerated Execution Manager): Intel’s virtualization software for Windows and macOS that makes your AVDs awesome.
Nice to Know
- Xamarin.Forms Roadmap: An awesome roadmap of upcoming features and fixes for Xamarin.Forms.
- Profiler: The Xamarin Profiler integrates seamlessly with your existing Xamarin toolchain to collect information about your Xamarin apps. Use it to find memory leaks, resolve performance bottlenecks, and add polish to your apps before getting them out the door.
- MVVM (Model-View-ViewModel): The Model-View-ViewModel (MVVM) architectural pattern was invented with XAML in mind. The pattern enforces a separation of the XAML user interface (the View) from the underlying data (the Model) through a class that serves as an intermediary between the View and the Model (the ViewModel). The View and the ViewModel are often connected through data bindings defined in the XAML file. The BindingContext for the View is usually an instance of the ViewModel.
- Custom Linker: If the default set of options is not enough, you can drive the linking process with an XML file that describes what you want from the linker.
Things to Follow
- Releases Blog: Keep up to date on what is happening.
- Xamarin’s Twitter: Tweet Tweet!
- Xamarin Events: All sorts of stuff happening in the Xamarin world
- Xamarin Podcast: When you aren’t listening to Merge Conflict I highly recommend listening to the Xamarin Podcast
- Weekly Xamarin: An awesome hand curated weekly e-mail subscription all about Xamarin!
You made it this far, so why not go even futher. On Episode 29 of Merge Conflict, Frank and I discuss What Developers Ought to Try out in 2017!
Note: I would figure I would add this disclaimer because Scott did. The idea for this post was taken directly from Scott so huge credit for his work. I took a few small snippets from Scott’s blog where I thought it should be duplicated. Additional text was taken from Wikipedia, Google, and Apple’s respective articles and Xamarin/Mono’s documentation.