Visual Studio for OSX

Visual Studio for Mac was officially launched on 10 May 2017 and supports C#7, NuGet .Net package manager, F#, and curiously also ASP.Net with a built in ‘Kestrel’ webserver for debugging.  It’s also free in the Community edition which is fully functional and little different from the Professional edition.

First don’t get confused with Visual Studio Code, which is an entirely separate product.

  • Visual Studio for Mac is born out of Xamarin Studio itself created in 2013 by the developers of Mono so it’s already a relatively mature and stable app.
  • VS Code, released Nov 2015 is a text-editor with wide-ranging intellisense and built in debugging capabilities for Node.js, javascript, Python, and with extensions Java and other languages including React Native….

VSCode

VS Code is very fast, cross-platform, free, extensible and feature rich, there’s little reason not to try it.

VS Code is a fully open source solution available on github built on:

  • Electron (formerly known as Atom-shell), which is a framework allowing cross-platform desktop apps to be built using web technologies (eg HTML, CSS, JavaScript on Chromium and Node.js).
  • “Monaco” editor component from Visual Studio Team Services

Overall VSCode is comparable to Atom, and with extensions comparable to Nuclide, Facebook’s Atom package to provide a unified development environment for Facebook.

  • Nuclide specifically covers Facebook’s Hack (PHP variant with extended type system).
  • VSCode is Open source under MIT license, Nuclide “has certain limitations around distribution and should not be considered an open source license. “
  • Both cover React-Native which needs a separate article ..

Tip of the day: If you don’t wish to send usage data to Microsoft, edit VSCodeTelemetrySettings.json file eg at ~/.vscode-react-native and add optIn:false.

Visual Studio for Mac

Visual Studio for Mac offers a familiar IDE and simple solution structure for mobile development with separate projects for:

  • shared client code projects
  • separate user interface code projects eg for iOS, Android
  • ASP.NET server code

as well as other structures for distributable libraries.

  • Teams with developers on both Mac and Windows can open and work on the same projects, sharing code across platforms and apps.
  • Mobile designers can use native iOS Storyboards and Android XML layouts or Xamarin.Forms XAML.
  • a variety of game engines are supported including native mobile gaming apis like SpriteKit, CocosSharp and UrhoSharp..
  • On iOS, Xamarin’s Ahead-of-Time ( AOT) Compiler compiles Xamarin.iOS applications directly to native ARM assembly code. On Android, Xamarin’s compiler compiles down to Intermediate Language ( IL), which is then Just-in-Time ( JIT) compiled to native assembly when the application launches.

Debugging

Running in debug with breakpoints etc is quite smooth and painless, all works as expected.  It doesn’t have the hot reload that React-Native supports to allow reload of the app without restarting the virtual machine, though the startup seems smooth.

There is now a Xamarin live player which runs on your phone rather than as a virtual machine and promises the capability to make live edits.  For now the connection can be troublesome and there are a number of limitations so don’t be surprised if you get “[xxx] is a native app. For best results, use Xamarin Forms” followed by build errors.

iOS Storyboard Designer

Visual designers are historically a key differentiator of the ‘Visual Studio’ product line, in this context the Storyboard designer seems unusually fragile: thankfully you don’t have to use it and many prebuilt and sample apps don’t:

  • design view often fails to load or loads blank.  Often changing the View As helps to refresh the display, but some views come out blank for no discernable reason
  • click actions are inconsistent: some controls such as label are clickable to edit the text.  Other controls react to clicking by silently creating an event property, which later causes the app to fail if you didn’t spot it and either wire it up or delete it  
  • Title is editable on some types of screen by clicking into the title, on others not: UIViewController and UITableViewController are inconsistent regarding use of Title attribute or separate widget,   
  • on some occasions the designer corrupted completely or duplicate code blocks got added to the designer.cs

Overall the setup of the screens and workflow the storyboard seemed over-complex and insufficiently stable.  With React-Native there is no explicit app delegate and no need for the complex storyboard flow definition thanks to simple constructs like the StackNavigator.

Also, why are 36 icon files needed for iOS?  Sure iOS might need it but it shouldn’t be mandatory to manually populate each size individually in Assets.xcassets  (and the Xamarin sample download doesn’t even include all the right sizes).  There are tools to create all the different sizes you might need eg:  http://appiconmaker.co  (but not the correct iOS filenames) and in Visual Studio, that’s 36×3=108 mouse clicks (just for iOS) that I don’t recall needing to do in React Native.

Xamarin forms

There’s a free Xamarin forms book by Charles Petzold, famous for his Windows programming books.  Visual Studio includes a visualizer to preview the cross-platform .xaml form definition file (but not a designer).

Documentation

The https://developer.xamarin.com/ documentation is generally good:

  • provides useful guides eg on Apple provisioning process
  • unfortunately some of the links to the underlying Apple concepts are out of date (either dead link or in come cases retired document with warnings “Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.”)
  • sample tutorial instructions are incomplete, for example miss some essential points needed for the basics to work such as setting project properties and adding references such as: using Foundation;  so working through the samples you will see errors like:
    • “The type or namespace name ‘NSUrl’ could not be found (are you missing a using directive or an assembly reference?) (CS0246)”
    • “Can’t launch a 32-bit app on a simulator that only supports 64-bit apps (iPhone 6s)”
  • sample code downloads are not directly comparable with what you get creating an application from scratch (or directly executable) due to dependency version changes.  Of course this also applies to every tutorial every written for React Native and popular javascript libraries: compared to these the Xamarin tools are relatively stable and easy to get running.  Example errors:
    • “/Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(5,5): Warning MSB3247: Found conflicts between different versions of the same dependent assembly.”  [easy to map the config so all components pick up the upgraded version though unfortunately that broke some of the components]
    • Most samples out there also break the Android7 rules for access to sqlite with “libmonosgen-2.0.so unauthorized access to libsqlite.so” see solution and discussion.

Summary (not conclusions)

Some of the points in favour of Xamarin will be the same as the points against, depending on your viewpoint:

  • Many organisations will welcome a solution supported by Microsoft, and the ability to reuse C# code and skillsets for mobile development.  Many will want to take advantage of existing development and skills in Javascript and avoid any apparent tie-in to Microsoft stack.
  • Visual Studio provides a lot out of the box with a reasonable reassurance that it is going to work together:  there is a marketplace (NuGet) for additional components but in comparison to the javascript based alternatives, less time will be spent doing product selection and compatibility debugging of the basic project components and infrastructure.   In particular React-Native is relatively newer and thus going through more frequent breaking releases.  Additionally as React-Native installs tend to require a lot of additional javascript components they become vulnerable to updates of javascript libraries not originally designed for use with React-Native.
  • Market watch sites including Stackshare weigh Ionic and React Native as both significantly more in demand than Xamarin.  The notable employment marketplace bias towards React-Native may also reflect the relative difficulty in retraining to and starting with React-Native.   In comparison Xamarin and other solutions may allow for redeployment of existing C# developers and web developers as a minor extension to existing skillsets.

Don’t jump to conclusions because everything is still under development..

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s