I am a .NET developer. I have a complete Android app developed in Android studio. I want to develop that app in Xamarin cross platform.
Which project template should I choose to develop my app both for Android and iOS? Which one of these will be easier to develop a cross platform app?
Blank App (Native Portable)
Blank App (Native Shared)
Blank App (Xamarin Forms Portable)
Blank App (Xamarin Forms Shared)
These links will help you to decide which project type you'll going to use:
https://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options/
https://xamarinhelp.com/portable-class-library-pcl-vs-shared-projects/
http://hotkrossbits.com/2015/05/03/xamarin-forms-pcl-vs-shared-project/
Xamarin Shared Library and PCL
http://xfcomplete.net/general/2016/01/19/pcl-or-shared-project/
Here are some aspects:
Xamarin Forms vs Native
Native you have to specify your Templates for each OS
Xamarin Forms, one Layout for all OS - But you can't use platform specific views/controls
Portable:
No platform specific code (it's possible to write your own lib for it, but for the most important features you will find such libraries on github or over nuget - e.g. https://github.com/XLabs/Xamarin-Forms-Labs for Controls, Camera-/Location-/..-access)
Easier to code Apps for multiple platforms - no need for compiler directives for code switching depending on platform
no need to think about what code is working on which os
easier to maintain and test (in my opinion, with a good design of your architecture it's not a big deal to make a shared project good maintainable and testable like an portable app)
Which platforms do you use? Are these supported in the PCL-libraries you need?
Shared:
Easier acces on platform-specific features
more versatile / flexible
Compiler directives for OS
Even though you have to decide which type will good fit with your values and needs.
I hope, I could help a little bit.
Related
I have made a .net core 2.2 app and it works great, I can browse to it through my browser and all of the stuff I made works. I am wondering if it is possible to make an app for my phone though instead of getting to my server through the browser. I mainly want to do this so that I have a better phone side layout. Is this possible and if so could you point me to a good starting point to figure out how to make something like this?
You could have a look at Xamarin perhaps?
Xamarin is a free open-source framework to build truely native cross-platform mobile apps using C# .NET for iOS, Android or Windows. It runs on Mono and .NET to build apps with native performance and native UI.
Xamarin allows you to develop native apps using C# language and platform specfic tools/SDKs and share the same code across multiple platforms - iOS, Android or Windows.
https://visualstudio.microsoft.com/xamarin/
What is the difference between these Visual Studio 2017 new project options?
File > New > Project > Visual C# > …
OPTION 1. > Cross-Platform which supports iOS, Android, etc.
OPTION 2. > iOS Extensions
OPTION 3. > iPhone & iPad > iOS App (Xamarin)
OPTION 4. iOS XAML App (Xamarin.Forms)
I want to make an app on iPad that displays live images from a remote USB camera, via a socket. Later to also run on iPhone, Android, and Windows 10.
OPTION 1. > Cross-Platform which supports iOS, Android, etc.
Creates a cross platform Xamarin.Forms (XF) solution with projects to support iOS, Android, and UWP and a project to hold all of your shared code, which may be all code depending on your needs.
With XF all, or most, of your back end and front end code can go in one shared library project, which is also created when you create this template solution.
In the shared library project, you will have access to cross platform abstracted controls and views like Label, Button, Image, ListView, and most other standard user controls/views, as well as all APIs in .NET Standard 2.0. These Xamarin.Forms controls/views will be rendered on each platform by platform specific renderers, i.e. a XF Button will render as a UIButton on iOS and an Android Button on Android, etc.
Depending on your needs, you still may need to add some platform specific code to your iOS, Android, or UWP projects, either to make your own custom renderers to render XF controls/views to native controls/views of your choosing or access control properties that are not available in the shared, abstracted XF control, or to run other platform specific code, like converting text to speech, which is different on each platform. Xamarin.Forms does provide methods to write platform specific code which can then be invoked from the shared code project, and also a way to make your own custom control/view renderers.
OPTION 2. > iOS Extensions
The are additions to an iOS app project. With these projects, you can create iOS extensions that can be used within iOS iMessage app or the iOS Share menu, for example.
OPTION 3. > iPhone & iPad > iOS App (Xamarin)
This is to develop an iOS only app project using Xamarin.iOS. Xamarin.iOS is a C# binding to the native iOS SDK, so anything that can be done with Obj-C or Swift in XCode can be done in C# using Xamarin.iOS.
OPTION 4. iOS XAML App (Xamarin.Forms)
This is the same as OPTION 1 above, but only the core shared project and the iOS project are created by default. You could later add an Android and UWP project, but if you do plan on supporting all three platforms in the future, you might as well use option one as a starting point.
Xamarin Forms is a write once deploy many option. You write your code and do your UI in Forms, and it will run on iOS, Android and Windows(ish)
iOS (Xamarin) is a native iOS app, but written using C# and Xamarin compiles to native iOS. If you wanted Android, you'd have to rewrite in Xamarin (Android).
There are a number of reasons to use one over the other, that is beyond the scope of SO, but there are a few good articles on the Xamarin site, and other places.
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/get-started/introduction-to-xamarin-forms
https://arctouch.com/blog/xamarin-forms-xamarin-native/
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am currently reading up on Xamarin and have stumbled upon a topic that confuses me. My intent is, to develop an iOS app as the target of my project. However, due to other circumstances, I can only test on an Android Phone right now and first in the last part of the development on an iPhone. Therefore, the app would have to be initially developed and tested for Android and then later on - through Xamarin - deployed as an iOS app.
In Visual Studio with Xamarin installed, there is a choice of using native app development such as Xamarin.iOS, Xamarin.Droid and Xamarin Windows app. As far as I was told by some more experienced programmers, it does not matter which of those three apps/platforms one would choose for the initial development as it is always possible - again through Xamarin - to deploy to whatever platform is required in the end.
Now there is also a fourth app solution in the project menu, called "cross-platform" and this confuses me. As I understand, this is a general app choice virtually fulfilling the same purpose as the native apps, mentioned in the previous paragraph - deployment to whatever platform is desired at the end of the project.
Unless I have misunderstood something here, what exactly would be the difference or idea of having a so called "cross-platform app" as a fourth choice if it can basically do the same as the native apps?
In Xamarin there is two approaches:
Traditional Approach where you share application business logic and you write UI specifically for each platform using Xamarin.Android or Xamarion.iOS APIs to target ~70% of code share.
Xamarin.Forms which is a library on top of the specific APIs (Xamarin.Android and Xamarin.iOS) to help share UI as well to target ~90% of code share.
With Xamarin you generate a native app and keep in made the quote:
Everything you can do in native with Java, Objective-c or swift you
should be able to do with Xamarin.
Xamarin does not magically make an app, you write for Android, run on iOS. At least not without creating an iOS app and all the UI etc. that goes along for that.
With Xamarin you create native applications, just written in C# instead of Java or Objective-C or Swift.
So why choose Xamarin? It enables you to share a lot of code. Depending on how you structure your code, there are some apps that achieve more than 90% shared code or more. However, that differs a lot from app to app, and differs whether you are using Xamarin.Forms or not.
You might be referring to Xamarin.Forms in your question and the project types that come with it. Xamarin.Forms is UI framework that runs on top of Xamarin.Android, Xamarin.iOS and UWP. However, note this is only a UI framework and it can potentially meet all of your needs.
However, Xamarin.Forms does not magically make a Android application run on iOS. The UI you write using Xamarin.Forms, has a huge potential to run and look fine on iOS too. However, it still runs in an iOS project and not the Android project. This would be the case for any other platform you are going to target.
Xamarin.Forms is an abstraction on top of those individual platforms to help you write your UI once and potentially run everywhere, among other features such as navigation and a service locator.
The project types you are referring to in the Cross-Platform section in Visual Studio, is just different ways of creating Xamarin.Forms apps. This can be in a Portable Class Library (PCL), which creates an assembly targeting the common subset of .NET capabilities of the chosen targets. Along the PCL there will be a application project for each supported platform.
The other type is creating a Xamarin.Forms App using a Shared Project type, which is different from a PCL. How? A Shared Project should be though off as a glorified file linking project. Eh what? Look at it as the files in the Shared Project are copied and compiled in the Application project itself when you build the project. So you can write platform specific code in that Shared Project. It does, however, not generate an assembly you can share with your friends just like the PCL does.
That was a lot of Xamarin.Forms talk. However, Xamarin.Forms is not the only way you can create a Xamarin app. Xamarin provides 1:1 exposure of the native API. Meaning, just like on iOS you create storyboards, ViewControllers, utilizing UIKit for Views etc. You can do exactly the same in a Xamarin.iOS project. The same goes for Xamarin.Android, where you will be able to create Widgets, Activities etc, simply in a Xamarin.Android project. Both of these yield a native App. However, in this case the UI is not abstracted, and gives you much more power to customize your App, without having to work against Xamarin.Forms.
Which one should you pick? That is up to you to figure out. Both approaches, yield fully native Apps with native UI. It just depends on whether you want more or less abstraction.
I've found a few examples, as I in a Xamarin.Native use a Windows UWP. But that would mean that I a Xamarin.Nativ in a Windows UWP Convert.
I would like convert a finished Windows UWP application to the target Android or iOS. Is that generally supported or needs my UWP application rebuild again with Xamarin?
Links:
Adding a Universal Windows Platform (UWP) App
Getting Started with Xamarin.Forms 2.0’s Windows 10 Preview
Unfortunately asfar as I know there is no converter that allows to convert UWP app to Android app straight forward.
There are few ways to make the whole process a lot much more easier (so you can create your Android app faster).
If you wrote your UWP application and separated common code that can be used in the other applications you can also use it in Xamarin.Android app - the best way is to have PCL with the common code.
It is also important which type of Xamarin app you would like to create:
1) Xamarin Forms - common UI for each app: Windows, Android and iOS.
There is one shared code that can be used by them. Remember that Xamarin Forms apps are generally speaking the best for displaying the data and they are limited with reference to platform specific functionality.
Please see below to read more:
https://docs.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/sharing_code_options/
2) Xamarin.Platfrom (so Xamarin.Android and Xamarin.iOS):
Here you can create native UI foreach of the project (Windows, Android and iOS) and access specific platform functionality.
With reference to the code - you can put common code in one PCL and have access to it from each project.
Please see this site - here you can find different Xamarin options to create cross-platfrom apps:
https://developer.xamarin.com/
Firstly, if you want a shared code, using Portable class library, you can use the same code for all the platforms including WPF, Android and iOS. First of all what you can do is convert the codes that is used again and again in the PCL (Portable Class Lirary). Once you get used to PCL, you can easily work on any platform you want.
As the Android, iOS are different from windows, a lot of .net framework functionality is not supported in PCL. Although, once you create the basics in PCL, you can integrate the class library in android as well as iOS.
Usually it is recommended to have two projects for both wp7 and wp8 platforms. Wp7 project contains .cs and .xaml files, and WP8 project contains links to that files.
I think that there is no reason to compile non-platform specific business logic code twice, since it can be referenced to WP8 project.
I'm thinking about following solution structure:
Business logic dll compiled for wp7 (not a PCL)
UI comliled for wp8
UI comliled for wp7
Such application can be compiled and I can deploy it to device/emulator.
The question is: will this app pass certification in Windows phone store? Or it is necessary to recompile shared dll?
UPD:
My crazy idea was born after this steps:
Create new WP7 app (WindowsPhoneApplication1)
Create class library targeted to WP7 (WindowsPhoneClassLibrary1) Use it in WindowsPhoneApplication1
Use Upgrade to WP8 menu. WindowsPhoneApplication1 will be updated to WP8, but the referenced project will be still targeted to WP7!
Such app can be deployed to WP8 devices.
Unless you use a Portable Class Library, you'll need to have separate project files, and compile separately for WP7 and WP8.
Thanks to Claus,
I made some research, and it looks like the answer is - you can use such solution.
I didn't find related information in documentation, but here is a proof from one of MSFT tech. evangelists from Netherlands: link to blogpost
The basic idea is to move all our code that can be used from both our existing Windows Phone 7 app as well as the Windows Phone 8 build, which we will add soon, to a Common project in the solution. The bad thing about this approach is that we have to create the Common project as a Windows Phone 7 class library, which will be used in our Windows Phone 8 build. I haven’t really noticed any negative impact of this decision in my existing apps, but note that you will be referencing a Windows Phone 7 library in your Windows Phone 8 build.
So it is a possible, but not the best solution.