Can I build and compile cross platform Xamarin apps on Linux? - linux

I'm using Fedora 27 as my Operating System, and I'm wondering if I could get the Xamarin toolset working on it to create cross platform apps with an IDE like monodevelop, VS Code or Rider.
I heard Xamarin get's new templates for Xamarin.Forms for Linux, but I can't find any recent development news about that.

Yes, as of mid-2018, it is somewhat possible to develop a Xamarin.Forms app under MonoDevelop on Linux. I successfully managed to do it.
Basically, you need to have at least two things:
A shared library project, containing all the cross-platform Xamarin.Forms code and Xaml files. For some reason, on Linux this library project have to be compiled with .NET Core toolchain and not Mono toolchain (otherwise there is some GTK issues at runtime later on). The target framework is .NET Standard 1.0 or .NET Standard 2.0, and the main dependency is the NuGet package "Xamarin.Forms".
A Mono/GTK# platform-specific project for Linux, containing all the platform specific code: initialize GTK and Xamarin.Forms.Platform.GTK backend, and start the Xamarin.Forms code. The dependencies are the NuGet package "Xamarin.Forms.Platform.GTK", references to locally installed GTK# of your linux distribution (gtk-sharp, atk-sharp, etc...), and obviously a reference to the shared library project. Note that only GTK2 is supported and not GTK3.
The shared library project may be developed with MonoDevelop, Visual Studio, or JetBrains Rider. Note that with MonoDevelop, there is no XAML designer... so this is easier to do the design stuff with Visual Studio on Windows.
The platform specific project may be developed using MonoDevelop or Rider on Linux.
Here is a picture of the project structure under MonoDevelop:
There is a "HelloWorldXamarin" library project. It uses the .NET Core toolchain targeting .NET Standard 1.0, and have a dependency to NuGet package "Xamarin.Forms"
There is a "HelloWorldXamarin_Linux" project. It uses the Mono toolchain targeting Mono/GTK# for Linux, and have dependencies to GKT# and HelloWorldXamarin library, as well as dependency to NuGet package "Xamarin.Forms.Platform.GTK". You can see the platform specific code on the right.
And a picture of the result:
So you can now develop cross-platform Xamarin.Forms GUI applications for Windows,Mac,Linux,Android,iOS...

Yes you can and how well it will work on Fedora I'm not sure, but it looks like development is still in progress for the GTK Backend on Linux. For more information, there's a Github repo here that shows how far along it is and how you can try it yourself.

Related

Cannot use a C++/CLI DLL unless Windows 10 SDK is installed

We have developed a C++ library that does a little bit of data interpretation, mostly converting raw byte streams into JSON strings and also collecting raw data packages and returning the collection as a binary file (byte stream).
This library is written with pure C++ STL without any other libraries as dependencies and is used successfully in Android and iOS projects.
For a new C# project for Windows Desktops, developed by external partners we have built, a PIMPL class in C++/CLI that enables easy integration of the already existing code base. In Visual Studio we compile the C++ library into a static library with clang/LLVM and use it in the Visual C++/CLI Wrapper project as a dependency to build a DLL that we provide for our partner.
This setup took a little time but it works now fine and we are really happy about the development.
But when we tried to get a Demo running on a different PC we encountered serious problems: It is not possible to load this DLL on a "clean" system. When trying to load it in our application (or a DLL Dependency Walker for that matter) it throws a
After some hours of experimenting I've narrowed it down to the Windows 10 SDK that seems to be necessary to load this DLL.
My guess is that it has something to do with some compiler/linker setting in Visual Studio, but I have no idea which one...
Edit:
All VC++ redistributables (2010-2017, x86&x64 just to be sure) as well as the .Net Framework 4.7 and .Net Core Redistributable are installed.

ServiceStack DTOs on MonoTouch

