简体   繁体   中英

Adding Xamarin to a Visual Studio C# project in future

We are looking to create a Visual Studio C# project that will be initially released as a Windows application. However, in future we would like to release on iOS and Android platforms using the Xamarin extension.

We plan to have a core application that is kept separate from the GUI code as much as possible to make multi-platform development more convenient in future.

Is this a good plan, or is it better to incorporate Xamarin into the project from the beginning?

We haven't used Xamarin before, and we're hoping to minimise refactoring of our code.

I think most developers would prefer to add the Xamarin project from the beginning but I started a project this way as well and I'd reconsider this as a successful one. However you should have some experienced developers which can handle UI abstractions and not put their code in the UI layer. Maybe you should look at frameworks like MVVM cross if you want to go cross platform.

However, Xamarin evolved as well and there's not just Xamarin.iOS and Xamarin.Andoird anymore. So they released their fantastic framework Xamarin.Forms a few months ago. By using it, you'll be able to reuse huge amount of your code - even the UI-code. So if your Windows Application is either a Windows Phone Application or a Modern UI-App and not a WinForms app (which not supported with Xamarin.Forms), it might be the best option for you.

.Net Framework Portble Class Library is what you need. Code that are shared amongst platforms should be implemented using PCL. What I do for my organisation is that I created one solution for each platform and add reference to PCLs that contain our common code. Our PCLs can run in Windows, Android and iOS.

https://msdn.microsoft.com/en-us/library/gg597391%28v=vs.110%29.aspx

Another way to do it is to write c# classes and add class references to your platform-specific code. However, if you go with this approach, each time you make a modification to the class, you need to make sure it builds in all platforms.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM