TechEd Europe 2014 DEV-B217 Go Mobile with C#, Xamarin, and Visual STudio
Introduction to Cross Platform Development with Xamarin/ Visual Studio
-
Upload
indymobilenetdev -
Category
Software
-
view
1.223 -
download
5
description
Transcript of Introduction to Cross Platform Development with Xamarin/ Visual Studio
![Page 1: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/1.jpg)
Introduction to Cross Platform Development with Xamarin/
Visual StudioBrad Pillow
PillowSoft LLC Indianapolis Mobile .NET Developers Group
April 8, 2014
![Page 2: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/2.jpg)
Who Am I• Co-founder of one of the first video-graphics hardware/software companies in
Indianapolis, Truevision Inc. in 1987
• My 15 seconds of Wikipedia fame: creator of the TGA file format
• Originally developed in C, then we switched to C++ as it matured
• Joined Adobe Systems Inc. in 2002 as a developer on Adobe Premiere Pro
• Became tired of slow development in C++, left Adobe in 2012 and started my consulting company going again, focusing on .NET C#/F#, web technologies and machine learning
![Page 3: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/3.jpg)
Why I Started This Group
• Cross-platform development with .NET is exciting and a lot is happening
• Help evangelize the available tools and the languages, in particular F#
• Xamarin promotes these meet ups (see freebies)
• Looking for a co-organizer
• Looking for corporate sponsors
• Network with others with similar interests
![Page 4: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/4.jpg)
Visual Studio 2013• Only works on Windows
• Allows a developer (without extensions) to build only for Windows (8 and variants) and Windows Phone 8
• Great debugger
• Excellent profiling tools
• Fantastic add-ins like ReSharper
• Alas, no iOS, Android, no Mac, etc.
![Page 5: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/5.jpg)
Typical iOS and Android Development
• iOS: XCode and Objective-C
• Android: Eclipse and Google SDK
• Good news: free
• Bad news: nothing sharable, multiple languages to learn, multiple API’s to learn, etc.
• Enter: Xamarin
![Page 6: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/6.jpg)
How Xamarin Works
• Unify app development in C# for all major device platforms
!• Deliver fully native apps – UI &
Performance !
• Speed time-to-market throughcode-sharing and re-use
!• Businesses can leverage existing C#
skills, tools, teams and code !
• Achieve broad reach across deviceplatforms and escape the Objective-C and Java dead ends
*Slide credit:Xamarin, “Xamarin 2.0 Overview “
![Page 7: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/7.jpg)
Native UI: No Compromises.
Cross-platform field service app for iOS,
Android and Windows 8
*Slide credit:Xamarin, “Xamarin 2.0 Overview “
![Page 8: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/8.jpg)
Code Sharing Case Study: TouchDraw
Released early Sept 2012 Android – Oct 2012
*Slide credit:Xamarin, “Xamarin 2.0 Overview “
![Page 9: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/9.jpg)
Tiny Cuts (early) That I Experienced (MonoTouch)• Initially had issues with value type generics - no reactive extensions
• debugging unstable
• no F# support
• no portable class library support
• little refactoring for C#
• IDE was unstable and had weird UI issues due to GTK
• Amazing how much better tools can get when a company is well funded!
Also see: http://jonathanpeppers.com/Blog/xamarin's-tiny-cuts
![Page 10: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/10.jpg)
Xamarin 2.0 Summary
• Xamarin Studio. A new IDE that streamlines design, development, debugging and deployment of native mobile apps. !
• Xamarin.iOS for Visual Studio. Visual Studio users can build iOS, Android and Windows apps in their favorite IDE.
!
• The Xamarin Component Store. An app store for code, where developers add third-party libraries with a few lines of code, and also add beautiful native UI controls and design themes.
!
• Starter Edition. A free tier that makes it easy for small businesses and individual developers to get started and experience the power of the platform.
!
!
![Page 11: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/11.jpg)
Rich IDE SupportIntroducing Xamarin StudioAvailable on Mac and
Windows
Built from the ground up for cross-platform mobile
development
*Slide credit:Xamarin, “Xamarin 2.0 Overview “
![Page 12: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/12.jpg)
Rich IDE SupportBuild iOS, Android and Windows apps in Visual
Studio
100% language unification across platforms in C# And with Xamarin 2.0 100% IDE unification
across platforms
*Slide credit:Xamarin, “Xamarin 2.0 Overview “
![Page 13: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/13.jpg)
Pre-built appsCustomize and deploy
!Cut and paste useful snippets
!Cross-platform best practices
!
Routing, Time recording !Camera capture of work !Signature capture !Uses MVVM !Uses Xamarin.Mobile !Uses Signature control !Backend integration ready
Field Service App
!*Slide credit:Xamarin, “Xamarin 2.0 Overview “
![Page 14: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/14.jpg)
Pre-built apps
Employee Directory !
Customize and deploy !
Cut and paste useful snippets
!Cross-platform best
practices !
iPhone, Android and Windows !
LDAP-ready !
Gravatar integration !
Uses MVVM !
SQLite data store with a .NET based SQLite ORM on all platforms
*Slide credit:Xamarin, “Xamarin 2.0 Overview “
![Page 15: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/15.jpg)
Xamarin Component Store• Many components already offer async APIs, e.g. Parse!
Powerful, easy to use components http://components.xamarin.com
![Page 16: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/16.jpg)
Now Bundled with Mono
• Reactive Extensions – Possible on iOS with new code gen changes
• F# everywhere • Razor - html template engine • Entity Framework • ASP.NET WebStack
![Page 17: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/17.jpg)
F# Support
• Functional Programming comes to iOS! !
• The pitch is simple: – Fewer bugs – Focus on intent – Reuse C# libraries, experience – More features, less time
![Page 18: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/18.jpg)
Razor Integration
• Sometimes you want to generate HTML • Razor offers a full template system
– Blend HTML and C# – Code completion in HTML
• Easily pass parameters from C# to Template • “static” pre-rendered templates on iOS
![Page 19: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/19.jpg)
New Devices
• Google Glasses (beta)
• Amazon fireTV
• Motorola and others Android watches (beta SDK now)
![Page 20: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/20.jpg)
Xamarin: Per-developer, per platform pricing.
What is the difference between Starter and Indie?
!
Xamarin Starter allows developers to build and publish simple apps,
which contain no more than 64k of compiled user code (IL), and which do not call out to native third party
libraries (i.e., developers may not P/Invoke into C/C++/Objective-C/Java.
See the full product comparison chart.
*Slide credit:Xamarin, “Xamarin 2.0 Overview “
![Page 21: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/21.jpg)
Rich IDE Support
Xamarin Component StoreHigh quality pre-built
components – UI controls, themes & web services
Full IDE integration
*Slide credit:Xamarin, “Xamarin 2.0 Overview “
![Page 22: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/22.jpg)
MonoDevelop / Xamarin Studio
MonoDevelop Xamarin Studio
MonoDevelop Core MonoDevelop Core
Android Mac iOS
Branding Add-In
Open source
Commercial
![Page 23: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/23.jpg)
dtrace probes on MacOS
Major collections and minor collections pause times visualized http://schani.wordpress.com/2012/11/02/sgen-and-dtrace/
![Page 24: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/24.jpg)
Static Compilation
• For systems that don’t support JITing – Apple’s iOS devices – Consoles (PlayStation, Xbox) – Security: when not shipping IL !
• Limited generics support – Static analysis limitations – Some dynamisms in .NET idioms
• LINQ and Value Types
![Page 25: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/25.jpg)
“Attempting to JIT compile method”
!!!System.ExecutionEngineException: Attempting to JIT compile method Foo[]:Bar`1
*Slide credit: [email protected], “What is new in Mono? “
![Page 26: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/26.jpg)
“Attempting to JIT compile method”
!!!System.ExecutionEngineException: Attempting to JIT compile method Foo[]:Bar`1
FIXED
*Slide credit: [email protected], “What is new in Mono? “
![Page 27: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/27.jpg)
Build Speed Improvements
Seco
nds
0
20
40
60
80
Hello World Large App
6.2 6.46.4+Incremental
*Slide credit: [email protected], “What is new in Mono? “
![Page 28: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/28.jpg)
Cocos2D XNA
• XNA port of the popular Cocos2D API – Over 4,000 games built with this API – Well documented, well known !
• MonoGame brings it everywhere – iOS, Android, Windows Phone (7 and 8) – Mac – Windows (GL, DX, , Windows Store) – Xbox360, Amazon Fire, future Google TV Box – Play Station Mobile (PS Vita + Sony Androids)
*Slide credit: [email protected], “What is new in Mono? “
![Page 29: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/29.jpg)
Using Cocos2D XNA Today
• Available as: – NuGet Packages – Templates for VS and Xamarin Studio !
• Source code: – http://github.com/mono/cocos2d-xna
!
• Getting Started: – http://docs.xamarin.com/guides/cross-platform/cocos2d_xna
*Slide credit: [email protected], “What is new in Mono? “
![Page 30: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/30.jpg)
Angry Ninjas - Full Open Source Game
https://github.com/xamarin/AngryNinjas
*Slide credit: [email protected], “What is new in Mono? “
![Page 31: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/31.jpg)
Xamarin.Mobile
• Base class library for mobile services !
• Mike Bluestein’s on Slideshare
*Slide credit: [email protected], “What is new in Mono? “
![Page 32: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/32.jpg)
Xamarin.Auth
!
• Clients for OAuth 1 and OAuth 2 – Includes variations • Stores user credentials • Support non-standard auth schemes • Cross Platform
![Page 33: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/33.jpg)
Xamarin.Social
• Posts statuses, links, images/media to social networks – Access social network APIs using authenticated requests. – Automatically and securely store user credentials using Xamarin.Auth. – Cross Platform !
• Extensible, currently has support for: – App.net – Facebook – Flickr – Pinterest – Twitter
![Page 34: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/34.jpg)
Now all Open Source
• All frameworks: – Cocos2D XNA • http://github.com/mono/cocos2d-xna – Xamarin.Auth • http://github.com/xamarin/Xamarin.Auth – Xamarin.Mobile • http://github.com/xamarin/Xamarin.Mobile – Xamarin.Social • http://github.com/xamarin/Xamarin.Social
!
• Taking patches!
*Slide credit: [email protected], “What is new in Mono? “
![Page 35: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/35.jpg)
MVVMCross• The Mvvm Platform for Xamarin.iOS,
Xamarin.Android, WindowsPhone, WindowsStore, WPF and Mac. Includes databinding support for Android XML, for iOS XIBs and for MonoTouch.Dialog.
• http://vimeo.com/68375201
• Keep your models and “view models” as common code, using device specific views per platform. Also provides many abstractions for various platform services.
![Page 36: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/36.jpg)
Future topics
• F#: functional programming for mobile development • Reactive Extensions using reactive programming in mobile • Open source .NET libraries for use in mobile dev (JSON.NET, etc.) • MonoTouch.Dialog and MonoDroid.Dialog • Using PCL (Portable Class Libraries) • C#/F# Async Deep dive • MonoGame for easy cross-platform game development • MVVMCross for easier cross-platform app development • Cloud services - Parse, Azure, Firebase…. • Hackathon??
![Page 37: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/37.jpg)
Why I Use It
• F# allow me to do very rapid development • Allows me to use F# and C# libs • PCL’s allow me to write core non-UI logic once and share • Rapid turn around time (quick incremental compiles) • Tons of open source libraries • Lots of books and web sites on C#/F# and more on Xamarin every day • With one too I can natively target almost anything out there…even the web
![Page 38: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/38.jpg)
My Dev Environment• I use Git for source control
• I use a Mac and run Xamarin Studio on it, as well as Visual Studio on Windows 8 on a VM with Parallels
• I try to use on F# and fall back to using open source C# libraries
• I have a MacMini server that I use to push my Git commits to (supports a Git server very easily!)
• I have the business editions, but will likely drop back to Indie when they are up for renew. They seem to do all I need.
![Page 39: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/39.jpg)
Free T-Shirt!!!!
http://xamarin.com/sharp-shirt
![Page 40: Introduction to Cross Platform Development with Xamarin/ Visual Studio](https://reader033.fdocuments.us/reader033/viewer/2022042601/554a49e6b4c905293a8b584e/html5/thumbnails/40.jpg)
What Next?
• Meet every month?
• Is this day of the week/week of the month good?
• Anyone want to present next?
• What topics next?