Is there a unified way of developing app that works on both Windows 8 and Windows Phone 8.
What I mean is that, can I make a single solution/project base or do I need to create different solutions, and then apply code sharing strategies to minimize the effort.
You need separate projects for the two app platforms, but you can share a lot of the effort by utilising portable class libraries, especially if you are using the MVVM pattern. For example, you can make a shared view model class using the PCL version of MVVMLight.
Related
So, I have been developing an android app for some time, and I was requested to try porting this app to windows phone too. In order to reduce the hassle in trying to maintain two separate versions of the same app, I decided to try to port this app into xamarin, because I have heard that its performance is better than hybrid apps. These are my questions with regard to xamarin:-
I want to maintain the same look and feel which I had in my original app into my cross platform app, and at the same time, make it distinct in the windows version. What are the things I can do to achieve this effect?
Is it rather better for me to port this app to windows phone native, because of added problems in trying to create a common app?
Are there any restrictions with regard to Windows store when publishing xamarin apps?
Xamarin doesn't really cover Windows UWP apps, only in the notion that they have the UI Framework Xamarin.Forms running on that platform. Meaning, that what you are making is a native Windows UWP app.
What Xamarin is great at is when you start targeting more than one platform and you have structured your code in a way that it can be reused on the supported platforms. This could for instance be done by putting most of your logic and behavior into a Portable Class Library/NETStandard library and consume it in your apps.
A Typical pattern for making platform agnostic logic and behavior for your apps, is the pattern known as Model-View-ViewModel, where the View is platform specific, while the Model and ViewModel usually are platform agnostic. The ViewModel is where the behavior resides and it is what ties the Model together with the View.
Usually the ViewModel wouldn't directly know the View, but there would be a layer in between (glue), such as XAML or a binding engine from MvvmCross, MvvmLight or ReactiveUI to name some MVVM libraries.
What Xamarin provides is the ability to write C# code for Android and iOS, which greatly enables you to share code between those two platforms, but also all the Windows platforms. Hence, UI, is very much dependent on each of the platforms on their own.
You can, of course, use Xamarin.Forms as a UI abstraction layer, which produces a native UI using the native UI controls to get a similar app on all the targeted platforms.
First of all you need to know there are different styles of Xamarin development, who will share more or less content.
If you use Xamarin Forms you have a Main project non-related to any platform (where you create the views and clases), and specific platform projects who adapt the controls to each native style.
If you develop using Xamarin Classic, you have a Shared project where you only develop data-related classes, and specific platform project with their own views and classes with native-friendly controls and native similar functions, but I think, there is no direct Xamarin Clasic Windows Project.
So if you only want to have two apps who look native both, but with same structure and functionalities Xamarin Forms will be the best option for you, cause you only develop "one single app" who becomes native-style like this:
If what you want is to have different apps, with different functionalities and diferent content, then you need to go for Xamarin Classic. What I recomend you to do then is develop the windows phone in native, but put all of the code you can in a shared library. Then you can create a Xamarin classic Android app and use the shared library. You will still need to mantain two different apps, but you will only need to change the "core" code only one time.
If you use Xamarin Forms to do a UWP windows app I don't think you have any problem to publish it, think Xamarin is from Microsoft.
I am currently working on Xamarin project and after some research, I am confused about how cross platform UI works.
Let's take the 3 following smartphones:
Samsung Galaxy S5
iPhone 6 Microsoft
Lumia 640 LTE
Three phones with three different types of controls. Samsung has 3 buttons at the bottom, whereas the iPhone has just 1 button. The Microsoft phone has 3 buttons like the Samsung, but those are different. So this is why I am confused.
The cross platform design shown in the tutorials such as this tutorial shows a shared design.
However, my goal isn't to make the same interface for each platform. I saw this article which is similar to what I want to make. We have the same app logic, but the design depends of the platform
In order: Android, iOS and Windows Phone
Now, here is the app architecture proposed by Xamarin
To achieve a different design per platform, I must not create a "Forms Xaml Page" in the shared project, but create 3 different pages (1 per platform). However, I'm not sure how this can be achieved.
At the launch, each app executes the following code line:
LoadApplication(new App());
So, if I make 3 different interfaces, how can I load the one specific to the platform the app is running on?
Also, if we use the MVC pattern (I know about MVVM, I just do not understand it at the moment), make 3 differents views, each one with a controller, but only share models/data/motor. (MVC -> 1M/3V/3C).
A good approach for a cross-platform project with platform-specific UIs is to use MvvmCross or a similar library.
The TipCalc-Project is a sample app which shares business logic via a Portable Class Library (PCL) and makes use of the MVVM-pattern (Model View ViewModel). You have a separated UI-project per platform (Android, iOS, ...) and reuse the functionality from your PCL.
This allows to share a large amount of your business code without using Xamarin.Forms and without any compromises regarding your UI.
You should have a basic understanding of MVVM and Dependency Injection for this approach.
With Xamarin.Forms, you are sharing the app logic and potentially all of the UI code by using the Forms API. This means the app interface will be fairly similar on all platforms.
With the non-Forms approach you share the app logic and then any UI code can go in the platform specific project and use the platform specific API.
Reading your requirements, I would suggest you look towards the non-Forms based approach of sharing code with Xamarin, rather than using Forms.
We have some good guides to get your started with this as well as a sample and case study.
I have a Windows Phone 8 (XAML/C#) app and a Windows 8(HTML/JS) app.
Both apps are very different visually, but they consume the same data from a JSON API service.
What would be the best approach (in time, effort and money) to engage the development of these apps?
Example:
Can i write only once the "JSON API/Connection/Serialization/DataModels/etc Code" and reuse it in both apps? (Maybe doing a portable class library)
Should i use XAML for both apps? Javascript for both apps? to unify code languages?
Should i have only one solution containing a WP8 project, and a W8 project?
What's with Windows RT? Will my Windwos 8 app run in WindowsRT?
What I think is :-
You should make portable class library (PCL) for your common code. As
PCLs are made for code reuse.
I think it is not much crucial what are using for UI, it is up to
you in which are good.
You should not make same project for Windows 8 and WP8. don't mix up
things here because there are lot of differences between these two
platforms. In the end you don't want that if you changes for Windows
8 and your WP8 apps stops working. don't create trouble for
yourself.
What I think for Win-RT is - it is at the edge of death. So don't
worry about them too much. In future everything going to be unified.
Note- I strongly recommend you PCLs for your common code. If something is not supported in PCLs then create separate projects(may be specific to platforms) and reuse them.
Hope it help you somehow.
Fist of all I want to say that I've read these two discussions:
How to organize Windows Phone code base to target both 7.x and 8 platforms and
Windows Phone 7/WPF - Sharing a codebase. So, I know about Portable Class Librariy project type which might be an answer to my question. But it isn't an answer for my case.
Problem
I have some old code-base in my project WindowsClassLibraryNetFw35. I need this project to be a class library which targets .NET Framework 3.5. The reason for it is that some dependent applications are deployed on customers' machines which don't have .NET Framework 4+ installed. Unfortunately I can't force my customers to upgrade their environment.
Now I create new project(s) for Windows 8 and Windows Phone 8. As you know, Windows Phone 8 projects will fail when I attempt to reference my old library because it is not a compatible Windows Phone project (see screenshot).
Question
What is the best way to reorganize my project type(s) in order to be able to support both my old and new projects?
I would still aim to get a PCL working, but if that fails, you can use the same code in two different projects.
Create two different projects, one Windows Phone, the other a Windows Store App. Add a file to one, then add that other file as a link to the other project. This means you have a single source file between two different projects, but will be compiled with each respective runtime tools. Then you can do things like this in your code:
void Foo()
{
#if WinRT
//WinRT specific code here
#elif WindowsPhone
//Silverlight specific code here
#endif
}
Just add the respective compiler constants on the Build tab of your Windows Phone and WinRT projects. This is far a more tacky solution, but sometimes its the only approach that works.
I am developing a relatively simple .NET class library mainly using basic value and reference types. To save code duplication, I would like to export to 1 DLL which could be used by both Windows PCs and Windows Phone devices? Is this possible? As far as I know, all methods are compatible with the .NET and Compact .NET Framework.
Yes, as long as you stick to the Compact Framework subset, it will work. Check out this MSDN article on that same topic.
Quote:
The techniques and principles
discussed in this article can be
utilized when writing cross-device
code—applications that target Windows
devices with differing form factors
(different screen sizes, orientations,
touch screens and so on).