Wilson Mar bio photo

Wilson Mar

Hello. Hire me!

Email me Calendar Skype call 310 320-7878

LinkedIn Twitter Gitter Google+ Youtube

Github Stackoverflow Pinterest

Microsoft made it free, as in if you have a license for Visual Studio

Overview

This article is a hands-on deep-dive tutorial about installing and using Microsoft’s Xamarin app development IDE and framework to create iOS and Android apps using the C# language.

This page provides PROTIPs that highlight hard-won experience not available elsewhere.

Competitors

Xamarin’s main competitor in the multi-platform mobile development tools market is Facebook’s React Native, which also generates native code, but from JavaScript coding rather than C# coding.

Although Kony is rated highly by Gartner, it is now focused on volume deals with large shops rather than getting individuals working.

Kivy generates mobile code from Python code. See Russell Keith-Magee’s talk May 2016 about his Python-iOS-template on GitHub and explained on pybee.org and http://omz-software.com/pythonista/

Run-times on mobile

Mono-project is the run-time engine equivalent to Microsoft’s .NET Core on other platforms. It implements .NET APIs and plays with .NET Standard so you don’t have to worry about implmentations “under the hood”.

In fact, there is a single .NET super optmized runtime that brings .NET to iOS, Android, macOS, Apple tvOS, IoT, Linux, PS4, Xbox, etc.

Some marketing materials say “15%-30%” of all code is shared among platforms. But you’ll need to see for yourself.

Xamarin “works with” Android Wear and Apple Watch worn on wrists in the sense that programs (WearService.cs) communicate with them, Xamarin does not actually run on them.

Examples of device platform-specific code include access to:

  • system information (such as battery life)
  • personal information (such as device name)
  • folders and files on the device
  • external devices (such as Bluetooth)
  • notifications

On April, 2016, Microsoft open sourced Xamarin at http://open.xamarin.com/

  • https://github.com/xamarin/xamarin-macios
  • https://github.com/xamarin/xamarin-android
  • https://github.com/xamarin/Xamarin.Forms

PROTIP: Microsoft’s Windows Phone is a dead product.

We are only talking about Android and iOS here when we say “mobile devices”.

Pre-built apps in Azure cloud

Microsoft’s Azure cloud was first announced in 2008 and released in 2010.

CAUTION: This section under construction:

PROTIP: Instead of clicking to download one or more of the Forms apps, first install the app without building from source code from https://github.com/xamarin/app-crm/wiki/Install-the-app-NOW-without-building-from-source-code

Even before software is installed locally, experience a pre-built app running live on Microsoft’s cloud at:

Azure Quick Starts

  1. Get into your Azure

  2. Mobile Apps Quickstart installs a Todo mobile app + SQLite database in Azure.

  3. Defined a unique name for app name among all Azure users.

  4. Create resource.

  5. Select location and pricing tier.

  6. Authentication.

  7. Easy APIs.

TryAppService

  1. https://tryappservice.azure.com/en-us

  2. Select Mobile App. Click Next.
  3. Select one of the pre-built apps, Field Engineer. Click Create.

    xamarin 6 1 1 azure prebuilt mobile apps 451x175

    It’s kept at https://github.com/Azure-Samples/app-service-mobile-dotnet-fieldengineer (formerly https://github.com/azure/fieldengineer by https://github.com/lindydonna/) which has offline-sync features.

    YOUTUBE: About Azure’s mobile services

  4. Login.
  5. Select Xamarin Forms (not JS Web Portal).

    Notice the “Working with your app” has a URL such as:

    https://ab8e8566-0ee0-4-231-b9ee.azurewebsites.net/

    But:

    Your free Mobile App will expire in: 00:00:10".
    Need more time? Click here to extend your trial to 24 hours.

    If you click “Publish” you’ll get XML like this:

    <publishData><publishProfile 
    profileName="ab8e8566-0ee0-4-231-b9ee - Web Deploy" 
    publishMethod="MSDeploy" 
    publishUrl="ab8e8566-0ee0-4-231-b9ee.scm.azurewebsites.net:443" 
    msdeploySite="ab8e8566-0ee0-4-231-b9ee" 
    userName="$ab8e8566-0ee0-4-231-b9ee" 
    userPWD="kCvuSojCcrg98lAlctivJtyRx48lrcwuBNox9EcxZQ0HGxevbx31kxY8nAgl" 
    destinationAppUrl="http://ab8e8566-0ee0-4-231-b9ee.azurewebsites.net" 
    SQLServerDBConnectionString="" 
    mySQLDBConnectionString="" 
    hostingProviderForumLink="" 
    controlPanelLink="http://windows.azure.com" 
    webSystem="WebSites">
    <databases /></publishProfile>
       <publishProfile profileName="ab8e8566-0ee0-4-231-b9ee - FTP" 
       publishMethod="FTP" 
       publishUrl="ftp://waws-prod-cy4-001.ftp.azurewebsites.windows.net/site/wwwroot" 
       ftpPassiveMode="True" 
       userName="ab8e8566-0ee0-4-231-b9ee\$ab8e8566-0ee0-4-231-b9ee" 
       userPWD="kCvuSojCcrg98lAlctivJtyRx48lrcwuBNox9EcxZQ0HGxevbx31kxY8nAgl" 
       destinationAppUrl="http://ab8e8566-0ee0-4-231-b9ee.azurewebsites.net" 
       SQLServerDBConnectionString="" mySQLDBConnectionString="" 
       hostingProviderForumLink="" 
       controlPanelLink="http://windows.azure.com" 
       webSystem="WebSites">
    <databases /></publishProfile></publishData>
    
  6. Click “Clone or push with git” using a link created like this to reach repo named “b8e8566-0ee0-4-231-b9ee” on host scm.azurewebsites.net:

    https://$ab8e8566-0ee0-4-231-b9ee:kCvuSojCcrg98lAlctivJtyRx48lrcwuBNox9EcxZQ0HGxevbx31kxY8nAgl@ab8e8566-0ee0-4-231-b9ee.scm.azurewebsites.net/ab8e8566-0ee0-4-231-b9ee.git

  7. Click to Download the Xamarin Forms client.

