Xamarin One platform to rule them all? Erwin de Groot @ 040 coders - - PowerPoint PPT Presentation

xamarin
SMART_READER_LITE
LIVE PREVIEW

Xamarin One platform to rule them all? Erwin de Groot @ 040 coders - - PowerPoint PPT Presentation

Xamarin One platform to rule them all? Erwin de Groot @ 040 coders .NET frameworks WPF UI SL UI UWP UI iOS UI Android UI MacOS UI Libraries Libraries Libraries Libraries Libraries Libraries Mono Mono Touch Android .NET .NET


slide-1
SLIDE 1

Xamarin

One platform to rule them all?

Erwin de Groot @ 040 coders

slide-2
SLIDE 2
slide-3
SLIDE 3

.NET frameworks

.NET framework WPF UI Libraries .NET Silverlight Xamarin. Mac .NET Core Mono Touch Xamarin. iOS Mono Android Xamarin. Android SL UI Libraries UWP UI Libraries iOS UI Libraries Android UI Libraries … MacOS UI Libraries

slide-4
SLIDE 4

.NET standard

.NET framework WPF UI Libraries .NET Silverlight Xamarin. Mac .NET Core Xamarin. iOS Xamarin. Android SL UI UWP UI iOS UI Android UI MacOS UI .NET standard interface

slide-5
SLIDE 5

Xamarin Forms

Xamarin Forms Xamarin. Mac .NET Core Xamarin. iOS Xamarin. Android UWP Shared UI iOS Android macOS Mono & GTK# Linux

slide-6
SLIDE 6

Xamarin

slide-7
SLIDE 7

Xamarin history

slide-8
SLIDE 8

Xamarin & alternatives

C#, XAML C++, QML C#, UnityScript, Boo Javascript, HTML5, CSS3 Open source MIT license Open source (L)GPL Proprietary Open source Apache License

  • Still maturing
  • No native controls
  • Focus on games
  • No native controls
  • Slow UI
  • No native controls

+ Customizable native controls + Mature rich UI development + Great for games/3D + Fast development

slide-9
SLIDE 9

Visual Studio Xamarin Solution

slide-10
SLIDE 10

From WPF to Xamarin.Forms

WPF Xamarin.Forms

Control Templates Rendering classes WPF names: UserControl StackPanel ScrollViewer DataContext Xamarin.Forms names: ContentView StackLayout ScrollView BindingContext Extended Binding functionality Basic Binding functionality ComboBox Picker ToolTips, Menu, ContextMenu

slide-11
SLIDE 11

Xamarin Bindings Xamarin.Forms

User Interface rendering

UWP StackPanel Button Android LinearLayout Button iOS UIStackView UIButton macOS NSStackView NSButton StackLayout Renderer Button Renderer StackLayout Renderer Button Renderer UI (XAML) StackLayout Button StackLayout Renderer Button Renderer StackLayout Renderer Button Renderer

slide-12
SLIDE 12

Custom renderers

slide-13
SLIDE 13

Custom renderers

slide-14
SLIDE 14

Xamarin.Forms.DependencyService

slide-15
SLIDE 15

Xamarin.Forms.DependencyService

slide-16
SLIDE 16

Xamarin.Forms.DependencyService

slide-17
SLIDE 17

Xamarin.Forms.DependencyService

slide-18
SLIDE 18

My development setup

Laptop

  • Visual Studio Community
  • Android emulators

iPhone SE Mac mini

  • Visual Studio for Mac
  • iOS emulators

iPad Air 2 Android phone (borrowed)

slide-19
SLIDE 19

Encountered issue #1

Deploying app to a device or simulator yields: “Couldn't connect to logcat, GetProcessId returned: 0” No idea what causes this, but when you uninstall the app from the device/simulator and try again, it works.

slide-20
SLIDE 20

Encountered issue #2

  • Dunno. Try again.
slide-21
SLIDE 21

Encountered issue #3

Latest Xamarin doesn’t support old .net standard anymore. Increase the ‘minimum supported windows version’ in the UWP app.

slide-22
SLIDE 22

Encountered issue #4

.NET and Java each have their own garbage collection. What happens when you process a bunch of large (native) bitmaps? Call ‘Dispose()’ on the bitmap when not used anymore, or use the ‘using’ construct. Listen to the ‘OnTrimMemory’ event and invoke the .NET Garbage Collection yourself.

.NET Java

slide-23
SLIDE 23

Encountered issue #5

Compiler keeps complaining that the iOS app requires a LaunchScreen, but the LaunchScreen is there! ‘iPad multitask’ is a new option starting from iOS 11 and also happens to be enabled default. Somehow this causes the strange ‘LaunchScreen’ error. Simply disable the option.

slide-24
SLIDE 24

Encountered issue #6

Xamarin.Forms 3.3.0 and up: removing a custom control from the macOS page causes a NullReferenceException. Issue is known, but not solved yet. Revert back to Xamarin.Forms 3.2.0 SkiaSharp 1.60.3 and older: when a canvas has size 0x0, an OutOfMemoryException occurs Upgrade SkiaSharp to 1.68.0 SkiaSharp 1.68.0 requires Xamarin.Forms 3.3.0

slide-25
SLIDE 25

In conclusion: did Xamarin help?

  • Flexibility
  • Custom renderers
  • DependencyService
  • A single UI definition
  • Once set-up, quickly add features too all platforms.
  • Xamarin.macOS hasn’t matured yet
  • Open source so you can fix it yourself
  • Xamarin & community are pretty fast picking up issues
  • Visual differences between platforms sometimes look awkward
  • You really need those custom renderers