So, one of the main features of coding using the native SDK provided by Android and iOS is the fact that you get not only a better performance, but also the look and feel of each platform: for example, on iOS, a tab-navigation bar would be located at the bottom of the screen, while in Android it is located at the top (yeah I know it also can be top and bottom, but you get my point), or also the Navigation Drawer dock is an Android navigation style while (as far as I know) there is nothing similar in iOS native sdk. My point being, you can feel the difference of platforms by their design guidelines which is a good thing, since it makes your app looks professional.

So taking that into account, in terms of performance and maintaining the feeling of your app, using JS-based frameworks like Titanium or PhoneGap will not make a wise choice.

Then comes Xamarin. As I read in here: Xamarin how it is getting the Native Look and Feel? it seems it is a C# wrapper for native SDK, which as far as I understand, it should not affect performance. But where's the look and feel part. Since XML layouts are not entirely what gives Android or iOS apps their feel, but also the navigation (which comes from the controller classes) how does Xamarin deals with these? It is said in their website that you can share code between platform, but will that also means I have to share navigation system and similar?

Finally, for the sake of "not writing code for each platform" , is it worth NOT to use native SDK and go with Xamarin (I don't really have a problem writing code for both iOS and Android), or is this framework target for C# developers so they won't have to learn Objective-C or Android.

Any extra explanation would be awesome, and thanks in advance.

有帮助吗?

解决方案

I built a large application within the last year (2013) with different components: mainly an API (ASP.NET Web API => C#), a Website (ASP.NET MVC => C# + AngularJS), and both an app for Android (Xamarin.Android => C#) and iOS (Xamarin.iOS => C#). The decision to use Xamarin had its advantages and its disadvantages, but all in all I am more than happy with it.

As you can see in my list above, almost everything was done with C# (okay, the Website is mainly written in JavaScript ;-)). It's a wonderful mature language with really nice features (as LINQ). In my scenario it becomes clear: I did not have to learn and to perfect four languages (Swift/Objective-C, Java, C#, JavaScript) but only two: C# and JavaScript.

That comes especially into play regarding the code sharing aspect: our client applications aren't really thin clients because of some offline functionality which requires a lot of synchronization logic, so the UI part of the two apps is only one side of the medal. As it turned out, I could really use 90% of that non-interface code on both iOS and Android. This is an incredibly huge benefit, as it's not only about some language originalities of Swift/Objective-C or Java, but also about the different frameworks you are using on iOS and Android. To use the .NET Framework/Mono as foundation of every Xamarin app enables you to abstract things like data access or network communication from the underlaying OS.

In terms of speed and UI you don't have any disadvantages, because you're using the native APIs 1:1. Whatever is available on iOS or Android is also available through Xamarin. And whenever Apple for example ships a new version of iOS, Xamarin will ship the update for that within a few days, so you don't have to wait to be able to use newly introduced features by Apple.

Xamarin uses a technique called Ahead of Time Compiling on iOS, so everything you write in C# is compiled into the native iOS stuff before it is deployed to your device. That means there is no difference in what is executed between a "native" Objectice-C application and a Xamarin application (except some small overhead which isn't noteworthy from my experiences).

On Android Just in Time compilation is used as just with any other "native" Android app, too.

That all means you have all the exact same APIs and possibilities you would otherwise have, if you would go with Objective-C or Java. You even use the same objects for building your UI with the exact same types and names (sometimes slightly optimized ;)). So if you want a tab bar navigation for your app - you use a UITabBarController for that. See iOS vs. Xamarin.

After multiple years on my way with Xamarin I only one disadvantage:

Possible memory leaks. Their whole samples out there are a bunch of crap regarding essential basics of preventing memory leaks. If you are working with "expensive resources" like media files within your application, you should take care from day one. I had to get rid of all that problems when an app of mine had already been growing to up to 35 different (complex) dialogs. That took me almost two months or in other words thousands of bucks. They provide some documentation about it, but the tooling is poor at this end. And errors are likely to appear and very hard to be found (example).

But all in all it was one of my best decisions to go with Xamarin.

其他提示

I have been coding with Xamarin for a while now. Its been great so far. Any problems I've had I figured it out because c# is my native language. The Xamarin site has many examples and API references for many features on all platforms.

  1. Performance - You get native performance from using Xamarin. No questions asked. I have been using it to create audio, video and photo recording features for a new app i'm working on. Xamarin processes the c# code into native byte code for all platforms. Thats how this is achieved.

  2. Look - The look of your app will be native. You literally have to use the Android xml format to make your user interface and the same Goes for IOS. You will still style your elements the same way you did on each platform. All Xamarin does is link a view to an event for you.

  3. Api - The beauty of Xamarin is in the API. They ported the whole Android and IOS namespace to c#. Take a look at their Documentation.

  4. Expensive - My only problem with Xamarin is that it is expensive. If you check their pricing it is outrageous. But you get what you pay for. A premium product that is backed by support.

  5. C# - Sharp is a great language that has loads of support. The new async/await gets ride of the whole thread management issue. Json processing is super easy on the platform. I have uploaded several classes on Github that can be used for many apps.

If you are from a java background, brushing up on your c# skills will be a breeze.

The rdio app was created with Xamarin. Download it on Android and IOS and test its performance and enjoy its native look.

Best of Luck

There is much much more internet content, help, and support for native. That alone helps me make my choice. If you are really good at Xamerin, maybe 70% of the code you write will be usable by both apps, you still have to custom tailor things for each app.

But again, the support for native is so vast, that if you run into a proble, so has someone else.

With xamerin, well, good luck.

When I say app I mean iOS/Android

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top