Pricing of Xamarin offerings

The marketing home page for Xamarin is xamarin.com. Click on Products.

xamarin ecosystem 20161025

PROTIP: It costs $11,759.50 per person to use the entire ecosystem the first year.

  • $5,999 for Visual Studio Enterprise

PROTIP: Some Microsoft resellers online give discounts.

  • $995 for bootcamp training and tutoring
  • $3,865.50 to test 3 devices
  • $0 for deployment and crash monitoring
  • $0 for Azure cloud to hold transaction data (first $150 per month is free)

  • $1,000 for optional fancy UI controls for Xamarin Forms from Infragistics

Buy MSDN license

  1. To buy the MSDN subscription with an email you’ll be using to build software:

    https://www.visualstudio.com/vs/pricing says Visual Studio Enterprise is
    $5,999 for the first year and then each additional year
    $2,569. However, some Microsoft Partners sell it for less.

    However, Mac users now still need an Enterprise Visual Studio license.

  2. Use the email you used to get your license to login MSDN.com, Subscriptions at:
    https://msdn.microsoft.com/subscriptions/manage/hh442900.

  3. Scroll down to Xamarin Studio (for OSX) and click “Register and Download”.

    NOTE: Xamarin was an independent organization (in San Francisco) which charged $5,697 per user per year per platform.

    See https://developer.xamarin.com/guides/cross-platform/getting_started/license/

  4. To create a Xamarin account if you don’t already have one,
    click Subscribe.

    Microsoft bought Xamarin Feb. 2016 (announced at Build 2016), so there is still a separate system at the end of 2016.

    PROTIP: Notice it’s an annual renewal.

    PROTIP: Work on Xamarin Studio has stopped on Windows. Microsoft is working on a Visual Studio for Mac.

    • Webinar: Visual Studio for Mac 12:54 Nov 18, 2016 by Mikayla Hutchison, Senior Program Manager

    • https://www.youtube.com/watch?v=nMcBWHuhDio Installing and working Visual Studio 2017 for MacOS

    • https://www.youtube.com/watch?v=59N_fJf6UPo First impressions


Install Xamarin Platform IDEs

TODO: A bootstrap script that installs everything needed in a single command.

For installation, Xamarin University classes direct students to these:

  • Mac Setup

  • Windows Setup

    “Platform” here refers to the tools to develop software.

    An Apple Mac machine is needed only to compile code to run on Apple iOS devices. One can NOT be shared. So the MacInCloud service connects each Windows machine with a separate Mac.

    NOTE: Xamarin Studio is customized from the open-source MonoDevelop IDE.

    NOTE: Xamarin Studio is no longer available on Windows.

    Parallels software, not being true virtualization, is an advantage is this case. On a Mac, one can install Parallels software, then install Windows 10 and Visual Studio 2015 for Windows inside that, and you’ll be able to run Windows Phone emulators as well.

  1. If you’re behind a corporate firewall proxy, talk to your security officer about whitelisting these hosts installers reference:

    • dl-ssl.google.com
    • dl.google.com
    • xamarin.com
    • download.xamarin.com
    • dl.xamarin.com
    • log.xamarin.com

    This tip is from https://blog.xamarin.com/installing-xamarin-made-easy-offline-installation/

Visual Studio on Mac

  1. Install Apple’s XCode on your Mac’s App Store.

    NOTE: Each version is related to a specific version of the Apple OS Mac operating system.

    Know the version by clicking on the program name next to the Apple icon, then select “About”:

    xcode about 271x48

    At the time of writing, my pop-up shows “Version 8.1 (8B62)”.

    XCode 7 supports iOS 9.

    PROTIP: Although Xamarin Studio is currently offered, its functonality is being folded into Visual Studio 2017 for Mac, free in Preview until May 31, 2017.

    I predict in the future this will become a paid Visual Studio Enterprise for Mac.

  2. Click to download VisualStudioforMacPreviewInstaller.dmg, 22.8 MB.

  3. Skip to follow these same instructions.

Files installed:

~/.local/share/Xamarin

~/Library/XAP ?

~/Library/Developer/Xamarin

~/Library/Xamarin.Mac contains a License file

~/Library/Xamarin* folders /Library/Developer/CoreSimulator/Profiles/Runtimes (iOS simulators)

Xamarin Studio on Mac

  1. Click on the “Download Now” on this page.

  2. During VS installation, under Cross Platform Mobile Development, choose Custom and select feature C#/.NET (Xamarin) [3rd Party].

  3. PROTIP: Before you begin, make sure you have enough disk space. The whole install will be shown as near 3 GB (2.2 GB they say).

  4. PROTIP: Since different versions of installers have the same name, XamarinInstaller.dmg, change the name downloaded with a date such as

    XamarinInstaller_2016.10.24.dmg

    takes 22.2 MB according to my Finder.

  5. Double-click on it in your Downloads folder to expand.

    Mac instructions

  6. Double-click the big down-arrow orange icon to open another window. If you don’t see the new window press command+tab and tab to the orange icon.

  7. Check the checkbox and click Accept.

  8. Click on Dependencies and unselect the components you don’t want, then click Continue.

    xamarin 6 1 1 install 525x176

    Notice the disk space usage (242 MB) and path (with “mac” subsituted for your account name):

    /Users/mac/Library/Developer/Xamarin/android-sdk-macosx

  9. Click Continue.
  10. Click Install.
  11. Check “I agree” to the Licenses, then Continue.

    PROTIP: You’ll be prompted several times to enter your Mac user’s password. So don’t walk off.

  12. Visit the While Waiting section, then return here.

  13. When “Installation successful” appears, click “Quit” or “Start” to invoke Visual Studio Community app.

    xamarin icon 412x386

  14. When Xamarin Studio opens (as “community”), click Login.
  15. After Login, “Enterprise” should appear at the upper left corner.

Visual Studio on Windows

Those developing on Windows machines work on iPhone by running a remote session on a Mac through a cable and running SSH.

NOTE: Since mobile devices will need to use virtualization, the IDE can’t also be running in a virtualized environment such as VMWare Fusion.

NOTE: Installation includes Xamarin Mac Agent (previously called the Xamarin Build Host). Its use includes enabling Remote Login on the Mac on the same Network subnet with the Mac’s IP address.

There is a free “Community” edition of Visual Studio on Windows. But the Community edition doesn’t include support.

  1. Go to
    https://www.xamarin.com/download.

  2. Create an account or SignIn.

    PROTIP: Many open several accounts for this to get around Microsoft’s 30-day trial limits plus redeeming a 30 day extension approval.

    Your picture appears from your email based on Gravatar.com.

  3. Select Product and Xamarin Platform. Click “Download now for free”.

    It recognizes what operating system you’re using based on what browser you used to visit the site.

  4. Fill out the form to begin downloading.

  5. Obtain a VS 2015 Community Edition web installer from https://visualstudio.com.

  6. Run the downloader and it downloads the rest.

  7. From your Installer folder, invoke the downloaded file.

    Visit the While waiting section if you are not installing on a Mac.

While waiting

  1. While you wait for the download, return to the “Xamarin Installer” pop-up screen, click the red X at the upper-left corner to dismiss it.

  2. While you wait, visit other pages to sign up for:

    There are self-guided classes. The mandatory starter class tells you how things work in Xamarin University and how you can plan your classes.

    But those who pay go to live hands-on classes. That’s $999 per year per person at the Xamarin University Mobile Training store after 30 days. Tick tock! (previously, it was $1,995)

    Each year you get 8 live one-on-one half-hour sessions with an instructor for code reviews.

    Cisco’s GoToTraining software is used.

  3. When “Installation successful” appears, click “Quit” or “Start” to invoke Visual Studio Community app.

    xamarin icon 412x386

  4. When Xamarin Studio opens (as “community”), click Login.
  5. After Login, “Enterprise” should appear at the upper left corner.

    NUnit 2.6.4 install

    CAUTION: NUnit 3.0 or higher is NOT yet compatible with Xamarin Studio 2016 or Xamarin.UITest. Back-version NUnit 2.6.4 should be installed.

  6. Follow these instructions.

    Android Player

  7. Download “Xamarin Android Player.dmg” (version 0.6.5 released November 4th, 2015) from:

    https://developer.xamarin.com/releases/android/android-player/

  8. Alt-click to install it.

    Xamarin Mac agant

From IDE login via SSH

### .Net Core 1.1 for MacOS

  1. Follow instructions on https://www.microsoft.com/net/core#macos

    If you get this message from brew install openssl

    Warning: openssl is a keg-only and another version is linked to opt.
    Use `brew install --force` if you want to install this version
    
  2. (Per this) Add in ~/.bash_profile

    export PATH="$PATH:/usr/local/Cellar/openssl/1.0.2j/bin/openssl"
  3. Verify:

    openssl version -a

    The response I got:

    OpenSSL 0.9.8zh 14 Jan 2016
    built on: Jul 30 2016
    platform: darwin64-x86_64-llvm
    options:  bn(64,64) md2(int) rc4(ptr,char) des(idx,cisc,16,int) blowfish(idx) 
    compiler: -arch x86_64 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O3 -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN -DMD32_REG_T=int -DOPENSSL_NO_IDEA -DOPENSSL_PIC -DOPENSSL_THREADS -DZLIB -mmacosx-version-min=10.6
    OPENSSLDIR: "/System/Library/OpenSSL"
    
  4. Read https://docs.microsoft.com/en-us/dotnet/articles/welcome

    https://github.com/dotnet/core

Clean up disk

  1. PROTIP: In Finder, alt-click the XamarinInstaller .dmg file to move it to Trash. In the left menu eject the “Xamarin Installer”. Also clean out your Trash can to recover disk space.

  2. PROTIP: If you’re going to be using it a lot: draw 3 fingers together on the touchpad. Click “X” for Xamarin.

    You’ll see “Xamarin Studio”, Xamarin Profile, and Xamarin Workbooks.

  3. Drag and drop the Xamarin Studio icon to the bar at the bottom of the screen.

The above only needs to be done once per machine.


Developer Certification

PROTIP: Learning a platform is a rather big career decision. Few people have time to be expert in tools for several languages. The fragmentation in Java and Android tools makes it difficult to be quickly productive when moving jobs since there are so many variations of tools to master. Even though Microsoft does limit and change (abandon) technologies over time, their ecosystem offers more focused training resources and help for learners make it easier to master and provides better movement among employers. My two cents.

xamarin-certified-developer logo

PROTIP: You can skip 7 of the 15 classes Microsoft requires before allowing registriation for certification if you can answer 80% or more of the 50-questions in the Introductory Assessment Exam on C#. You only get one chance to do it, though.

Email: training@xamarin.com

WARNING: The current certification questions are based mostly on Xamarin.Forms. *

