iOS Development in C# with Xamarin Studio and Visual Studio

image of letters coming from phone screen

Daniel Grizelj/Getty Images

In the past, you may have considered Objective-C and iPhone development but the combination of a new architecture and a new programming language together may have been too much. Now with Xamarin Studio, and programming it in C#, you may find the architecture not that bad. You may end up coming back to Objective-C though Xamarin makes feasible any type of iOs programming including games.

This is the first of a set of tutorials on programming iOS Apps (ie both iPhone and iPad) and eventually Android Apps in C# using Xamarin Studio. So what is Xamarin Studio?

Previously known as MonoTouch Ios and MonoDroid (for Android), the Mac software is Xamarin Studio. This is an IDE that runs on Mac OS X and it's pretty good. If you've used MonoDevelop, then you'll be on familiar ground. It's not quite as good as Visual Studio in my opinion but that's a matter of taste and cost. Xamarin Studio is great for developing iOS Apps in C# and likely Android, though that depends on your experiences creating those.

Xamarin Versions

Xamarin Studio comes in four versions: There's the free one that can create Apps for the App store but those are limited to 32Kb in size which is not a lot! The other three cost starting with the Indie version for $299. On that, you develop on the Mac and can produce Apps of any size.

Next is the Business version at $999 and that's the one used for these examples. As well as Xamarin Studio on the Mac it integrates with Visual Studio so you can develop iOS/Android apps as if writing .NET C#. The clever trick is that it uses your Mac to build and debug the App using the iPhone/iPad simulator while you step through code in Visual Studio.

The big version is the Enterprise edition but that won't be covered here.

In all four cases you need to own a Mac and to deploy Apps in the App store needs you to pay Apple $99 each year. You can manage to offset paying that until you need it, just develop against the iPhone simulator that comes with Xcode. You have to install Xcode but it's in the Mac Store and it's free.

The Business edition does not have a big difference, just that it is on Windows instead of the Mac with free and Indie editions, and it uses the full power of Visual Studio (and Resharper). Part of that comes down to whether you prefer to develop Nibbed or Nibless?

Nibbed or Nibless

Xamarin integrates into Visual Studio as a plugin that gives new menu options. But it doesn't yet come with a designer like the Xcode's Interface Builder. If you are creating all your views ( the iOS word for controls) at runtime then you can run nibless. A nib (extension .xib) is an XML file that defines the controls etc in views and links events together so when you click on a control, it invokes a method.

Xamarin Studio also requires you to use Interface Builder to create nibs but at the time of writing, they have a Visual designer running on the Mac in alpha state. It will likely become available on the PC as well.

Xamarin Covers the Whole iOS API

The whole iOS API is pretty massive. Apple currently has 1705 documents in the iOS developer library covering all aspects of iOS development. Since they were last reviewed, the quality has improved a lot.

Likewise, the iOS API from Xamarin is pretty comprehensive, though you will find yourself referring back to the Apple docs.​

Getting Started

After installing Xamarin software on your Mac, create a new Solution. The project choices include iPad, iPhone, and Universal and also with Storyboards. For iPhone, you then have the choice of an Empty Project, Utility Application, Master-Detail Application, Single View application, Tabbed Application or OpenGl Application. You have similar choices for Mac and Android development.

Given the lack of designer on Visual Studio, you can take the nibless (Empty Project) route. It's not that difficult but nowhere as easy to get the design looking spot on. In this case, as you are mainly dealing with square buttons, it's not a worry.

Architecting iOS Forms

You are entering into a world described by Views and ViewControllers and these are most important concepts to understand. A ViewController (of which there are several types) controls how data is displayed and manages view and resource management tasks. The actual displaying is done by a View (well a UIView descendant).

The User Interface is defined by ViewControllers working together. We'll see that in action in tutorial two with a simple nibless App like this one.

In the next tutorial, we'll look in depths at ViewControllers and develop the first complete App.

mla apa chicago
Your Citation
Bolton, David. "iOS Development in C# with Xamarin Studio and Visual Studio." ThoughtCo, Feb. 16, 2021, Bolton, David. (2021, February 16). iOS Development in C# with Xamarin Studio and Visual Studio. Retrieved from Bolton, David. "iOS Development in C# with Xamarin Studio and Visual Studio." ThoughtCo. (accessed June 9, 2023).