Last time out, I started a simple Cordova project. Having got the default project, it’s time to start making some changes. I should probably note that for some not very exciting reasons to do with where I am today and the dev machine to hand, I have used Visual Studio 2013 with Update 4 for this post.
I thought I’d start with something simple. so I added an <h1> tag and put “Starting the Cordova project” inside it. Next thing is to see if it works. That means running the project. With this being a cross platform app, there are several options. The first thing to choose is the platform you want to run the project on:
If, like me, you found that you cannot see the box on the right hand side, you can add the Solution Platforms drop down selector from the Add Or Remove Buttons menu. There are all the familiar Windows Phone Emulators as well as a selection of Android emulators – the simplest being the Ripple emulators that use Chrome to emulate Android. And remember there is a Visual Studio Android emulator that you an install and use, too.
I started with the Ripple emulator, then used the Android emulator, then used a Windows Phone emulator and the app runs on all of them. Here it is on a Windows Phone emulator:
That’s a working – albeit not especially useful or impressive – app running on multiple platforms. Next time I will look at adding some functionality.
That section has a template for creating a Cordova app:
You can do the same thing in TypeScript if you prefer. When the project is created, Visual Studio shows a helpful Getting Started page. If, like me, you need to find that page again, have a look in the project folder: the file is called Project_Readme.html.
The brand new project contains a number of folders:
I figure I don’t need to understand what they all do know, but it’s good to know they’ve been created in the right structure.
The thing I am interested in is index.html, which is the starting page of the app. Without any changes, it looks like this:
That looks like something I can understand. Next time out I’ll see if I can make some simple modifications to it.
A slightly bigger gap between the first and second posts than I had planned, so having to go back to basics a bit.
A good place to start is this article, which gives a good introduction to Cordova. I’m interested because if you’re building apps, you’re likely to be facing the challenge of writing code to run across a variety of platforms. If you have web development skills, Cordova provides a way to address that challenge.
A couple of other links that look useful are:
And if you have started to look at Cordova, why not provide some feedback?
My next step is to start a simple app.
It’s been a little while since I wrote on this blog. I’ve just started to get to know Apache Cordova, so I figure it’s in order to blow away the virtual dust and post occasional blog entries to document progress and keep notes.
But first a quick side note: once I get some more momentum I will need a better name for this series of posts. I have already rejected Cutting the Cordova and They Think It’s Cordova. Suggestions welcome.
One more thing that’s worth noting is the tooling that is available for Visual Studio 2013 for writing Apache Cordova apps. It’s also part of Visual Studio 2015 – preview available here. When you install the tooling, there’s a bunch of other stuff you can install, like the Android SDK and Java SDK, so you can build, debug and deploy cross platform (more info on that here.)
Once you have the tools installed and you’re ready to go, here are a few good resources to ready you for the first steps:
Looking at how to call F# from C#, I thought I should share this link. I have 2 projects in one solution (one in F# and one in C#.) The C# project (a console application) references the F# project (a library) and that works. Doesn’t do anything useful yet, but one step at a time…
After my simple start to an anagram solver in C#, I have a simple equivalent in F#:
let generateKey (chars : char) = new string(chars)
let lookup = words |> Seq.groupBy(fun x -> generateKey(x.ToCharArray() |> Array.sort))
The lookup function expects a list of strings. It works – although I’ve only tried it with fairly short lists of words. Next exercise is to try calling this (or something like it) from C#.
I’ve been spending a little time recently writing a simple Windows Phone 7 app and I’ve been impressed with how easy it has been. I’ve been thinking of writing an anagram solver as an exercise in F# – and it might make for another simple phone app – so I thought I’d start with a few simple steps.
The first step is to try (part of) a potential solution – given a list of words, group the words by the constituent letters (so that, for instance, horse and shore would be grouped together.) That way, I won’t have to try every single combination of letters and compare against a list of words. My intention this week was to write a simple program in C# to do this. Here’s the method that does the work:
private Dictionary<string, List<string>> ProcessWordList(string words)
Dictionary<string, List<string>> result = new Dictionary<string, List<string>>();
foreach (string word in words)
IOrderedEnumerable<char> ordered = from char a in word.ToCharArray()
string orderedString = new string(ordered.ToArray());
List<string> list = new List<string>();
Next exercise is either to extend the program towards solving anagrams or to write the method above in F#.