Abbreviations used in course titles:

  • XAM = Xamarin general cross-platform and Xamarin Forms apps
  • IOS = Xamarin.iOS
  • AND = Xamarin.Android
  • CSC = C sharp C# concepts
  • ENT = enterprise, targeting enterprise solutions
  • FSC = F Sharp F# concepts (I’m skipping these)
  • XTC = Xamarin Test Cloud and testing

Sample Code Download

On the right panel it displays a set of sample apps for download as zips from https://www.xamarin.com/prebuilt

  • app-crm-master.zip - 33.7 MB from GitHub

  • MyShoppe-master.zip - 5.1 MB

  • XWeather-master.zip - 3.6 MB from Colby Williams is a mash-up of Google Maps and Weather Underground. It builds to an app without modification.

  • app-acquaint-master

  • Sport-master

  • MyShoppe-master

NOTE: File names have “-master” in them because they were downnloaded as Zip from GitHub, which adds the branch name to the repo named.

PROTIP: In the list I’ve added the results of my research about each example’s size, who wrote it, and where the latest version resides:
https://github.com/xamarin/prebuilt-apps

  • Employee Directory
  • Field Engineer
  • Todo List?

### Native iOS and Android apps

The Hello iOS app: https://developer.xamarin.com/guides/ios/getting_started/hello,_iOS/

The Hello Android app: https://developer.xamarin.com/guides/android/getting_started/hello,android/

The Hello Multiscree app: https://developer.xamarin.com/guides/android/getting_started/hello,android_multiscreen/

IDE intro with sample app

PROTIP: By default, macOS only allows one instance of an application to run. To launch a second instance, from a Terminal window:

   open -n /Applications/Xamarin Studio
   

Alternately, launch a new instance use Jonathan Dick’s http://redth.codes/xamarin-studio-launcher convenient app.

  1. When Visual Studio or Xamarin Studio is opened and Logged in, it presents its Welcome page.

  2. PROTIP: Return to the Welcome page anytime from the Windows menu.

    The IDE has 3 vertical panes. One pane displays links to news items. Another pane has links to tutorials such as Learn about Mobile Development with Xamarin.

    PROTIP: Let’s begin by looking at Solution is.

    New solution templates

  3. Click on File | New Solution or press Shift+command+N, which presents the various types of solution templates.

    vs2017 template 400x172

    The default is a Multiplatform Xamarin.Forms Forms app.

    All coding is in C# or F#. No VB, C++, etc.

    “Connected” apps are also called “ASP.NET Core” mobile services apps.

    Multiplatform games are created with either SpriteKit or SceneKit.

  4. Click the left pane’s iOS App to see that Metal and OpenGL game templates are selected there.

    For iOS under the General category are templates specific to iOS, such as Single View, etc.

  5. Click the left pane’s Android App to see templates for Android, such as Wear and WebView (hybrid) apps.

  6. Scroll down the bottom of the left pane to see the “Other” solutions traditionally supported by Visual Studio: .NET and ASP.NET.

    PROTIP: Now let’s look at some pre-built apps.

  7. Press Esc key to dismiss the dialog.

    Let’s now get an understanding of coding by looking at the pre-built apps downloaded. for Forms apps.

    Development approaches

    PROTIP: The types of development approaches:

    • Silo approach of writing Objective-C code for iOS and Java code for Android provided by vendors. This requires different developer teams.

    • Black Box takes a single (HTML/JavaScript) code base to create multiple apps with “minimum common” features common across the platforms.

    • Xamarin Forms

    Xamarin Forms is simpler to program, but you might run into a “brick wall” when you need to re-code using the native coding approach. But if you can live with eventual limitations, Forms is a quick way to get to an app quickly.

    XWeather sample app

  8. In Finder, navigate into a folder containing app source.

    PROTIP: Open Visual Studio by clicking on a .sln (solution) file in a folder containing its other files.

  9. In Finder, navigate into the XWeather sample app to where the XWeather.sln (solution) file is listed.

  10. Open Visual Studio by clicking on the .sln file.

    Structure of folders and files

    After an analysis of various examples, XWeather has what I think the most comprehensible structure for folders and files. Here’s the tree from root of the app folder:

    • .gitignore
    • images/__.png for the app’s sample UI image for display in the store
    • README.md
    • LICENSE.md
    • XWeather folder

    Within the XWeather (alphabetically): Code for .Droid and .iOS are generated automatically.

    • Droid = generated for Android devices
    • iOS = generated for Apple iOS devices

      PROTIP: It’s better for reuse to not include the name of the app (“Droid” instead of “XWeather.Droid”).

    • NuGet.config
    • Scripts
    • Shared
    • UITests
    • Unified
    • __.sln = solution file for use by Visual Studio IDE

    PROTIP: Xamarin Studio stores projects using the Visual Studio .sln file format. So solution files are interchangeable between Xamarin Studio and Visual Studio regardless of IDE used.

    There are lots of files in each folder above.

    More sample app source

    Xamarin Android Tutorial - Chat Application by EDMT Dev

    https://github.com/xamarin/ios-samples

    https://github.com/xamarin/mac-samples

    https://github.com/xamarin/xamarin-forms-samples

    https://github.com/xamarin/mobile-samples

    References

    Within VS2017, the References folder within both Android and iOS projects contains:

    • System
    • System.Core
    • System.Xml

    Microsoft’s .NET Base Class Library (BCL).

    In iOS projects the References folder also contains:

    • Xamarin.iOS

    In Android projects the References folder also contains:

    • Mono.Android

    Build and Error Review

  11. Click the Build arrow icon at the top.

    The result is likely errors.

  12. Double-click on the red message for a list at the bottom of the screen.

  13. Cursor to the top edge of the message pane so the cursor changes, then drag it up to see more lines.

    If there are no blocking errors, you’ll see a message such as this:

    NOTES:

    The build process creates IL (Intermediate Language) code that is vendor neutral. IL code is defined by the .NET standards by ECMA (not ISO).

    Xmarin.iOS builds use AOT (Ahead of Time Compilation) to compile IL into native ARM assembly code for compile into a native binary executable.

    Xamarin.Android builds use JIT (Just in Time Compilation) to compiles IL into ___ and IPK executable loaded on Android devices.

    A UWP (Universal Windows Program) app runs on both Windows 10 and Windows 10 mobile without rework. It’s not for Macs.

