随着最近移动(Mobile)领域的技术进步,我们几乎可以使用手机做任何事情。主要的移动市场份额由谷歌的Android占据。紧随其后的是苹果的 iOS,然后是微软的Windows。如果您是一个初露头角的移动开发人员,那么您可能会在某个时候面临这个最关键的情况。您希望在与其设计目标不同的平台上运行您的应用程序。
但是学习一门新语言、API(APIs)和其他东西似乎是一项乏味的任务,它可以让你坚持你的平台。但是称为Xamarin的东西可以帮助您构建跨平台的移动应用程序,其性能几乎与平台本机应用程序相似。
什么是 Xamarin
Xamarin是一家成立于 2011 年的软件公司。最近在 2016 年被微软(Microsoft)收购。Xamarin为开发人员提供了可帮助他们构建跨平台移动应用程序的工具。这些应用程序可以拥有所有的原生特性,同时也可以共享通用的代码库。根据Xamarin的统计数据,超过 15000 家公司依赖他们的工具,名单中包括许多知名人士。
Xamarin 工具(Xamarin tools)可通过Visual Studio下载,您可以直接从Visual Studio本身创建Android、iOS和Windows 应用程序。(Windows apps)大多数常见代码都是用C#编写的。因此,如果您已经了解 C#,则无需学习Java、Objective-C或Swift即可构建应用程序。如果您是初学者,那么采用Xamarin路径而不是传统的学习过程实际上可以教您为多个平台开发应用程序。但是你会错过真正的原生功能吗?
这个问题的答案大多是“否”(No)。整个工具集提供的强大功能集确保您不会错过任何功能。但在某些时候,您可能想要更深入地挖掘。Xamarin 允许您调用以其他特定于平台的语言(例如Android中的(Android)Java)编写的现有代码。但这只是在您构建无法在不同平台上实现的非常具体的东西时。
Xamarin 也支持可穿戴设备(wearable devices)。您也可以为Android Wear(Android Wear)和Apple Watch构建原生应用程序。Xamarin 组件商店允许您通过下载简单的插件来为您的应用程序添加更多功能。您可以轻松地将您的应用程序与大多数流行的后端(如Microsoft Azure、Parse等)集成。您也可以添加流行的身份验证方法。此外,还提供用于添加计费支持和其他功能的插件。大多数流行的插件都是跨平台的,但也可以使用特定于平台的插件,例如Google Play计费支持插件。
Xamarin 是如何工作的
这是关于这个平台的最常见和最奇特的问题。那么,基本上Xamarin做了什么,您可以为不同的平台编写通用代码?在最根级别,Xamarin已将整个现有的Android和 iOS SDK转换为 C#,以便您可以使用更熟悉的语言进行编码。由于您可以使用 C# 为这两个平台编写代码,因此您需要记住的语法更少。您可以使用Xamarin(Xamarin)工具在 C#中访问几乎任何 iOS 或Android API 。
现在来到它的 UI,UI 几乎保持不变。您需要为不同平台分别构建 UI,然后将 UI 与通用代码库绑定。这是一张来自Xamarin网站的图片,我想分享它,以便您更好地了解幕后发生的事情。
因此,您可以构建实际的原生应用程序 UI。这样的 UI 不仅为用户提供了所需的感觉,而且应用程序的行为就像它们是普通的原生应用程序一样。在平台特定的 UI 代码下方,是调用公共代码库的共享 C# 代码。
实际上有两种不同的方式来构建 UI。您可以使用原始本机方法来构建 UI,也可以使用Xamarin.Forms。表单(Forms)可让您一次为不同平台构建 UI。如果您决定选择Forms而不是Native UI Technology ,那么几乎 100% 的代码共享。
在完成 UI 之后,最困难的部分是您需要将 UI 连接到代码库。这又可以通过称为“共享项目(Shared Project)”或“可移植类库(Portable Class Libraries)”的两种不同的代码共享策略来完成。
Xamarin 入门
现在让我们看看如何将你的手放在这个神奇的东西上。要在Windows上使用Xamarin,您需要安装Visual Studio。您可以免费下载 Visual Studio Community或购买高级许可证(如果您还没有许可证)。前往xamarin.com(Head)下载已使用Xamarin工具配置的(xamarin.com)Visual Studio 。
Visual Studio是Microsoft 推出(Microsoft)的一款出色的IDE,已广泛用于开发Windows应用程序。完成安装和设置 Visual Studio后,您可以创建一个新的“跨平台应用程序”项目并开始工作。系统将提示您选择一些设置,然后您就完成了。Visual Studio可能需要一些时间来设置您的项目。
要了解更多信息,您可以在此处(here)阅读原始文档。此外,在工作室中玩耍并查看项目中的默认文件,以真正了解一切在后台是如何工作的。
萨马林大学
所以,你对这个东西很感兴趣,你觉得这是移动应用程序的未来。如果您对学习Xamarin或移动开发很认真,那么我建议您看看Xamarin University。在线大学提供实时在线讲座、1:1 学生互动、Xamarin专家指导等等。整个课程涵盖了很多东西,你肯定可以学到很多东西。费用相当实惠,注册该课程的费用约为 83.25 美元/月。在这里(here)查看Xamarin 大学(Xamarin University) 。
Xamarin 能否成为移动开发领域的下一件大事?您认为它会取代现有的常规开发方式吗?让我们拭目以待。同时,您可以让自己熟悉 Xamarin,并亲自看看它是否有效。(Can Xamarin be the next big thing in the world of Mobile Development? Do you think it will replace the existing conventional development methods? Let’s wait and watch. In the meantime, you can get yourself familiarized with Xamarin and see for yourself whether it will work or not.)
What is Xamarin? How does it help in cross-platform mobile app development?
With the recent technological advancements in the Mobile sphere these days, we can use a phone to do almost anything. The major mobile market share is held with Google’s Android. Followed by Apple’s iOS and then Microsoft’ѕ Windows. If you arе a budding mobile developer, at a point you may face this most crucial situation. Where yоu would want to run yоur app on a platform different from which it was designed for.
But learning a new language, the APIs, and other stuff may seem a tedious task and it can make you stick to your platform. But something called Xamarin can help you build cross-platform mobile applications that can perform almost similar to the platform native applications.
What is Xamarin
Xamarin is a software company founded back in 2011. And it was recently in 2016 that it was acquired by Microsoft. Xamarin provides a developer with tools that can help them in building cross-platform mobile applications. The applications can have all the native features and also share the common codebase at the same time. As per Xamarin stats, more than 15000 companies rely on their tools and the list includes many big names out there.
Xamarin tools are available to download with Visual Studio and you can directly create Android, iOS and Windows apps from Visual Studio itself. Most of the common code is written in C#. So you don’t need to learn Java, Objective-C or Swift to build apps if you already know C#. If you are a beginner, then taking the Xamarin path instead of the conventional learning process can actually teach you app development for more than one platforms. But will you miss out on real native functionality?
The answer to that question is mostly No. The great set of features provided by the entire toolset makes sure you don’t miss out on any functionality. But at some point, where you might want to dig a lot deeper. Xamarin lets you call existing code written in other platform-specific languages such as Java in Android. But that is only when you are building something very specific which cannot be implemented on different platforms.
Xamarin supports wearable devices as well. You can build native applications for Android Wear and Apple Watch as well. The Xamarin component store lets you add more functionality to your apps by downloading simple plugins. You can easily integrate your application with most of the popular backends like Microsoft Azure, Parse and etc. You can add popular authentication methods as well. And also, plugins to add billing support and other features are available as well. Most of the popular plugins are cross-platform but platform specific plugins are available as well, for example, the Google Play billing support plugin.
How does Xamarin work
This is the most asked and peculiar question about this platform. So, what does basically Xamarin does that you can write a common code for different platforms? At the very root level, Xamarin has converted the entire existing Android and iOS SDK to C# so that you can code in a more familiar language. And as you can use C# to code for both the platforms, you need to remember less of syntax. You can access almost any iOS or Android API in C# with the Xamarin tools.
Now coming to its UI, the UI remains pretty much the same. You need to build the UI separately for different platforms and then bind the UI with the common codebase. Here is a picture from Xamarin website that I would like to share so that you can understand better what is happening under the hood.
So, you can build actual native application UI. Such UIs not only provide the user with required feel but also the apps behave as if they were normal native apps. Below the platform specific UI code, is the shared C# code that calls the common codebase.
There are actually two different ways to build the UI. You can use the original native methods to build the UI or you can use Xamarin.Forms. Forms let you build UI for different platforms all at once. There is almost 100% code sharing if you decide to choose Forms over Native UI Technology.
After doing the UI comes the most difficult part in which you need to connect the UI to the codebase. And that again can be done by two different code sharing strategies called ‘Shared Project’ or ‘Portable Class Libraries’.
Getting started with Xamarin
Now let’s check out how to lay your hands on this amazing thing. To use Xamarin on Windows, you need to install Visual Studio. You can download Visual Studio Community for free or purchase a premium license if you don’t have one already. Head over to xamarin.com to download Visual Studio, already configured with Xamarin tools.
Visual Studio is a great IDE by Microsoft that has been widely used to develop Windows applications. Once you are done with installing and setting up Visual Studio, you can create a new ‘Cross Platform App’ project and get going. You will be prompted to choose some settings and you are done. Visual Studio may take some time for setting up your project.
To know more, you can read the original documentation here. Also, play around the studio and check out the default files in the project to actually know how everything is working under the hood.
Xamarin University
So, you are pretty interested in this thing and you feel that this is the future of mobile applications. If you are serious about learning Xamarin or the mobile development, then I suggest you have a look at Xamarin University. The online university provides live online lectures, 1:1 student interaction, the guidance of Xamarin experts and a lot more. A lot of things are covered in entire curriculum and you can for sure learn a lot. The fee is pretty affordable and it can cost you somewhere around 83.25$/month to enroll in the course. Check out Xamarin University here.
Can Xamarin be the next big thing in the world of Mobile Development? Do you think it will replace the existing conventional development methods? Let’s wait and watch. In the meantime, you can get yourself familiarized with Xamarin and see for yourself whether it will work or not.