Xamarin 移动开发介绍

Introduction to Mobile Development
移动开发介绍


原文网址

Building mobile applications can be as easy as opening up your IDE, throwing something together, doing a quick bit of testing, and submitting to an App Store – all done in an afternoon. Or it can be an extremely involved process that involves rigorous up-front design, usability testing, QA testing on thousands of devices, a full beta lifecycle, and then deployment a number of different ways.
构建移动应用程序可以像打开你的IDE、拖放一些东西在一起、做一个很快的小测试,并提交到App 商店一样容易–一下午全做完。或者可以是一个极端复杂的过程,涉及到严密的前端设计、性能测试、上千设备上的品质保证测试、完整的测试生命周期,以多个不同的方式部署。
In this document, we’re going to take a thorough introductory examination of building a Xamarin mobile application, including:
在本文中,我们将参加一个构建Xamarin移动应用的全面的入门性剖析,内容包括:


1.Requirements – We’ll enumerate and examine the requirements for building for iOS and Android applications.
         需求–我们将列举和剖析构建iOS和Android应用的必须条件。


2.Introduction to Xamarin – List of features of the Xamarin platform.
         Xamarin介绍 –列出Xamarin平台的特征。


3.How Does Xamarin Work? – A brief overview of how Xamarin works to bring C# to iOS and Android.
         Xamarin如何工作? – 简要概述Xamarin如何使用C#与iOS及Android工作。

    
4.Get started! – Dive in to building your first Xamarin app, for iOS, Android, or all the platforms using Xamarin.Forms.
    开始! – .着手用Xamarin.Forms构建你的第一个iOS、Android或这两个平台的Xamarin应用。


This document is intended to introduce the Xamarin platform. To learn more about the process of building mobile applications from design through to testing, refer to the Introduction to the Mobile Software Development Lifecycle document.


本文意在介绍Xamarin平台,学习更多关于构建移动应用的从设计到测试的过程。参考 移动软件开发生命周期介绍 文档。




Requirements
必须条件




If you’d like to develop for iOS, whether you want to code in Xamarin Studio or Visual Studio, you must have an Apple Macintosh computer running at least OS X Mountain Lion on hand. Although Xamarin applications are based on the .NET BCL and are written in C#, Xamarin requires the iOS SDK and Xcode in order to compile. Additionally, the iOS Device Simulator is part of the iOS SDK, and therefore only available on Mac. In order to download the iOS SDK, you must be a member of Apple’s Developer Program. This program requires an
upgraded membership that costs $99 USD/year.


如果你喜欢为iOS开发, 不管你想用 Xamarin Studio 或 Visual Studio编写代码, 你手里必须要有至少运行 OS X Mountain Lion 的Apple Macintosh计算机。尽管Xamarin应用是基于.NET BCL (基础类库-Base Class Library)而且是用C#写的, Xamarin 需要 iOS SDK和 Xcode进行编译,另外,  iOS 设备模拟器是 iOS SDK的一部分,只对Mac有效。要下载 iOS SDK, 你必须成为  Apple’s Developer Program. 的成员,这需要一个升级后的会员资格,该资格每年需要支付99美元。


All the tutorials presented here are based on the latest version. Installation is covered in the next tutorial.
所有当前教程都是基本最新版本的,对于一个新版教程,原版本的安装将被覆盖。




Introduction to Xamarin 
Xamarin介绍




When considering how to build iOS and Android applications, many people think that the indigenous languages, Objective-C and Java, respectively, are the only choice. However, over the past few years, an entire new ecosystem of platforms for building mobile applications has emerged.
当考虑如何构建iOS和Android应用时,许多人认为Objective-C 或Java等原有语言才是唯一的选择,然而,在过去的几年里,一个全新的构建移动应用平台的生态体系已经出现了。