New Library Project

Libraries are defined as separate projects.

  1. Right-click on the Solution node and select Add > Add a New Project.

  2. Under the Multiplatform category, select Library, then Shared Project in the right pane. Click Next.

  3. Name the project “MyTunes.Shared” and click Create to create the project.

    SAPs are files named .shproj containing a group of source and assets referenced by each target project’s code as if they were individually added to the project, before build.

  4. Click Create for template code to be created in a .cs (C#) file.

Solution compiler symbols and directives

  1. In the solution pane, double-click on the solution’s name (such as XWeather).
    for the Options dialog.

  2. In the solution pane, right-click on project name XWeather.Droid.
    Select Compiler.

    Field Define Symbols should contain:

    DEBUG;__ANDROID__;

    Such values are referenced by conditional compiler directives (shown below).

    Press Esc.

  3. In the solution pane, right-click on project name XWeather.iOS.
    Select Compiler.

    Field Define Symbols should contain:

    __UNIFIED__;__MOBILE__;__IOS__;DEBUG;ENABLE_TEST_CLOUD;

    Notice these values are for the Configuration: value at the top of the dialog. That’s why the value “DEBUG” is there.

  4. Click and hold on the value to Configuration: field and select Release.

    Field Define Symbols should now contain:

    __UNIFIED__;__MOBILE__;__IOS__;
  5. Press Esc to cancel the dialog.

Shared Asset Projects (SAPs)

SAPs were introduced with Visual Studio 2013 Update 2 (April 2014) and Xamarin 5.

Conditional compiler directives in the Shared code can direct the compiler to isolate platform-specific code based on compiler symbols defined defined in

   #if   __IOS__
       ...
   #elif __ANDROID__
       ...
   #elif WINDOWS_PHONE || WINDOWS_UWP
       ...
   #endif
   

PROTIP: IOS is listed at the top because that is currently the most popular device type.

PROTIP: In the code above, there is vertical alignment.

An alternative is to make calls to a class that is defined in all platforms using the same signature (number of parameters and data types referenced in the call). This is called “Class Mirroring”.

The C# language provides for partial classes and Methods to be defined for code generators to complete.

SAPs replace PCLs

PCLs (Platform Class Libraries)

  • View assemblies within a Profile at C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.5\Profile\Profile78\

  • TOOL: .NET Portability Analyzer assesses whether an existing library can be converted to a PCL profile.

  • https://github.com/xamarin/FacebookComponents

  • https://github.com/xamarin/Xamarin.Social

  • https://github.com/xamarin/SalesforceSDK
  • https://github.com/xamarin/google-apis
  • https://github.com/xamarin/github-trello

Xamarin Components Store

This applies to both Android and iOS projects.

  1. In VS2017 a solution pane under a project, click Components.

  2. Click the Open Component Store button at the bottom of the screen.

  3. Sign-In using your Xamarin credentials because the Xamarin Component Store was created before NuGet to provide paid support on components (to encourage contributions).

    Among Plugins, https://github.com/jamesmontemagno/Xamarin.Plugins enables functionality needed for apps such as for Uber ride sharing.

  4. Click Order By: DOWNLOADS to see what people actually use.

    QUESTION: Is there source for a buildable sample app that incorporates these?

    WARNING: Even though there are hundreds of forks, if there are no Issues and Pull Requests for a repo, there is no real community collaboration, which means software that is not really mature.

    • Android Support Library for backward compatitibility
    • Android Support Design Library

    • AdvexpSettings for cross-platform settings, from among Libraries.

    • Xamarin.Auth by Auth0 for 2-factor authentication
    • Xamarin.Social for Facebook, Flickr, Twitter

    • RESTSharp REST client for consuming HTTP APIs
    • Amazon S3 storage among Cloud components.

    • SQLite.NET for ORM-based local storage using SQL commands

    • Stripe for mobile payments. Adcash for mobile ads, from among Libraries.
    • Notifications: https://github.com/Redth/PushSharp

    • AI.API for speech recognition and natural language processing, from among Cloud components.
    • Google Cardboard VR (Virtual Reality) for Android (not iPhones), from among Games.

    • Active Directory Authentication Library (ADAL)
    • Azure Mobile Service libraries
    • Syncfusion Essential Studio charts

  5. Click on the Website link for a component, such as Action Pack.

    WARNING: If the “Published On” date is more than a year ago, it may be that the component is not really supported anymore.

    NOTE: Many components are published in both the Component Store and Microsoft’s NuGet.org.

  6. Press Esc to return to the IDE.

    Xamarin Packages

  7. Click Packages on the solution pane.

    An Add Packages dialog appears.

  8. Click and hold on Nuget.org.

    You can configure additional sources of components, such as .NetFoundation.org.

  9. Click Close.

    Additional Components

    When a Xamarin component is installed into an App project, it is placed in a Components folder at the root level of the Solution folder. If you remove the Component from all projects in the solution, it will get removed from this folder as well. A copy is ALSO stored in a cache:

    On Windows: %LocalAppData%\Xamarin\Cache\Components

    On Mac: ~/Library/Caches/Xamarin/Components

    PROTIP: To remove a component completely from a machine, delete it from your projects/solutions AND from the cache folder.

    QUESTION: Code used across different platforms are stored in different “profiles”.

    Assets

    DEFINITION: Assets include text and font files loaded by Android code such as:

    Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
    

    The above code calls methods in Android’s AssetManager package.

Xamarin Forms Apps

QUESTION: Sample apps Task List and Step Counter ???

  1. Here are some overview videos:

  2. Read:

    https://developer.xamarin.com/guides/xamarin-forms/getting-started/

    “Xamarin.Forms is a new library that enables you to build native UIs for iOS, Android and Windows Phone from a single, shared C# codebase. It provides more than 40 cross-platform controls and layouts which are mapped to native controls at runtime, which means that your user interfaces are fully native.”

    UI controls are coded at a high level in C# for the library to render them as native counterparts in each platform.

    Xamarin.Forms controls are a wrapper on native controls, they aren’t new controls themselves.

    v4 introduced a new SSH-based build host which replaces the old and buggy build host.

    v3 introduced Xamarin.Forms supports Native UI development for iOS, Android, and Windows.

    Hanselman Forms

  3. Read Scott Hanselman’s blog about writing the library May 2014.

    The app aggregates his web blog and tweets.

  4. On your local Terminal, create a folder such as

    ~/gits/wilsonmar/Hanselman.Forms
  5. Got to Hanselman’s Form app code repo

    https://github.com/jamesmontemagno/Hanselman.Forms

  6. Fork it to your own GitHub account.

  7. Clone your edition of Hanselman’s Form app code (instead of “jamesmontemagno”):

    
    git clone https://github.com/jamesmontemagno/Hanselman.Forms --depth=1
    

    View app source folders

    Preview.png ?

    Versions and Logs

UI

## Profiles

Code used across different platforms are stored in different “profiles”.

### Plug-ins for Xamarin Forms #

Gaps in Xamarin Forms functionality are filled by https://github.com/jamesmontemagno James Montemagno (@JamesMontemagno), Principal Program Manager for @Xamarin at Microsoft.

  • https://github.com/XLabs/Xamarin-Forms-Labs XLabs (no longer maintained) was an open source project to provide a powerful and cross platform set of services and controls tailored to work with Xamarin and Xamarin Forms.

### Fancier Controls #

PROTIP: If you want fancier UI and have $1000, consider the Infragistics Xamarin Forms library at http://www.infragistics.com/products/xamarin-forms

This is coded in a similar way and look similar as on other platforms. So it’s good to keep up.

Debugger

https://developer.xamarin.com/guides/cross-platform/troubleshooting/questions/debugger-settings/

vs2017 debug options

Mobile device form factors:

vs2017 devices

“SE” is the emulator.

To run on a physical iOS device:

  • Have a registered Apple Developer account.

  • Get a Code Signing Certificate from Apple

MVVM (Model - View - ViewModel)

MVVM (pronounced by spelling out the letters Em Vee Vee Em) is a layered, separated presentation pattern made popular by XAML based UI where a data binding engine takes the place of the controller/presenter.

Models (entities consisting of classes and methods) are shared across platforms.

Views are visual aspects of what is presented to users to see and interact with (layouts, colors, fonts, buttons).

ViewModels are a view-centric representation of the data to be displayed (the strings for each element)

In the Xamarin Show on MVVM, James Montemagno explains how, conceptually, MVVM enables developers to separate business logic from user interface code.

Mono’s UI is developed using XAML (pronounced Zam-mil). XAML is a variant of XML containing definitions of UI elements, much like Android XML. (iOS Storyboards)

The XAML is referenced by “code behind” programming code that define behaviors.

The code sets text properties, register for click handlers, and automatically enable and disable controls with Commands.

The data binding framework built into Xamarin.Forms.

The programming language is Microsoft’s C# version 6.0.

Deploy

Publish to OneDrive cloud

https://github.com/xamarin/publish-over-onedrive-plugin

Insights in HockeyApp

HockeyApp at
hockeyapp.net is a cloud-hosted solution for beta app distribution and collection of real-time crash reports and user metrics and feedback.

Xamarin Insights is being merged into HockeyApp.

Test First

Xamarin UITest is a Microsoft-only testing solution.

Some prefer Appium purely because it is an open source library and thus a vendor-neutral approach.

  1. Introduction to Xamarin Test Recorder Lightning lecture at Connect 2016 by Rob Gibbons.

WARNING: Links below in this section require a Xamarin University subscription.

  1. Intro to Testing [XTC101] introduces the concepts and types of testing and then dives into writing Unit Tests for your mobile apps with NUnit.

  2. Working with Xamarin.UITest [XTC102] Explores the Xamarin.UITest framework for creating acceptance tests for your iOS and Android applications in C#.

  3. GC Fundamentals [CSC270] Knowing when and how a GC happens in your application can help you improve your apps responsiveness in the face of activity. This class walks you through the basics of Garbage Collection in Mono/.NET and gets into the GC implementation details for SGEN as well as some of the tweaks and diagnostics you can enable to see what’s happening in your application.

  4. Managing non-memory resources [CSC271] Garbage Collection based systems are great at managing memory, but applications use more than just memory based resources. In this class, we will explore the strategies used to release non-memory based resources such as files handles, network streams, and database connections. We will look at ways to influence the freeing of these resources using IDisposable, and how to ensure things get released using finalizers and SafeHandle objects.

  5. Diagnosing Memory Issues [XAM370] This class explores common memory issues you will encounter in your mobile apps and how to diagnose, identify and fix them. We look at how the GC system interoperates with iOS and Android to ensure things are cleaned up and where you will run into trouble. Finally we look at some platform-specific options you can tweak to potentially improve performance.

Xamarin Test Cloud

“Scale” level provides 5 hours a day for 3 concurrent devices for
$3,865.50 per year ($379/month billed annually).

$4,548 per year, after a 25% discount of $1,137, is $3,411.

CAUTION: The lower “Start” level provides just one device for one hour per day, for $99/month. If you don’t use it one day, you’ve donated the money to Microsoft.

BTW, Microsoft acquired its Test Cloud from Karl Krukow (@KarlKrukow, from Denmark, who built “Calabash, an Automated UI Acceptance Testing framework for writing and executing tests that validate the functionality of iOS and Android Apps using Cucumber and Ruby libraries. See him speak about Continuous Deployment.)

  1. Introduction to Calabash [XTC201] Video Course Introduces the Calabash environment and all of the pieces that make up a behavior driven test.

    https://developer.xamarin.com/guides/cross-platform/ci/

    This now Microsoft offering may be low when compared against charges and additional setup needed to use alternatives such as Amazon’s Test Cloud, Perfecto, and others.

    PROTIP: Evaluate the cross-compatibility of test code. Xamarin Test Cloud tests supports a different test framework for each language:

    • Ruby with the Calabash framework,
    • C# with Xamarin.UITest, and
    • Java via the Appium framework

    • https://developer.xamarin.com/guides/testcloud/troubleshooting/#The_Apple_App_Store_Rejected_My_iOS_App_Because_of_Non-public_API_Usage

    • https://github.com/xamarin/test-cloud-samples
  2. Deploying to Test Cloud [XTC103] Learn how to run your UI Tests on local devices and on Xamarin Test Cloud for complete testing coverage.

    Alternative test clouds

    PROTIP: As with all cloud arrangements, have agreements in place to use alternative test clouds such as Amazon Device Cloud and Perfecto.

    Alternative test clouds may have a wider choice of devices. Most importantly, one cloud may have new devices earlier than others.

    The Perfecto cloud offers a private option. On-premises test device vendors offer complete secrecy. And MSDN subscribers get a discount.

Azure

CLI for Azure

  1. Install from a Terminal Python:

    sudo npm install -g azure-cli
    
  2. This enables you to use the azure command:

    
    azure login
    
  3. Type y or n if the data collection question appears.
  4. Copy the code and click this URL:

    https://aka.ms/devicelogin

  5. Click on the field containing “Code” and paste the code in the web page. Click “Continue”.

    info:    login command OK
    
  6. List:

    azure account list
    
  7. To list commands available, type the azure account without parameters:

    azure
    
    info:             _    _____   _ ___ ___
    info:            /_\  |_  / | | | _ \ __|
    info:      _ ___/ _ \__/ /| |_| |   / _|___ _ _
    info:    (___  /_/ \_\/___|\___/|_|_\___| _____)
    info:       (_______ _ _)         _ ______ _)_ _ 
    info:              (______________ _ )   (___ _ _)
    info:    
    info:    Microsoft Azure: Microsoft's Cloud Platform
    info:    
    info:    Tool version 0.10.8
    help:    
    help:    Display help for a given command
    help:      help [options] [command]
    help:    
    help:    Log in to an Azure subscription using Active Directory or a Microsoft account identity.
    help:      login [options]
    help:    
    help:    Log out from Azure subscription using Active Directory. Currently, the user can log out only via Microsoft organizational account
    help:      logout [options] [username]
    help:    
    help:    Open the portal in a browser
    help:      portal [options]
    help:    
    help:    Manages the data collection preference.
    help:      telemetry [options]
    help:    
    help:    Commands:
    help:      account          Commands to manage your account information and publish settings
    help:      acs              Commands to manage your container service.  
    help:      ad               Commands to display Active Directory objects
    help:      appserviceplan   Commands to manage your Azure appserviceplans
    help:      availset         Commands to manage your availability sets.  
    help:      batch            Commands to manage your Batch objects
    help:      cdn              Commands to manage Azure Content Delivery Network (CDN)
    help:      config           Commands to manage your local settings
    help:      datalake         Commands to manage your Data Lake objects
    help:      feature          Commands to manage your features
    help:      group            Commands to manage your resource groups
    help:      hdinsight        Commands to manage HDInsight clusters and jobs
    help:      insights         Commands related to monitoring Insights (events, alert rules, autoscale settings, metrics)
    help:      iothub           Commands to manage your Azure IoT hubs
    help:      keyvault         Commands to manage key vault instances in the Azure Key Vault service
    help:      lab              Commands to manage your DevTest Labs
    help:      location         Commands to get the available locations
    help:      network          Commands to manage network resources
    help:      policy           Commands to manage your policies on ARM Resources.
    help:      powerbi          Commands to manage your Azure Power BI Embedded Workspace Collections
    help:      provider         Commands to manage resource provider registrations
    help:      quotas           Command to view your aggregated Azure quotas
    help:      rediscache       Commands to manage your Azure Redis Cache(s)
    help:      resource         Commands to manage your resources
    help:      role             Commands to manage role definitions
    help:      servermanagement Commands to manage Azure Server Managment resources
    help:      servicefabric    Commands to manage your Azure Service Fabric
    help:      storage          Commands to manage your Storage objects
    help:      tag              Commands to manage your resource manager tags
    help:      usage            Command to view your aggregated Azure usage data
    help:      vm               Commands to manage your virtual machines
    help:      vmss             Commands to manage your virtual machine scale sets.  
    help:      vmssvm           Commands to manage your virtual machine scale set vm.  
    help:      webapp           Commands to manage your Azure webapps
    help:    
    help:    Options:
    help:      -h, --help     output usage information
    help:      -v, --version  output the application version
    help:    
    help:    Current Mode: arm (Azure Resource Management)
    

