在今年所有的IDE演进(主题上的所有平台都发生了变化)之后,我希望了解这些平台的技术状态。

它们各自的优点和缺点是什么? 其中一种方法有局限性吗?

我在c#和Javascript方面有很好的经验,没有编程语言的影响可以倾斜到一边。


当前回答

我和Xamarin一起工作过。以下是我发现的优点和缺点:

阳性

易于编码,c#使工作更容易 性能不是问题 本地用户界面 好的IDE,很像Xcode和Visual Studio。 Xamarin的调试器 Xamarin SDK是免费的开源软件。维基

底片

你需要了解你想要瞄准的每个平台(iOS、Android、WP8)的API。但是,您不需要了解Objective-C或Java。 Xamarin跨平台共享的东西很少(比如数据库和web服务)。 你必须为每个平台分别设计UI(这可能是好事,也可能是坏事)。

其他回答

Phonegap非常慢:点击一个按钮最多需要3秒才能显示下一个屏幕。 Iscroll是缓慢和跳跃的。

还有其他有趣的错误和问题,我能够克服, 但总的来说,还没有完全成熟。

编辑: 根据不爽的评论,实际上不是Phonegap慢,而是JS/Browser原生引擎慢

我使用Appcelerator Titanium的时间并不长,但我会把我对它的理解放在最后。

我可以更多地谈谈PhoneGap和Xamarin之间的区别,因为我每周都有5天(或更多)的时间在使用这两个软件。

如果您已经熟悉c#和JavaScript,那么我想问题是,业务逻辑是更适合JavaScript还是c#的领域?

PhoneGap

