87

Is it possible to develop and build Linux applications with Xamarin with the same code base?

After a few years with Ubuntu, my main OS right now is Windows again. But it's not impossible that I could switch to Mac.

Right now I have a bit of experience with Qt and no experience with Xamarin. With Qt you can develop on Windows, Linux, and Mac and for Windows, Linux, Mac, iOS, Android, Windows Mobile, ... They are pretty clear about that.

Since Xamarin is free and open source now and I still don't have much experience in Qt, I'm considering trying out Xamarin for cross platform development instead of Qt.

Not being able to release my software for Linux would be a deal breaker for me. Being able to develop on Linux would be nice, but is optional. But after all my Google research, I could only find information and people asking for support to develop on Linux and not for Linux.

As far as I know, this shouldn't be a problem with Mono alone. But as far as I know Xamarin > Mono and I don't get everything in Mono I could get in Xamarin.

I'm also not sure how well-supported Mono will be in the future. For me it looks like Xamarin is much more important for Microsoft than Mono itself.

I'm not sure if it's even possible, since Xamarin is based on Mono, but is it possible that Microsoft will at some point decide not to support Mono with .NET compatibility in the same way as Xamarin, or even cancel Mono as standalone completely?

So I'm looking for one single framework for all desktop and mobile platforms I can rely on, and I want to know if Xamarin and/or Mono and and/or Xamarin + Mono could be an alternative to Qt before I go deeper into any of those solutions.

Snostorp
  • 544
  • 1
  • 8
  • 14
JuSchu
  • 1,480
  • 1
  • 11
  • 12

7 Answers7

76

Just in case someone else comes accross this q/a: the situation has changed. With Xamarin.Forms 3.0, Gtk# is supported (as preview, at this moment). Therefore, full Linux GUI support is enabled.

So, Xamarin now covers:

The only thing left to wish for: JS/HTML5 Web App target platform, as part of Xamarin :)

Muzib
  • 2,412
  • 3
  • 21
  • 32
hardyVeles
  • 1,112
  • 11
  • 13
  • Other things to wish for in Xamarin: ability to actually call and return c# functions from js... – Alexander Sep 08 '18 at 00:32
  • 1
    I think Xamarin.Mac also covers macOS? – Franklin Yu Dec 16 '18 at 20:26
  • 1
    not sure if it is possible to cover your wish "JS/HTML5 Web App target platform" in a proper way, so the content is still clean HTML and possible to be processed by webcrawler and stuff like that. but a JS/HTML5/WebAssembly UI that just "works somehow" would be already a benefit. to get real native HTML experience you should checkout Blazor – Thomas Haller Aug 19 '19 at 13:43
  • 1
    GTK# is not supported (by microsoft) it is a community only effort that Microsoft doesn't contribute to or care about. It is not possible to develop for it on linux, only to use it on linux after you build it on windows. The Xamarin.Forms UI designer is not available on linux at all. Microsoft simply does not care about this. – trampster Oct 09 '19 at 22:50
49

No, Xamarin is not available for Linux. This was a conscious decision made by the Xamarin team several years ago:

Miguel de Icaza 2011-08-04 11:52:37 UTC

We face a QA problem here.

The problem with supporting Linux is that we would need to create a self-contained Mono packaging for all of the bits we ship since most Linux distributions are slightly off when it comes to Mono.

It also means that if we advertise "Linux" we would need to QA a dozen different combination due to different Linux distributions and different editions of each distribution.

Perhaps we would support just a single distribution and a single version, which is closer to what we have to do on Windows/Mac today.

To clarify, the Xamarin product range is not available on Linux (Xamarin Studio, Xamarin.iOS and Xamarin.Android) but MonoDevelop, the foundation of Xamarin Studio, and Mono, the cross-platform .NET runtime, definitely is.

You can build desktop software using MonoDevelop. The MonoDevelop site has plenty of instructions on getting started:

JuSchu
  • 1,480
  • 1
  • 11
  • 12