Learnings

Xamarin University on Azure

WARNING: Links below in this section require a Xamarin University subscription.

  1. Introduction to Azure [AZR101] by Mark Smith provides a tour of the various services provided by Microsoft Azure. Sign up for an Azure account, the services offered by Azure, pricing models, and the management portal where you can setup, configure and deploy services.

  2. Building an Azure Mobile App Service [AZR110] by builds an Azure App Service mobile client back-end to expose data from it using both node.js and ASP.NET.

  3. Building an Azure Mobile App Client [AZR115] This class focuses on the client-side model for building a Xamarin application that uses an Azure App Service mobile back-end. We will explore the techniques used to add support to an existing Xamarin application to consume data from an Azure service, how to support offline caching and synchronization, and how to manage conflicts when they arise.

  4. (No video) Authentication with Azure [AZR120]</a> This class begins with how to activate the built-in authentication services in Azure by configuring an identity provider. We then show you how to log in and out of the identity provider from your Xamarin mobile applications. Finally, we dive into how to restrict your data to a specific user by utilizing the authentication information returned from the identity provider.

Benchmarking

https://github.com/xamarin/benchmarker

Ecosystem

Learning resources

Listed by the most recent and complete.

  1. Xmarin Tutorial for Absolute Beginners May 8, 2016 on YouTube’s Ms Academy by Christopher Harrison (@geektrainer) and Gerry O’Brien (@gerryod, Content Developer) has been cancelled.

    XAM101 references the T-Shirt prebuilt app which no longer exists (others are CRM, Employee Directory, Step Counter, etc.).

