Quintic
Xamarin Forms

Installation

Thought I would have a go with Xamarin Forms and a bit of SmartPhone app development. A few years ago (back in 2012) I started developing apps on iOS using Objective C. Got so far before other work intervened. Must say I was not impressed with Objective C, nor with its successor Swift. I found Objective C’s syntax obscure at times, and Swift seemed like it was trying to dumb-down the whole programming ideal. Added to that was the issue the development was only iOS, not Android and you had to pay Apple over £1000 p/a for the priviledge

However, now we have VS2019, Xamarin, & Xamarin Forms. All Free, and with (the potential) for easy Cross-Platform development for iOS, Andriod and Windows (and who knows possibly even the Raspberry Pi in the not too distant future). So thought I would give it a try.

As always with development on the MAC, the first thing you will have to do is get everything up to the required version. I had already managed to install VS2019 and Xamarin get them both working (see here), but that is insufficient for Xamarin Forms. Xamarin Form needs at least XCode 11. XCode 11 requires at least Mojave OS. I was still running High Seria, with XCode 10.1, because, the last time I checked, you could not install Mojave on my MAC Notebook Pro 2013. Apple

Good news is now you can. Downloaded Mojave and installed. Everything started up OK. Started XCode, at 11 which is good, but the version requires additional components. The attempt to download these additional components failed – something about expired certificates! Searched the web, and the solution is delete XCode and re-install. Which I did, except the latest version of XCode requires not Mojave, but Catalina. So now it is download Catalina (which I am pleased to say is also available for my MAC) and then try again.

Installed Catalina, the latest version of XCode and Xamarin Forms. Opened VS2019 and started a new project Xamarin Forms project. Attempted a compilation, which failed. Aparently wrong version of Java. Xamarin Forms requires 1.8, whereas I had 1.7, or at least VS2019 believed I had Java 1.7. Open up a terminal window and entered ‘java -version’, response was 1.8!

Oh, I was also missing the Andriod SDK

Oh, and VS calls the Java JDK, an SDK – but thats just wording.

However VS indicates I can download a version of Java from Oracle that is designed to significantly improve the performance of Xamarin. Attempt to do that to fix the Java version issue. The download succeeds, but does not solve the problem and VS2019 does not register the download.

On top of that the Andriod SDK will not successfully download, this time because of a Java directory location.

So, no idea what caused the problem, but a possible reason is that Mac OS Catalina switched from using the BASH (bsh) shell to ZSH, and I wondered if the in the switch $JAVA_HOME was lost, and that caused the problem. Certainly under Catalina $JAVA_HOME was not defined.

Best solution I could come up with was to uninstall everything and try again. So, in order I uninstalled.

  • VS2019
  • Xamarin
  • Andriod SDK
  • Java JDK

I then attempted to re-install VS2019 (using the same installer package that I had previously download), with the following package options:

  • .Net Core
  • Andriod
  • iOS
  • macOS (Cocoa)
  • Xamarin Workbooks.

This failed because of a permissions issue with the Andriod package. Checked on the web, and this is a known fault, that is fixed with the latest VS2019 install package!!

Downloaded the latest VS2019 install package. Installed VS2019 with the same above packages. All went well.

Started a new Xamarin Forms project

Added a ContentPage and added couple of labels to the page.

Compiled – OK – Yes! Yes! Yes!

Running Blank App

Attempted to run. That failed because default project was Android and I didn’t have an Android emulation device loaded. (Executing everything on MacOS)

Switched to iOS project. (The default solution includes both Android and iOS projects.). A re-run did indeed produce an iPhone, or rather an iPod Touch emulator. Strange choice, but it works.

iPod Touch Emulator

Andriod Emulator

I then worked out how to add an emulator for an Android device.

Tools>Device Manager – under Andriod

Multi-Page App

I then began following the on-line Xamarin Forms Tutorials. Very good set of tutorials for beginners. Hit a minor issue with Multi-Page app tutorial. Instruction 9 includes the following c# code:

var filename = Path.Combine(App.FolderPath, $"{Path.GetRandomFileName()}.notes.txt");

Problem is App does not have a FolderPath property. However a later Instruction (Item 13) includes the code to update the App object with a FolderPath property.

Multi-Page Notes App using Database

Tutorials then go on to use a database rather than files for the notes. I have to say, this development is so much easier and faster than Objective C, or Swift. Plus the multi-threading handling with C# async and await really do simplify the whole dev process.

Next step – Deployment >>