PPT de la primera reunión de la comunidad de usuarios Barcelona Mobile .NET Developers Group.
Nuestro primer meetup fue ser un acto informal en el que nos conocimos todos y realizamos una primera revisión sobre cómo crear aplicaciones móviles iOS, Android y Windows Phone con Xamarin.
Azure Tech Frogs La vida despues de Xamarin NET MAUI y el desarrollo de apps....
Introduction to xamarin
1. Go Mobile with C#
and Xamarin
BCN Mobile
.NET
Developers
Group
Softmachine
2. Borja García Cueto
@borjagarciac
Mobile & Core Developer en International Softmachine Systems SL
José Antonio Reyes Guerrero
@jareyesguerrero
Arquitecto de Software en International Softmachine Systems SL
Barcelona Mobile .NET Developers Group
@bcnmobilegroup
Blog: http://bcnmobilegroup.azurewebsites.net/
3. (*) Consumición válida tras la finalización de la charla.
Patrocinadores - Es de bien nacido…ser agradecido
Dougall’s 942
Cerveza Pale Ale
Alcohol: 4,2%
Ingredientes:
Maltas: Maris Otter y Caragold
Lúpulos: Cascade y Simcoe.
Levadura: ALE
Dougall’s KAJUN
Cerveza Moonshiner IPA
Alcohol: 7,0%
Ingredientes:
Maltas: Maris Otter y Biscuit
Lúpulos: Mosaic, Citra, Centennial,
Chinook y Cascade.
Levadura: ALE
Agua
Formación, material, comida, …
¡Estar atentos! al final de la charla sortearemos algún regalo
de Xamarin.
Formación, tiempo, recursos, apoyo …
Softmachine
Y para los cerveceros*…
Sala de reunión, material …
¡Y COMIDA!
4. Patrocinadores - Softmachine
Empresa especializada en el desarrollo e implantación de sistemas de Gestión Horaria,
Control de Accesos, Información Corporativa y Movilidad.
Ayudando a gestionar personas.
Conciliación
Familiar
Empleados
Contentos
Aumento
Productividad
5. Patrocinadores - Softmachine,
Soluciones
Gestión horaria, Control de accesos, Planificación horaria, Gestión del comedor,
Control de Externos, Portal del empleado, Productividad, Tempo Mobile, …
Tempo Mobile
Aplicación de movilidad integrada
con la suite Tempo y disponible
para iPhone y Android.
• Marcajes (inicio/pausa/fin).
• Control zona geográfica
permitida.
• Modo compartido.
• Modificación de datos personales.
7. Desarrollo móvil - Enfoque clásico
Nativo, desarrollando 3 Apps
‘iguales’
• Varios equipos especializados.
• Mucho código repetido.
• Diferentes herramientas.
• …
8. Enfoque: escribe una vez, ejecuta en todos los sitios
• Mínimo común denominador.
• Fragmentación del navegador.
• Rendimiento no nativo.
• Desarrollas y diseñas una única vez, pero…
HTML5 + CSS3 + Javascript
• ¿Rendimiento?
• ¿Experiencia de usuario?
• ¿Calidad del código?
9. Enfoque Xamarin (Clásico)
• Interface de usuario nativa.
• Rendimiento nativo.
• Código compartido.
• C# & .NET Framework
• Cobertura total de APIs.
10. Con Xamarin.Forms:
mas código compartido (controles nativos)
Enfoque tradicional de Xamarin
Shared UI Code
Enfoque Xamarin.Forms
12. First
release of
Xamarin.Mac
Launch
Partner
Program
200,000
Developers
Xamarin
Founded
First release of
Xamarin.Android
Xamarin.iOS launches
(originally known as
MonoTouch)
Ximian
Founded
No es flor de un día…
2001 2003 2009 2011 2012 2013
Mono
Launches
Ximian Acquired
by Novell
Xamarin 2.0
Component Store
Xamarin Test Cloud
Evolve 2013
Microsoft Partnership
500,000
Developers
100+ Partners
100+ Components
2014
//
Xamarin 3
2000
SAP Partnership
Fire TV Support
Salesforce partnership
Visionary in Gartner
Magic Quadrant
Google Glass Support
Visual Studio Partner
of the Year
Android Wear Support
Xamarin Evolve 2014
800,000
Developers
200+ Partners
200+ Components
2015…
13. Barcelona, 26-31 de Octubre 2014
Cloud First Mobile First+
+
Microsoft apuesta
por Xamarin! ¿Y para los amantes del HTML?
14. C# => productividad = true;
• Soporte para LINQ
• XDocument: XML fácil.
• Eventos y delegados.
18. Json.NET, con SerializeObject y DeserializeObject
permite una conversión sencilla entre JSON strings
y objetos .NET.
C# JSON => JSON.Dificultad = Dificultad.Facil;
20. Xamarin.iOS utiliza la compilación
Ahead Of Time (AOT) para producir un
binario ARM de Apple’s App Store.
Rendimiento nativo
Xamarin.Android se aprovecha de
la compilación JIT (Just in Time) en
los dispositivos Android.
21. Xamarin - Siempre actualizado
Xamarin ofrece soporte inmediato tras
cada publicación de actualización:
iOS 8 liberado el 17 de Septiembre del 2014.
Compatibilidad Xamarin con iOS 8: 18 de Septiembre.
24. Compartiendo código: desarrollo acelerado.
Estadísticas de iCircuit
Más del 90% del código compartido.
Nuget: Reutilización de librerías ya existentes.
iOS Android Windows Phone
25. Tempo Mobile
Aprovechando nuestros conocimientos de POO, C# y .NET
para un desarrollo ágil:
• Mantenibilidad —> SOLID, patrones, …
• Uso de genéricos.
• Inyección de Dependencias —> Unity.
• Pruebas unitarias —> Unit, RhinoMocks.
• Expresiones Lambda.
• LINQ.
• Web API
27. Xamarin es la mejor forma de…
Desarrollar Testear Monitorizar
28. …y además Xamarin Profiler (Preview) - Mac y PC
Dos instrumentos
Tracking Memoria (allocations)
Tracking Rendimiento (time profiler)
Arbol de llamadas
Navega por las funciones en el orden
que han sido llamadas.
Muestreo
Revisa donde esta gastando más tiempo
tu aplicación.
Snapshots de memoria
Obtén información de la memoria
utilizada en diferentes tiempos.
29. Otra alternativa:
(https://www.genymotion.com/)
…y además Xamarin Android Player (Preview) - Mac y PC
Emulador android rápido
Disponible para Mac y PC.
Ejecución “side-by-side” con el emulador de WP.
Gratuito (https://xamarin.com/android-player).
38. Integración con Visual Studio
Una única solución para:
• iOS
• Android
• Windows Phone
• Windows Store
Disponibilidad de todo el
ecosistema de Microsoft:
• ReSharper
• Team Foundation Server
• …
39. Debug en:
• Emuladores
• Dispositivos
Integrando en el toolbar
• Estado
• Logs
• Lista de servicios
Integración con Visual Studio
40. Xamarin Studio
• Optimizado para el desarrollo móvil
multiplataforma.
• Explora las APIs nativas con ‘code
completion’
• Diseñadores Android e iOS
• Depuración en emuladores o
dispositivos.
41. Diseñador Android
• Disponible en:
• Xamarin Studio
• Visual Studio
• Crear la UI con drag & drop.
• Multiples tamaño de pantalla,
resoluciones y versiones de Android.
• Layouts guardados en ficheros XML
standards de Android.
42. Diseñador iOS.
• Disponible en Xamarin Studio
y Visual Studio.
• Similiar a los diseñadores de
Visual Studio.
• Soporta todos los elementos
de UIKit.
• Crea y edita componentes
personalizadas o de 3rd.
• Soporte Storyboards.
44. .NET Mobility Scanner
Mide el grado de compatibilidad de código existente:
• http://scan.xamarin.com
• Escanea .exe o .dll para determinar la compatibilidad
• Genera un informe completo.
46. Con Xamarin.Forms:
mas código compartido (controles nativos)
Enfoque tradicional de Xamarin
Shared UI Code
Enfoque Xamarin.Forms
47. +40 Pages, Layouts, y Controls
Desarrollo desde C# ó XAML
Data Binding bidireccional (MVVM)
Navegación
API animación
Dependency Service
Messaging Center
Shared UI Code
Que incluye
51. Xamarin.Forms Example
En tiempo de ejecución, las páginas y controles
de Xamarin.Forms son convertidos a elementos
nativos de interface de usuario de cada
plataforma.
52. Inserta vistas personalizadas
Utiliza vistas construidas mediante
Xamarin.iOS y Xamarin.Android
dentro de páginas de
Xamarin.Forms.
Utiliza APIs de cada plataforma.
¿Necesitas servicios específicos de
cada plataforma (acelerometro,
cámara, …) dentro de una página de
Xamarin.Forms? Xamarin incluye
servicios de acceso rápido y sencillo
APIs de específicas de cada
plataforma.
Extensibilidad
58. Resumen
• Xamarin permite crear aplicaciones nativas en iOS, Android, Mac y Windows mediante
.NET y aprovechando toda la potencia de C#.
• Las aplicaciones implementadas mediante Xamarin tienen un Look&Feel nativo porque
son nativas. Ofrece un 100% de cobertura en las APIs de desarrollo de cada plataforma,
estando siempre al día en cuanto a actualizaciones se refiere.
• Posibilidad de desarrollar en Mac o Windows mediante Xamarin Studio, o instalando el
plugin de Xamarin para Visual Studio.
• Mejora los tiempos de desarrollo y los costes mediante la compartición de una gran
cantidad de código.
• Prueba de forma automática tu APP en miles de dispositivos reales mediante Xamarin
Test Cloud.
• Obtén información de los dispositivos de los usuarios mediante Xamarin Insights.
59. ¡Regalos….REGALOS…!
• A parte del framework de desarrollo, ¿Qué otras “patas” componen la plataforma
Xamarin?
• ¿De cuantos Layouts dispone Xamarin.Forms?
• ¿En qué año nació el embrión del actual Xamarin y como se llamaba?
Let’s talk about the state of mobile development today
Multiple Teams
Multiple Code Bases
Expensive & Slow
Positive = Great apps delivered to user’s platform
Negative = Development hampered by multiple code bases & fragmentation
Unhappy Users
Unhappy Developers
Increase in Abandoned Apps
Limited to what is implemented
UI build natively per platform, leveraging C#
C# + XAML
C# + XML
C# + XIB
One shared app logic code base, iOS, Android, Mac, Windows Phone, Windows Store, Windows
Xamarin recently introduced Xamarin.Forms a new library for cross platform user interface. We will touch up on this later, but this enables you to be highly productive, share code, but build out UI on each platform and access platform APIs.
With Xamarin.Forms you now have a nice Shared UI Code layer, but still access to platform APIs
You can start from native, pick a few screens, or start with forms, and replace with native later
Let’s talk a bit about why you would choose Xamarin as your development platform.
Major announcement at the end of 2013:
Truly Portable Class Libraries
Support for VS 2013
Special offers for MSDN Subscribers
20 City Roadshow!
Statically typed so you avoid a pitfall of errors that afflict other languages.
Use LINQ in your Xamarin projects to query, filter and select data from in-memory arrays, or from databases such as SQLite.
Parsing XML is easy
Setting up event handling is a breeze
Intellisense, lambdas, etc. are all awesome.
The async and await keywords in C# 5.0 now available to Xamarin developers make asynchronous programming incredibly pleasant.
You end up with code that is much more linear and much easier to understand.
The compiler does a lot of magic for you which simplifies your code and your life.
With Xamarin we even extend native methods with C# Features
Here there is no need for a callback block, simply await on the animation to finish before continuing on
Here is an example of creating a class with a method to get names
1 Line with LINQ to execute this command
Take advantage of C# features and set properties easily
Here we can see how easy it is just to do a += for an event and not have to implement a bunch of listeners every time. Easy to read, string.Format, using args, etc.
In fact we can make this call Async/Await by just adding async to the delegate!
Use your favorite libraries like Json.NET!
There is no compromise on performance.
Xamarin apps look and feel native because they are native.
Apple has a developer preview where Xamarin has alphas ready. Google does not offer this.
Android versions are usually 4 to 8 weeks out for a stable release, but alphas and betas are usually earlier.
Xamarin realizes how important having iOS ready because within 24 hours a large portion of iOS users upgrade
Android on the other hand is much different. After 4 months on the market Android 4.4 only had 1% adoption
Compiles down to APK or IPA that you can distribute anywhere, any store.
Or even internal enterprise
iCircuit is made by Frank Krueger, a long time Mono & Xamarin developer.
Sharing code lead to 70 to 90% code reuse across platforms speeding up development
Real-time circuit simulator and editor used to design analog and digital circuits
http://praeclarum.org/post/42378027611/icircuit-code-reuse-part-cinq
Let’s talk a bit about C# and why it is awesome.
If you have ever developed for a Windows Platform before these .NET namespaces might look familiar.
However, if we go to a new platform such as Windows Phone or Store we have a new SDK to use and a new set of namespaces.
You can think of iOS and Android development the same with Xamarin. You can see we have all of our .NET namespaces and libraries, but Xamarin give us 100% api coverage of each iOS API in it’s SDK that we access view C#.
The same is true for Android as well.
Portable Class Libraries are awesome!
You can write all of your C# code in one assembly and share across all platforms
Before the Xamarin & Microsoft Partnership PCLs were limited ONLY to Windows Platforms
Now add official support to create and use PCLs in Visual Studio and Xamarin Sudio
Xamarin Studio
PC -> Android
Mac -> iOS, Android, Mac
Visual Studio: iOS, Android Windows
Additionally Supports Visual Studio 2010, 2012, & of course 2013
Additionally support desktop apps on Windows: WPF, ASP.NET, Silverlight, WinForms!
The same Solution & Projects open in BOTH Xamarin Studio and Visual Studio!
Connect to Mac build host for iOS development
Show list of all iOS devices and Simulators to debug on
Shows all Android devices and emulators
X86, Arm, Genymotion..
Take advantage of all debugging power of VS
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!
State of the art features:
View different Themes
View different device sizes
Multi-view editing!
Add high quality pre-built app components directly from Visual Studio.
Includes dozens of beautiful UI controls and web services – adding a theme or a 3rd party library is just a few clicks away
Complements existing .NET NuGet ecosystem
Differentiator: focus on UI controls and themes – we are making developers better designers across all platforms
Generates a full report of all method calls to determine compatibility with Xamarin.Android, Xamarin.iOS, Windows Phone, and Windows 8.
Demo time if so desired
Xamarin recently introduced Xamarin.Forms a new library for cross platform user interface. We will touch up on this later, but this enables you to be highly productive, share code, but build out UI on each platform and access platform APIs.
With Xamarin.Forms you now have a nice Shared UI Code layer, but still access to platform APIs
You can start from native, pick a few screens, or start with forms, and replace with native later
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.
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
You have more than 40 controls, layouts, and pages to mix and match from.
These are all of the controls you have out of the box, you can of course create your own.
What is unique is you get the native control and have access to it.
Consider an Entry Field
On iOS it is mapped to UITextField
Android it is EditText
Windows Phoneit is a TextBox
Here is an example of Xamarin.Forms in action using C# in the code behind to create a login screen. You can see how each is rendered with the native controls on iOS, Android, and Windows Phone.
Xamarin.Forms is extremely extensible as well allowing you to customize controls or add your own. You can always get down and call platform specific APIs, so you aren’t limited in any way.
Demo time if so desired
Demo time if so desired
Demo time if so desired
If you look at the wide range of devices there is no way to tackle everything. These are low numbers for just the top manufactures on Android.
Test Cloud enables you to write Automated Test in C# to run against hundreds of physical devices. This means you get real results from real devices to you know how your app will look, feel, and act on a wide range of devices before your users run into issues.