1 | Introducing Xamarin Learn what Xamarin is all about and how you can create cross-platform mobile applications.

2 | Installing Xamarin See how to install Xamarin, and get started with app development.

3 | Exploring a Xamarin project Create a new project, and create your first application.

4 | Using emulators Get started with Windows Phone, iOS, and Android emulators.

5 | Debugging Get started with troubleshooting.

6 | Deployment Deploy your app to a device.

  1. Xamarin Essential Training on LinkedIn by Walt Ritscher

  2. https://www.linkedin.com/learning/xamarin-essential-training/

  3. Read up https://developer.xamarin.com/guides/cross-platform/xamarin-studio

Social Media

  • QUESTION: Announcements about releases on on https://twitter.com/xamarinhq

  • https://www.xamarin.com/thanks offers these (and others I’ve found):

    hello@xamarin.com email

    Phone +1 (855) 926-2746

  • https://developer.xamarin.com

  • https://developer.xamarin.com/guides/cross-platform/getting_started/

  • http://stackoverflow.com/unanswered/tagged/xamarin

  • https://bugzilla.xamarin.com houses bugs reported in Xamarin.

  • https://forums.xamarin.com/

  • Xamarin channel on YouTube

Rock Stars

Among the 35 Xamarin MVPs

  • David Ortinau in St. Louis