Xamarin is unique in this space by offering a single language – C#, class library, and runtime that works across all three mobile platforms of iOS, Android, and Windows Phone (Windows Phone’s indigenous language is already C#), while still compiling native (non-interpreted) applications that are performant enough even for demanding games.
Xamarin是唯一能通过提供跨iOS、Android和Windows Phone这三大平台工作的单一的语言(C#)、类库和运行时,仍能编译性能足以满足高要求游戏的原生(非解释)应用的平台(注:Windows Phone的原用语言是C#)。【 performant 法语单词,性能好】


Each of these platforms has a different feature set and each varies in its ability to write native applications – that is, applications that compile down to native code and that interop fluently with the underlying Java subsystem. For example, some platforms only allow you to build apps in HTML and JavaScript, whereas some are very low-level and only allow C/C++ code. Some platforms don’t even utilize the native control toolkit.
开发移动应用的平台中的每一个都有一些不同的功能,且编写原生应用能力各有不同,即,编译为原生代码的应用,与下层的JAVA子系统流畅地交互。比如,有些平台只允许你用HTML和JavaScript构建应用,反之,有些则是非常低层的而且只允许C/C++代码,有些平台甚至不能利用原生控件工具箱。


Xamarin is unique in that it combines all of the power of the indigenous platforms and adds a number of powerful features of its own, including:
而Xamarin独一无二地结合所有这些原有平台的功能并增加了一系列强大的特征,包括:


1.Complete Binding for the Indigenous SDKs – Xamarin contains bindings for nearly the entire underlying platform SDKs in both iOS and Android. Additionally, these bindings are strongly-typed, which means that they’re easy to navigate and use, and provide robust compile-time type checking and during development. This leads to fewer runtime errors and higher quality applications.
与原有SDK完全绑定-Xamarin几乎包含与iOS和Android中全部下层平台SDK的绑定, 另外, 这些绑定是健壮型的,这意味着它们易于导航和使用,并提供健壮的编译时类型检查和过程开发,这带来更少的运行时错误和更高品质的应用。    


2.Objective-C, Java, C, and C++ Interop – Xamarin provides facilities for directly invoking Objective-C, Java, C, and C++ libraries, giving you the power to use a wide array of 3rd party code that has already been created. This lets you take advantage of
existing iOS and Android libraries written in Objective-C, Java or C/C++. Additionally, Xamarin offers binding projects that allow you to easily bind native Objective-C and Java libraries using a declarative syntax.
Objective-C, Java, C, 和 C++ 互动 – Xamarin 提供直接调用Objective-C、 Java、C、和C++ 库的能力,能使用众多的现有三方代码,可获得Objective-C、Java 或C/C++生成的 iOS 和 Android 库的优势,另外,Xamarin提供绑定项目的功能,允许使用声明语句轻松绑定Objective-C  和 Java库 。


3.Modern Language Constructs – Xamarin applications are written in C#, a modern language that includes significant improvements over Objective-C and Java such as
Dynamic Language Features , Functional Constructs such as Lambdas , LINQ ,


Parallel Programming features, sophisticated Generics , and more.
现代的语言结构- Xamarin应用程序使用C#编写,C#是一种现代的语言,具有许多超越 Objective-C 和 Java的重要改善,如动态语言特性,还包括功能性结构(如Lambas)、LINQ、并行编程特性、深奥的Generics等。


4.Amazing Base Class Library (BCL) – Xamarin applications use the .NET BCL, a massive collection of classes that have comprehensive and streamlined features such as powerful XML, Database, Serialization, IO, String, and Networking support, just to name a few. Additionally, existing C# code can be compiled for use in your applications, which provides access to thousands upon thousands of libraries that will let you do things that aren’t already covered in the BCL.
惊人的基础类库(BCL)-Xamarin应用使用.NET基础类库,它是一个大型的类的集合,这些类具有全面而简洁的功能,诸如,强大的XML、数据库、序列化、IO、字符串及网络支持等,这里仅列举一小部分。另外,现存的C#代码能被编译并用在你的应用中,这些代码提供访问成千上万的库,这些库的能完成BCL能力范围之外的工作。


5.Modern Integrated Development Environment (IDE) – Xamarin uses Xamarin Studio on Mac OS X, and also Xamarin Studio or Visual Studio 2013 on Windows. These are both modern IDE’s that include features such as code auto completion, a sophisticated Project and Solution management system, a comprehensive project template library, integrated source control, and many others.
现代的集成开发环境(IDE)-Xamarin在Mac OS X下使用Xamarin Studio,在Windows下使用 Xamarin Studio 或 Visual Studio 2013。它们都是具有诸如代码自动编译、复杂项目和解决方案管理系统、综合项目模板库、集成的源控件和其他许多功能的现代集成开发环境。


6.Mobile Cross Platform Support – Xamarin offers sophisticated cross-platform support for the three major mobile platforms of iOS, Android, and Windows Phone. Applications can be written to share up to 90% of their code, and our Xamarin.Mobile library offers a unified API to access common resources across all three platforms. This can significantly reduce both development costs and time to market for mobile developers that target the three most popular mobile platforms.
移动跨平台支持– Xamarin 为iOS、 Android和Windows Phone三大主流移动平台提供复杂的跨平台支持,编写的应用可共享90%的代码,并且Xamarin.Mobile库跨越三大平台提供统一API来访问公共资源。这可明显减少针对三大最流行移动平台的移动开发的成本和时间。


Because of Xamarin’s powerful and comprehensive feature set, it fills a void for application developers that want to use a modern language and platform to develop cross-platform mobile applications.
由于Xamarin的强大而综合的特征,它填补了使用一种现代语言和平台开发跨平台移动应用的应用开发的空白。




Note:
This Getting Started series focuses on getting started building iOS and Android applications. If you’re interested in building for Windows Phone, Microsoft offers tutorials here. If you’re interested in learning more about cross-platform development with Xamarin (including Windows Phone), you can find our guide here.
说明:
本开始系列聚焦于开始构建iOS和Android应用,如果你对构建Windows Phone感兴趣,微软在这里提供教程。如果你对学习更多的Xamarin跨平台开发(包括Windows Phone)感兴趣,你可以在这里找到我们的指南。
Let’s take a look at how this all works.
让我们看看所有这些是如何工作的。




How Does Xamarin Work?
Xamarin如何工作?




Xamarin offers two commercial products: Xamarin.iOS and Xamarin.Android. They’re both built on top of Mono, an open-source version of the .NET Framework based on the published .NET ECMA standards. Mono has been around almost as long as the .NET framework itself, and runs on nearly every imaginable platform including Linux, Unix, FreeBSD, and Mac OS X.
Xamarin 提供了两个商业产品,Xamarin.iOS和Xamarin.Android。他们都创建在Mono上,Mono是一个基于已发布的.NET ECMA标准之上的.NET框架开源版本。Mono的历史几乎与.NET框架本身一样长,并且运行在几乎每一个能想到的平台,包括Linux、 Unix,、FreeBSD和 Mac OS X。


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.
In both cases, Xamarin applications utilize a runtime that automatically handles things such as memory allocation, garbage collection, underlying platform interop, etc.
在iOS下,Xamari的Ahead-of-Time ( AOT) 编译器直接将amarin.iOS应用编译本机ARM程序集代码。在Android下,应用被Xamarin的编译器编译为中间语言(IL),中间语言在应用启动时被编译为本机程序集。
两种情况下,Xamarin应用 利用  自动处理诸如内存分配、垃圾收集、平台下的交互等事务的运行时机制。


MonoTouch.dll and Mono.Android.dll
MonoTouch.dll 和 Mono.Android.dll


Xamarin applications are built against a subset of the .NET BCL known as the Xamarin Mobile Profile. This profile has been created specifically for mobile applications and packaged in the MonoTouch.dll and Mono.Android.dll (for iOS and Android respectively). This is much like the way Silverlight (and Moonlight) applications are built against the Silverlight/Moonlight .NET Profile. In fact, the Xamarin Mobile profile is equivalent to the Silverlight 4.0 profile with a bunch of BCL classes added back in.
Xamarin应用是针对.NET BCL的一个子集构建的,这就是被公认的Xamarin 移动概要(Xamarin Mobile Profile)。该概要是为了移动应用而被创建的,并被打包在MonoTouch.dll和Mono.Android.dll(分别针对iOS和Android)中。这很像银光(Sliverlight)(和月光(Moonlight))应用是针对SilverLight/ Moonlight.NET 概要构建的。实际上,Xamarin 移动概要同银光(Silverlight) 4.0概要一样带着一组后面加进去的BCL类。


For a full list of available assemblies and classes, see the Xamarin.iOS Assembly List and the Xamarin.Android Assembly List
关于有效程序集和类的全部列表,参见Xamarin.iOS程序集列表Xamarin.Android程序集列表


In addition to the BCL, these .dlls include wrappers for nearly the entire iOS SDK and Android SDK that allow you to invoke the underlying SDK APIs directly from C#.


除了BCL以外,这些.dll包括几乎整个iOS SDK和Android SDK的封装,允许直接从C#调用下层的SDK API。


Application Output
应用输出


When Xamarin applications are compiled, the result is an Application Package, either an
.app file in iOS, or .apk file in Android. These files are indistinguishable from indigenous application packages and are deployable in the exact same way.
当Xamarin应用被编译时,结果是一个应用包,要么是iOS的.app文件,要么是Android的.apk文件,这些文件与原生应用包是难以区分的,而且在严格相同的方式下是可部署的。




Getting Started
开始




Now you've learned a little about how Xamarin works, it's time to dive in!
现在你已经学习了一些关于Xamarin如何工作的内容,是时候开始进入实战了。


The next step is to start building your first app using one of these guides:
下一步是使用以下指南中的一个来开始构建你的第一个应用。
Hello, iOS 


Hello, Android


Introduction to Xamarin.Forms


Summary

This document has merely introduced the Xamarin platform. The real fun starts when you get your first app up-and-running. Check out the Hello, iOS, Hello, Android, and Introduction to Xamarin.Forms guides to begin.


总结:
该文档仅仅介绍了Xamarin平台,当你开始第的一个应用良好运行时真正的有趣就开始了,查看Hello, iOS、 Hello, Android、和  Xamarin.Forms介绍指南来开始吧。



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值