We're creating a webservice with ServiceStack (current v3-fixes branch) and another company is programming an Android and iOS App against it.
My DTOs are (of course) in separate assemblies and compiled against .Net Framework 4. I can use these assemblies without problems in .Net projects and also in the Xamarin.Android project. The other company now told me, that they are not working in Xamarin.iOS.
They are using the latest (precompiled) ServiceStack.MonoTouch dlls with version 3.9.55. I read somewhere that I have to compile my DTOs against the MonoTouch version of the ServiceStack dlls.
Is this correct and is it possible to do this in a windows environment?
Thanks in advance
Steffen
Yes this is true you will need to compile your DTO's against the MonoTouch version of the ServiceStack dlls. The reason for this is because Xamarin.iOS does not support the full desktop version of the .NET assemblies. Rather it is a subset of them, much like the Silverlight platform. See here for more information.
Note: Xamarin.iOS is not ABI compatible with existing assemblies compiled for a different profile. You must recompile your source code to generate assemblies targeting the Xamarin.iOS profile (just as you need to recompile source code to target Silverlight and .NET 3.5 separately).
While Xamarin does have a Visual Studio plugin, Xamarin doesn't support Xamarin.iOS without a Mac OS X environment. There are services online where you can hire remote Mac OS X systems.

Can I reference .NET 4.0.3 runtime in MonoDevelop on a Mac?

In my question about using .NET 4.0.3 in a Portable Class Library I spoke a little too soon: I got the PCL working on my Windows machine, but now I can't get it working on the Mac. If the library is set to use .NET 4.03, I get compiler errors in MonoDevelop, saying that the framework is not supported. So I'm stuck on PCL for .NET 4.0, which is annoying because I need some features from 4.0.3.
So, is there a way to target .NET 4.0.3 in MonoTouch/MonoDevelop on the mac?
MonoDevelop (up through 3.0.6) is/was hard-coded to only work with PCL Profile1 (I think it was Profile1, anyway). As a workaround, you can try changing over to Profile1 and building that.
On MacOS, MonoDevelop simply links with MonoTouch (or Mono4Android) system assemblies and ignores the PCL profile constraints (other than verifying that the profile is Profile1). If MonoTouch has the 4.0.3 APIs that you are trying to use, then things will build fine.

windows application having no dependency to install

I want to implement windows desktop form application having no dependencies to install (e.g. framework, third-party etc).
In which technology I can achieve this?
Can i achieve this goal in C# Win-forms?
You can build an MFC app that requires no installation (just copying the files to the target computer) by statically linking and/or deploying the Visual C++ runtime redist side-by-side.
As Arnon has answered, you can build a .Net app that requires no installation if you target a version of .Net that is pre-installed on your target operating system. This blog entry lists the .Net versions included with each version of Windows.
what version of windows are you targeting your application to ? different versions of windows have different versions of .NET (see this link for details).
So basically, if you are looking for no installation you'd have to shoot for the lowest common denominator and/or ship multiple versions of your app.
I understand that it isn't what you want but -If you do go with .NET it is usually better to ensure that the installer will install the right version of .NET if needed (see this link for example)

How to run C# 4.0 app on Linux OS using mono?

I want to run my c# application with OS Linux using Mono. I am new to this cross platform migration? Please tell the procedure for doing that?
Thanks & Regards.
It very much depends on what type of application it is. For a console or WinForms app, it may be simple. Mono doesn't support WPF.
Well, the first think you'll need to do is install Mono of course. Then you probably want to run MoMA to determine your application's compatibility. There's a whole separate page about porting WinForms apps.
If all is well, you should just be able to run your application using:
mono MyApplication.exe
after copying the binaries over.
If your application is actually a web service or web application, you'll want to think about the various hosting options.
I suspect you'll want to read a lot of the pages on the Mono Start Page.
Check if your application is 100% compatible with Mono Framework using MoMA.
Remove or replace those unimplemented parts with Mono's implementation or third party libraries that works with Mono. Or if you think it should work fine, just execute it with Mono Framework 2.8 or higher. Better go with 2.10 which is default's profile is on 4.0.
There is an IDE, MonoDevelop that supports Web and Desktop applications. Open the project files (monodevelop supports visual studio project files) from monodevelop, compile and run.
you can browse mono website here, where you can find which features are supported and which are not supported and why.

Resources