Wallace McClure is Microsoft’s MVP on Xamarin. Has he moved on to other ventures?

Pierce Boggan (@pierceboggan) Program Manager at Microsoft for @XamarinHQ. He and Mike James

James Montemagno Principal Program Manager of Mobile Developer Tools at Microsoft Seattle (motzcod.es) has a GitHub repo containing popular plug-ins, which adds to https://github.com/xamarin/XamarinComponents.

Chris Hardy (@chrisntr, weblogs.asp.net/chrishardy)

He began in 2013 the Xamarin podcast on iTunes with

Michael Stonis (@michaelstonis) @TheEightBot Development Lead and President. Xamarin MVP.

Brian Costanich

Charles Petzold’s coverage of Xamarin Forms.

Joseph Hill (@JosephHill), VP of Developer Relations and Xamarin co-founder

@XamarinU trainers:

  • Jason DeBoever (https://twitter.com/jdeboever)

  • Judy McNeil (@flyinggeekette)

  • Kym Phillpotts (@kphillpotts)

  • Chris van Wyk

  • Glenn Stephens (@glenntstephens, glennstephens.com.au) in Australia

  • Adrian Stevens (@Adrian_Stevens, themethodology.net), Vancouver

  • Rob Givvens (@RobGibbens, arteksoftware.com), Farmington, MI

  • Mark Smith (@marksm)

Freelancers:

  • René Ruppert @rene_ruppert

  • Martijn00 (van Dijk) @mhvdijk

Newsletters:

  • Every Friday: http://weeklyxamarin.com/

  • @XamarinEvents

  • Jason Awbrey @jkawbrey

  • @AllAboutXamarin of AllAboutXamarin.com by @DanRigby

Aggregators:

  • https://twitter.com/PlanetXamarin, https://PlanetXamarin.com, https://github.com/planetxamarin/planetxamarin

Had 50 contributors on January 20, 2017.

Microsoft MVPs:

  • Sara Silva (@saramgsilva), MSDN Author MVP Mentor Writter & Speaker Windows & Azure & Xamarin Dev
  • Oren Novtny (oren.codes)

Xamarin Certified Mobile Developers on LinkedIn.

  • Jayme Singleton (@JaymeSingleton1) Business Program Manager

Conferences

  • https://github.com/xamarin/xamarin-evolve-2016
  • https://github.com/xamarin/xamarin-evolve-2015
  • https://github.com/xamarin/xamarin-evolve-2014

  • https://github.com/xamarin/evolve-presentation-template

Older videos

YOUTUBE: Webinar selling Xamarin v4

RV Travel group on Google+