matthewrdev
  • 11,930
  • 5
  • 52
  • 64
  • Thanks. Of course now it would be interesting what I'm missing when I just use Mono? It looks like Mono also supports Android and iOS. Is the advantage of Xamarin just it's IDE (for the case it is an advantage) and something like the Xamarin Test Cloud? – JuSchu Apr 08 '16 at 08:39
  • Or would it be possible to use Xamarin for everything it can be used for and then build it for Linux with the same code base? – JuSchu Apr 08 '16 at 09:13
  • Yes, Mono supports iOS and Android but is rebranded as Xamarin.iOS and Xamarin.Android; these are specific products sold by Xamarin for which you require a license. – matthewrdev Apr 08 '16 at 11:08
  • Xamarin is a product suite that incorporates Insights, Test cloud and the iOS and Android runtimes. – matthewrdev Apr 08 '16 at 11:09
  • 6
    @JuSchu Mono does not support iOS and Android. That's why Xamarin renamed MonoTouch to Xamarin.iOS and Mono for Android to Xamarin.Android. And .NET/Mono does not aim to allow you use one code base to support all platforms. You can share code but don't dream of sharing every lines. – Lex Li Apr 08 '16 at 11:18
  • @matthewrdev Did I misunderstood what Microsoft did with Xamarin or did you miss the announcement at the build converence, that Xamarin is now for free and included in Visual Studio Community Edition? I hope you just missed it. – JuSchu Apr 08 '16 at 18:42
  • @Lex Li I already found out, that I have do implemet the UI for every single platform but could share (at least most of) the buissness logic. Right? But is it in principle possible to share the buissness logic between a Xamarin Android and a Mono Linux project? Wouldn't that part just be normal .NET code in both cases? The UI would be a plus for Qt. As far as I know I can implement the UI with QML or QtWidgets for every plattform in one code base. – JuSchu Apr 08 '16 at 18:44
  • 1
    @JuSchu yep, the business logic can be shared everywhere, though the sharing mechanism is now under a big change (from PCL to .NET Standard Library) if you already check out related Build sessions. – Lex Li Apr 09 '16 at 01:37
  • Ok, if they are making big changes at the moment, I guess now is not the right time to learn Xamarin. Well, I would have to learn C# and .NET first anyway. – JuSchu Apr 10 '16 at 12:57
  • First, I want to point out that the argument is far-fetched. They could just support a single distro, e.g. Ubuntu or Fedora, and let the rest ones to repack it if they want to. Second, the answer is outdated: as the link shows, they released the source code, so GNU/Linux and Mac users can build Xamarin themselves. I unfortunately didn't yet manage doing that, because of some odd problems with git and the recently updated proxy in the company I'm working at. But I'm hoping for the best :з – Hi-Angel Dec 19 '16 at 10:20
  • 7
    It seems that Miguel de Icaza's team decided to [support Xamarin for linux](https://www.reddit.com/r/programmerchat/comments/4dxpcp/i_am_miguel_de_icaza_i_started_xamarin_mono_gnome/d1vdfwz/) :) – Upol Ryskulova Jan 18 '17 at 19:34
  • @UpolRyskulova seems that nothing has come of that, they still don't support linux. – trampster Aug 17 '18 at 02:15
  • Their answer seems somewhat weird because there is an option to use flatpaks. Another such option is snap. – handicraftsman Mar 14 '19 at 12:23
  • @handicraftsman it's just an excuse, they have no interest in supporting desktop applications on linux, Microsofts interest in linux is all about server side and getting people to use Azure. – trampster Oct 09 '19 at 22:54
9

Seems that there is a chance of Xamarin Forms work on linux distros. In this reddit thread Miguel de Icaza says:

Some of our team members actually develop in Linux. The reason why we never released the Linux tools is because we were charging a lot of money and people would rightfully expect the software to be fully supported. We had enough keeping our Mac and Windows users happy, and adding an unknown number of Linux distributions sounded like a hard task. Now that we are open sourcing the SDKs and I no longer will feel bad if something does not work under a particular Linux configuration, I will be happy to release the Linux builds.

That is: the fact that Forms is an open source tool currently opens this possibility.

Bruno Peres
  • 15,845
  • 5
  • 53
  • 89
5

Yes, as of mid-2018, it is possible to develop cross platform GUI applications that target windows/mac/linux/android/ios using the "Xamarin.Forms" library. Basically, you have one shared library project from cross platform code (UI and other cross platform stuff), and one project per platform for platform-specific code (Xamarin.Forms have one backend implementation for each platform. On Linux, this is using GTK).

However, with MonoDevelop you can only develop/build the cross-platform project and the linux-specific project of the application. You will still need to use Visual Studio or Rider to develop/build for the other platforms.

See the following answer: https://stackoverflow.com/a/53317021/298005

Gabriel Cuvillier
  • 3,617
  • 1
  • 28
  • 35
4

https://github.com/0xFireball/xamarin-android-linux

As matthewrdev said, Xamarin.Studio, Xamarin.iOS, and Xamarin.Android aren't "officially" supported; however, Xamarin.iOS uses virtual emulator anyway (and I don't think there will be a workaround for Xamarin.iOS to run on Linux), but for Xamarin Studio (MonoDevelop on Linux, or Jetbrain's Riders (how to run it on linux with no official support is also provided in the link) Can run on Linux as an alt for Xamarin.Studio, and that link I shared explains how to install Xamarin.Android on linux, so just for Xamarin.iOS you will need to migrate or dual boot or sth, I hope that helps! (I stopped using Xamarin my-self, however, this environment helps developing for Xamarin on linux!)

rghome
  • 8,529
  • 8
  • 43
  • 62
  • 2
    Hi, I maintain that guide you linked; it had broken for some time because some of the paths had been changed, as of today it has been updated and has been confirmed working. – 839829389A Feb 03 '18 at 19:56
  • I can confirm it still works. Only issue was with the libzip.so.4 errors. I didn't have it in the first place so I had to install it through: sudo apt-get install libzip4 – ignacardel Mar 07 '18 at 11:16
1

GTK is listed as one of supported platforms/backends for Xamarin.Forms which allows building apps for Linux (as well as macOS and Windows via same GTK project). Though it doesn't look like there was much of development since 2018/2019 and Xamarin.Forms 3.0. Tried running 2 apps with basic UI and compared GTK backedn on Windows/macOS (comparing to WPF and Xamarin.mac back-ends ) and found GTK not worth pursuing (basic scenarios failing).

You can track GTK progress at https://github.com/jsuarezruiz/forms-gtk-progress/blob/master/Status.md

J. Doe
  • 101
  • 3
1

On Ubuntu 20.04, you can run your ASP.Net MVC 5 application using XSP4. Open a console to where you installed your MVC applications, where all folders, Global.asax, Web.config, ... are and run "xsp4 --port 80" or any other port you like and available. XSP4 is an independent web server and does not need Apache to be run. Also, for C# developers, even the MonoDevelop is not in Ubuntu 20.04, which I don't know why, you can still install it and debug your ASP.Net MVC application. You can also debug any WinForm and console application using the MonoDevelop. YOu can run all your application using mono too.

amirhp
  • 11
  • 1