PhoneGap is designed to allow you to write your applications using JavaScript and HTML, and much of the functionality that they do provide is designed to mimic the current proposed specifications for the functionality that will eventually be available with HTML5. The big benefit of PhoneGap in my opinion is that since you are doing the UI with HTML, it can easily be ported between platforms. The downside is, because you are porting the same UI between platforms, it won't feel quite as at home in any of them. Meaning that, without further tweaking, you can't have an application that feels fully at home in iOS and Android, meaning that it has the iOS and Android styling. The majority of your logic can be written using JavaScript, which means it too can be ported between platforms. If the current PhoneGap API does most of what you want, then it's pretty easy to get up and running. If however, there are things you need from the device that are not in the API, then you get into the fun of Plugin Development, which will be in the native device's development language of choice (with one caveat, but I'll get to that), which means you would likely need to get up to speed quickly in Objective-C, Java, etc. The good thing about this model, is you can usually adapt many different native libraries to serve your purpose, and many libraries already have PhoneGap Plugins. Although you might not have much experience with these languages, there will at least be a plethora of examples to work from.

Xamarin的

Xamarin.iOS and Xamarin.Android (also known as MonoTouch and MonoDroid), are designed to allow you to have one library of business logic, and use this within your application, and hook it into your UI. Because it's based on .NET 4.5, you get some awesome lambda notations, LINQ, and a whole bunch of other C# awesomeness, which can make writing your business logic less painful. The downside here is that Xamarin expects that you want to make your applications truly feel native on the device, which means that you will likely end up rewriting your UI for each platform, before hooking it together with the business logic. I have heard about MvvmCross, which is designed to make this easier for you, but I haven't really had an opportunity to look into it yet. If you are familiar with the MVVM system in C#, you may want to have a look at this. When it comes to native libraries, MonoTouch becomes interesting. MonoTouch requires a Binding library to tell your C# code how to link into the underlying Objective-C and Java code. Some of these libraries will already have bindings, but if yours doesn't, creating one can be, interesting. Xamarin has made a tool called Objective Sharpie to help with this process, and for the most part, it will get you 95% of the way there. The remaining 5% will probably take 80% of your time attempting to bind a library.

更新

正如下面的评论所指出的,Xamarin发布了Xamarin Forms,这是一个围绕平台特定UI组件的跨平台抽象。绝对值得一看。

PhoneGap / Xamarin Hybrid

现在,因为我说过我会得到它,上面提到的PhoneGap的警告,是一种混合方法,你可以使用PhoneGap的一部分,Xamarin的一部分。我在这方面很有经验,我要提醒你不要这么做。高度。这样做的问题在于,这是一个无人之地,如果你遇到问题,几乎没有人会接近你在做什么,并会极大地质疑你正在尝试做什么。这是可行的,但绝对不好玩。

Appcelerator钛

As I mentioned before, I haven't worked much with Appcelerator Titanium, So for the differences between them, I will suggest you look at Comparing Titanium and Phonegap or Comparison between Corona, Phonegap, Titanium as it has a very thorough description of the differences. Basically, it appears that though they both use JavaScript, how that JavaScript is interpreted is slightly different. With Titanium, you will be writing your JavaScript to the Titanium SDK, whereas with PhoneGap, you will write your application using the PhoneGap API. As PhoneGap is very HTML5 and JavaScript standards compliant, you can use pretty much any JavaScript libraries you want, such as JQuery. With PhoneGap your user interface will be composed of HTML and CSS. With Titanium, you will benefit from their Cross-platform XML which appears to generate Native components. This means it will definitely have a better native look and feel.

还有AppGyver类固醇,结合PhoneGap和本地UI很好。

使用类固醇,你可以添加像本机标签,本机导航栏,本机动画和过渡,本机模式窗口,本机抽屉/面板(facebook侧菜单)等东西到你的PhoneGap应用程序。

这里是一个演示:http://youtu.be/oXWwDMdoTCk?t=20m17s

概述

蒂姆·安德森报道

Cross-platform development is a big deal, and will continue to be so until a day comes when everyone uses the same platform. Android? HTML? WebKit? iOS? Windows? Xamarin? Titanum? PhoneGap? Corona? ecc. Sometimes I hear it said that there are essentially two approaches to cross-platform mobile apps. You can either use an embedded browser control and write a web app wrapped as a native app, as in Adobe PhoneGap/Cordova or the similar approach taken by Sencha, or you can use a cross-platform tool that creates native apps, such as Xamarin Studio, Appcelerator Titanium, or Embarcardero FireMonkey. Within the second category though, there is diversity. In particular, they vary concerning the extent to which they abstract the user interface. Here is the trade-off. If you design your cross-platform framework you can have your application work almost the same way on every platform. If you are sharing the UI design across all platforms, it is hard to make your design feel equally right in all cases. It might be better to take the approach adopted by most games, using a design that is distinctive to your app and make a virtue of its consistency across platforms, even though it does not have the native look and feel on any platform.

编辑Xamarin v3在2014年开始提供Xamarin的选择。表单以及纯粹的本地仍然遵循这里提到的哲学(自由的内联编辑,因为这样一个伟大的答案)

另一方面,Xamarin Studio并没有试图提供一个共享的GUI框架:

我们不试图提供一个有效的用户界面抽象层 在所有平台上。我们认为这是一个不好的方法,会导致 最低标准的用户界面。(纳特·弗里德曼致蒂姆·安德森)

这是对的;但缺点是需要为应用程序维护两个或多个用户界面设计。

关于PhoneGap和Titanium的比较在Kevin Whinnery的博客中有很好的报道。

PhoneGap

The purpose of PhoneGap is to allow HTML-based web applications to be deployed and installed as native applications. PhoneGap web applications are wrapped in a native application shell, and can be installed via the native app stores for multiple platforms. Additionally, PhoneGap strives to provide a common native API set which is typically unavailable to web applications, such as basic camera access, device contacts, and sensors not already exposed in the browser. To develop PhoneGap applications, developers will create HTML, CSS, and JavaScript files in a local directory, much like developing a static website. Approaching native-quality UI performance in the browser is a non-trivial task - Sencha employs a large team of web programming experts dedicated full-time to solving this problem. Even so, on most platforms, in most browsers today, reaching native-quality UI performance and responsiveness is simply not possible, even with a framework as advanced as Sencha Touch. Is the browser already “good enough” though? It depends on your requirements and sensibilities, but it is unquestionably less good than native UI. Sometimes much worse, depending on the browser.

PhoneGap并不像人们想象的那样真正跨平台,并不是所有的功能在所有平台上都得到了同等的支持。

Javascript is not an application scale programming language, too many global scope interactions, different libraries don't often co-exist nicely. We spent many hours trying to get knockout.js and jQuery.mobile play well together, and we still have problems. Fragmented landscape for frameworks and libraries. Too many choices, and too many are not mature enough. Strangely enough, for the needs of our app, decent performance could be achieved (not with jQuery.Mobile, though). We tried jqMobi (not very mature, but fast). Very limited capability for interaction with other apps or cdevice capabilities, and this would not be cross-platform anyway, as there aren't any standards in HTML5 except for a few, like geolocation, camera and local databases.

作者:Karl Waclawek

Appcelerator钛

The goal of Titanium Mobile is to provide a high level, cross-platform JavaScript runtime and API for mobile development (today we support iOS, Android and Windows Phone. Titanium actually has more in common with MacRuby/Hot Cocoa, PHP, or node.js than it does with PhoneGap, Adobe AIR, Corona, or Rhomobile. Titanium is built on two assertions about mobile development: - There is a core of mobile development APIs which can be normalized across platforms. These areas should be targeted for code reuse. - There are platform-specific APIs, UI conventions, and features which developers should incorporate when developing for that platform. Platform-specific code should exist for these use cases to provide the best possible experience.

因此,基于这些原因,Titanium并不是一种“编写一次,到处运行”的尝试。和Xamarin一样。

钛将在类似Xamarin的方向上更进一步。在实践中,他们会做两个不同深度的层:一层是Titanium(在JS中),它会给你一个bee JS-of-Titanium。如果你想要更低级的,可以创建一个额外的层(称为Hyperloop),在那里(总是使用JS)直接调用SO的原生api

Xamarin (+ MVVMCross)

AZDevelop.net

Xamarin (originally a division of Novell) in the last 18 months has brought to market its own IDE and snap-in for Visual Studio. The underlining premise of Mono is to create disparate mobile applications using C# while maintaining native UI development strategies. In addition to creating a visual design platform to develop native applications, they have integrated testing suites, incorporated native library support and a Nuget style component store. Recently they provided iOS visual design through their IDE freeing the developer from opening XCode. In Visual Studio all three platforms are now supported and a cloud testing suite is on the horizon. From the get go, Xamarin has provided a rich Android visual design experience. I have yet to download or open Eclipse or any other IDE besides Xamarin. What is truly amazing is that I am able to use LINQ to work with collections as well as create custom delegates and events that free me from objective-C and Java limitations. Many of the libraries I have been spoiled with, like Newtonsoft JSON.Net, work perfectly in all three environments.

在我看来,有几个巨大的优势,包括

本机性能 更易于阅读代码(IMO) 可测试性 客户端和服务器之间的共享代码 支持(尽管Xam可以在bugzilla上做得更好)

升级对我来说是使用Xamarin和MVVMCross结合。它仍然是一个相当新的框架,但它是从其他几个框架(如MvvmLight和moncross)的经验中诞生的,现在已经在几个发布的跨平台项目中使用。

结论

在了解了这些框架之后,我的选择是根据产品需求来选择开发工具。然而,一般来说,如果你开始使用一个你觉得舒服的工具(即使它需要更高的初始开销),你将永远使用它。

我选择了Xamarin + MVVMCross,我必须说我对这个选择很满意。 我不害怕使用Native SDK进行软件更新,也不害怕看到系统的有限功能或最琐碎的功能图形。编写相当结构化的代码(DDD + SOA)对于与原生c#视图实现共享核心项目非常有用。

参考资料及连结

http://www.theregister.co.uk/Print/2013/02/25/cross_platform_abstraction/ http://kevinwhinnery.com/post/22764624253/comparing-titanium-and-phonegap http://forums.xamarin.com/discussion/1003/your-opinion-about-several-crossplatform-frameworks#Comment_3334 http://azdevelop.azurewebsites.net/?page_id=181 https://github.com/MvvmCross/MvvmCross http://pierceboggan.com/post/51671827932/binding-third-party-objective-c-libraries-in

作为替代方案,你可以在BridgeIt .mobi上查看BridgeIt。它是开源的,解决了上面讨论的浏览器性能/一致性问题,因为它利用了设备上的标准浏览器而不是web视图浏览器。它还允许你访问本地功能,而不必担心应用商店部署和/或本地容器。

我已经将它用于简单的基于摄像头的访问和扫描仪访问,它适用于简单的应用程序。文档内容有点少。不知道它在更复杂的应用程序上会如何表现。