On a whim, I decided to create a new Universal App. If you haven’t been following the news, Microsoft announced Universal Apps at the Build 2014 conference. The term is used to refer to an application that is created and that will share code for multiple platforms such as Windows 8.1, Windows Phone 8.1, Android and iOS, amongst others.
In order to get access to the latest project templates, I installed Visual Studio 2013 Update 2 Release Candidate which can be found here.
Once that was done, here are the steps I followed:
In Visual Studio 2013, I created a new project and selected the Blank App (Universal Apps) option. I could have picked the Hub App but I wanted to create my own application from scratch.
I called my application the CalendarEventCreator.
This created a solution that contained 3 projects: one for Windows 8.1, one for Windows Phone 8.1, and a Shared component where shared XAML and code would reside.
This is good but the shared component is a way of linking files into both projects above. This means that the shared files are built directly into every one of the executables within the same solution. I prefer to have the bulk of my shared code reside in a class library so that it can be unit tested and built only once but referenced by various executables. This means if the shared code changes, I am not forced to rebuild and ship every executable. Here’s an excellent blog post that helps make sense out of both types of shared components: Sharing Code Across Platforms. For my project, I chose to create both a Portable Class Library called CalendarEventCreatorShared and a matching test project. My solution now looks like:
As the test project will be testing the portable shared library, I went to add a reference to the library from the test project. This, however, failed with the following message:
To solve this, I had to do two things:
- Go into the portable class library’s properties by right-clicking the project in the Solution Explorer and add “.NET Framework 4.5.1” as a target.
- Go into the unit test project’s properties by right-clicking the project in the Solution Explorer, change the framework to version 4.5.1 and accept the warning.
After having accomplished this, I was able to add a reference to the portable class library into my test project and started doing some real coding…which unfortunately will be a story for another time.
Hope this helps you get started with Universal Apps!