Building native applications across multiple platforms is hard. iOS requires knowledge of Xcode, the iOS SDK and Objective-C or Swift. Android requires Eclipse Android Studio, the Android SDK and Java. The Windows 10 Universal Windows Platform requires Visual Studio, C# and the UWP/WinRT SDK. Are we really expected to learn all of this? You can take the HTML5 & Cordova route, but not all apps should be built using a hybrid approach. If you want to create a truly competitive app with a premium experience, you’ll need to go native. Fortunately, there is a way you can share a lot of your code across mobile platforms and do so using the C# language you already know and love. Xamarin is a powerful toolset that allows developers to write native Android and iOS apps using C#, thanks to the Mono framework – an Open Source project that brings the C# language and .NET to other platforms. This session explores how you can build cross-platform applications for iOS, Android, and Windows 10 using C#. You’ll learn how to get started with a sample cross-platform solution, which tools you can use, how to design a proper user interface for each platform and how to structure your projects for maximum code reuse. We’ll also look at how you can share UI code with Xamarin.Forms. Native mobile development doesn’t have to be so hard. Come learn how your .NET skills can be transformed for true cross-platform development.
Building Mobile Cross-Platform Apps foriOS, Android & Windows in C# with Xamarin
1.
2. Building Mobile Cross-Platform Apps for
iOS, Android & Windows in C# with Xamarin
Nick Landry
Senior Technical Evangelist, Microsoft
AgeofMobility.com
@ActiveNick – github.com/activenick
18. All 3 characteristics are required for a truly native app
Xamarin is native in all 3 ways
Native User Interface
Apps are built with standard, native
user interface controls for easy and
familiar interactions
Apps have access to the full spectrum of
functionality exposed by the underlying
platform and device
Apps leverage platform-specific hardware
acceleration, and are compiled as native
binaries, not interpreted at runtime.
High-fidelity API Access
Native Performance
20. Anything you can do in Objective-C or Java
can be done in C# with Xamarin using Visual Studio
21. Native Performance
Xamarin.iOS does full Ahead Of
Time (AOT) compilation to
produce an ARM binary for
Apple’s App Store.
Xamarin.Android takes advantage of
Just In Time (JIT) compilation on the
Android device.
29. Xamarin + Xamarin.Forms
With Xamarin.Forms:
more code-sharing, native controls
Traditional/Classic Xamarin approach
Shared UI Code
30. What’s included
✓ 40+ Pages, layouts, and controls
(Build from code behind or XAML)
✓ Two-way data binding
✓ Navigation
✓ Animation API
✓ Dependency Service
✓ Messaging Center
Shared C# App Backend
(non-UI code)
Shared UI Code
31. <?xml version="1.0" encoding="UTF-8"?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.MainPage">
<TabbedPage.Children>
<ContentPage Title="Profile" Icon="Profile.png">
<StackLayout Spacing="20" Padding="20"
VerticalOptions="Center">
<Entry Placeholder="Username"
Text="{Binding Username}"/>
<Entry Placeholder="Password"
Text="{Binding Password}"
IsPassword="true"/>
<Button Text="Login" TextColor="White"
BackgroundColor="#77D065"
Command="{Binding LoginCommand}"/>
</StackLayout>
</ContentPage>
<ContentPage Title="Settings" Icon="Settings.png">
<!-- Settings -->
</ContentPage>
</TabbedPage.Children>
Native UI from shared code
At runtime, each Xamarin.Forms page and its
controls are mapped to platform-specific native
user interface elements
Use a single API to generate native, platform-
specific user interfaces
42. Native Dev: Platform Tools or Xamarin?
Platform Tools (Windows, iOS, Android)
• Default native method to build apps
• Free development tools & SDKs
• Requires learning at least one language &
SDK per platform (C#, Java, Objective-C)
• Design, develop & maintain completely
separate apps for each platform
• More learning resources available
• Books, web sites, blogs, training,
StackOverflow, videos, larger
community, etc.
• Yet, iOS developers are (kinda) starting all
over with Swift
Xamarin / Mono
• Reuse existing C# skills & source code (but
you have to know C#)
• Need to buy an additional tool: extra cost
• Need to learn new tools & techniques
• Still need to learn the specifics of each
platform SDK, app architecture & lifecycle
• Fewer third-party libraries available
• Built-in GUI designer for iOS and Android
• Xamarin.Forms provides native shared Uis,
but there is no XAML designer (yet)
• Vendor lock-in / dependency
43. Mobile Strategy Considerations
Audience
• General Consumer
Market
• Niche Consumer
Market
• Enterprise Users
• BYOD
Objectives
• Marketing “Checklist”
Apps
• Brand “Reach” Apps
• Weekend Warrior Apps
• Apps for Profit
• Mobile Revolution
Apps
Other Considerations
• Mobile Population
Coverage Target &
Desired Reach
• Expertise
• Resources
• Timeframe
49. Xamarin Developer Certifications:
Be part of an Elite Developer Community
Students have the option to take a certification test and become Xamarin certified.
Xamarin skills are increasingly in demand – certifications let the market know you
represent top talent.
50. Online Microsoft training delivered by experts to
help technologists continually learn
Hundreds of courses for developers, IT Pros,
students, entrepreneurs and enthusiasts
11 different languages
More than 3M students registered
Build your own Learning Plan
All free!
Cross-Platform Development with
Xamarin & Visual Studio
aka.ms/MVAxamarin
http://www.microsoftvirtualacademy.com
51. • Universal Windows App Development
with Cortana and the Speech SDK
• Available for on-demand viewing now:
http://aka.ms/CortanaMVA
52. Recommended Xamarin Books
http://aka.ms/Xs5v48
Xamarin Mobile Application Development for Android
(Mark Reynolds)
http://aka.ms/Ndl0jn
iOS Development with Xamarin Cookbook
(Dimitris Tavlikos)
http://aka.ms/S8akz1
Xamarin Cross-Platform Application Development
(Jonathan Peppers)
http://aka.ms/Sl5aj9
53. Thank You!
Slides are posted on SlideShare. Demos are on GitHub.
SlideShare: www.slideshare.net/ActiveNick
Blog: www.AgeofMobility.com
Twitter: @ActiveNick
Mobile Apps: www.bigbaldapps.com
LinkedIn: www.linkedin.com/in/activenick
GitHub: github.com/ActiveNick
Email: nick.landry@microsoft.com
Xamarin Studio
PC -> Android
Mac -> iOS, Android, Mac
Visual Studio: iOS, Android Windows
Xamarin Studio is available for Android development on the PC.
Xamarin Studio on Mac offers: Android, iOS and Mac development
World Class IDE with great features:
Code Analysis
Upload to Test Flight
Git & Subversion Integration
Code Completion
Code Navigation
Easy transition from Visual Studio
The same Solution & Projects open in BOTH Xamarin Studio and Visual Studio!
Xamarin.Forms is much more that just a framework and includes everything you need to get up and running to build out full native applications.
If you are used to MVVM type of development you will feel right at home.
Here is a quick example of a login page:
Notice the data binding on the Entries Text fields. Additionally, there is a LoginCommand.
Each has a native user interface
First you have a set of pages for each screen of your application
There are things like Content, and MasterDetail which gives you a nice flyout
With a tabbed view you get the correct look on each platform
iOS on bottom, Android on top, and on WP you have a Pivot control
Inside of a page are layouts
A lot of options from something simple like a stack panel to complex and powerful grids