- Being able to create one Visual Studio solution containing a cross-mobile application with all the device-specific projects in there. In my case: iOS, Android, WP7 and a standard .NET 4 for unit testing
- Sharing lotsa' code between the projects.
- Being able to compile all of these projects in this solution, giving me a quick heads up when doing stuff in the shared lib that doesn't work in a specific device.
- Being able to test all platform specific projects directly from Visual Studio (device simulators)
For my Christmas holiday, I started testing ways to accomplish this.
First up, find something that allows me to write c# code in all of the platforms I wanted to support.
Solution: Use Xamarin MonoTouch (iOS) and MonoDroid (Android)
Being already somewhat familiar with MonoTouch and loving it, I headed out to download MonoDroid for Visual Studio. It was truly a joy to install, Next Next Finish and ...done. Sure, it took a while for it to download and install all the bits and pieces needed (Android SDK, some Java-stuff, more Java-stuff, Visual Studio integrations etc etc), but I did not had to fiddle with anything to get up and running. Sweet.
Secondly, allow MonoTouch projects to load inside VS and being able to compile that.
Say hi to VSMonoTouch, a VS addin that gives you freedom to do just that. Installation went fine, and my iOS projects could now be loaded. To get the compile-thingy going, you need to copy some dlls from your Mac to your PC (as stated in the installation notes).
Now I can haz iOS code compiled in VS? Sweet.
Thirdly, create the grand VS solution to hold all the projects.
I created a shared lib ("Core") containing code such as my models and a web service client.
I then created a specific library for all my supported platforms (e.g. "Core.iOS"), linking the code from the shared lib.
That's great and all. But what happens when I want to add a new file to the shared lib. I'll have to manually link that file in all my platform specific projects? Fear not, use the Project Linker addin. Created by Microsoft, this addin was originally meant to aid Silverlight/WPF devs but works excellent in our case. So, when doing any changes (add/remove files/dirs) in the shared lib, I now get those changes automatically in my platform specific projects. Sweet.
Lastly, I wanted to run simulators and test the code (UI things not covered by my unit tests I mean).
Using the tools now already in place, I can compile all my code from Visual Studio and test that on simulators for both Android and Windows Phone directly.
But, there's still the thing with running the iOS simulator. I know Xamarin is working on something for us Visual Studio-nerds to be able to almost skip the Mac completely and run everything from inside VS, but no official release plan yet.
Instead of waiting for such a feature, I went ahead and shared my Windows PC folder with all my code on our network (yes, only allowing myself to read/write) and tried to load that directly from my Mac (with Xamaring MonoDevelop). Turns out it works fine. So all I have to do now to test my code on the iOS simulator or a real iDevice, is just to flip over to my Mac, load the solution (yes, the same solution) and hit F5, eeeh... I mean Command + Enter.
Sweet.