我可以在Linux上构建和编译跨平台Xamarin应用程序吗? [英] Can I build and compile cross platform Xamarin apps on Linux?

查看:296
本文介绍了我可以在Linux上构建和编译跨平台Xamarin应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Fedora 27作为操作系统,我想知道是否可以让Xamarin工具集在其上运行,以使用monodevelop,VS Code或Rider等IDE创建跨平台应用程序。

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.

我听说Xamarin获得了用于Xamarin.Forms for Linux的新模板,但是我找不到关于它的最新开发新闻。

I heard Xamarin get's new templates for Xamarin.Forms for Linux, but I can't find any recent development news about that.

推荐答案

是的,截至2018年中,在Linux上的MonoDevelop下开发Xamarin.Forms应用程序是有可能的。我成功地做到了。

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:


  • 一个共享库项目,包含所有跨平台的Xamarin.Forms代码和Xaml文件。由于某种原因,在Linux上,必须使用.NET Core工具链而不是Mono工具链来编译该库项目(否则,稍后在运行时会出现一些GTK问题)。目标框架是.NET Standard 1.0或.NET Standard 2.0,主要依赖项是NuGet包 Xamarin.Forms。

  • Linux的Mono / GTK#平台特定项目,其中包含所有平台特定的代码:初始化GTK和Xamarin.Forms.Platform.GTK后端,然后启动Xamarin.Forms代码。依赖项包括NuGet包 Xamarin.Forms.Platform.GTK,对Linux发行版本地安装的GTK#(gtk-sharp,atk-sharp等)的引用,以及对共享库项目的引用。 。请注意,仅支持GTK2,不支持GTK3。

共享库项目可以使用MonoDevelop,Visual Studio或JetBrains Rider开发。请注意,使用MonoDevelop,没有XAML设计器...因此,使用Windows上的Visual Studio可以更轻松地完成设计工作。

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.

可以开发特定于平台的项目在Linux上使用MonoDevelop或Rider。

The platform specific project may be developed using MonoDevelop or Rider on Linux.

以下是MonoDevelop下项目结构的图片:

Here is a picture of the project structure under MonoDevelop:


  • 有一个 HelloWorldXamarin库项目。它使用面向.NET Standard 1.0的.NET Core工具链,并依赖于NuGet包 Xamarin.Forms

  • 有一个 HelloWorldXamarin_Linux项目。它使用针对Linux的Mono / GTK#的Mono工具链,并且具有对GKT#和HelloWorldXamarin库的依赖关系,以及对NuGet包 Xamarin.Forms.Platform.GTK的依赖关系。您可以在右侧看到特定于平台的代码。

以及结果图片:

因此您现在可以开发适用于Windows,Mac,Linux,Android的跨平台Xamarin.Forms GUI应用程序,iOS ...

So you can now develop cross-platform Xamarin.Forms GUI applications for Windows,Mac,Linux,Android,iOS...

这篇关于我可以在Linux上构建和编译跨平台Xamarin应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