Xamarin Mobile Application Development for iOS

4 (1 reviews total)
By Paul F. Johnson
  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Installing the Xamarin Product Range for Android and iOS

About this book

Before the release of monotouch, development on iOS was purely in Objective C. There was nothing wrong with that except for one thing – it’s very unpleasant to write code in! The release of Xamarin changed all of that, and with it brought cross-platform development to the mobile world.

Xamarin Mobile Application Development for iOS is not just your normal everyday book on iOS app development. Everything is written for a point and not for effect, and therefore you will learn everything you need to know quickly and efficiently without getting bogged down in needless information. The code has been taken from fully tested apps, so you can just drop it into your code and it will work out of the box.

In this clear and informative guide, you will be taken on a whirlwind tour of iOS application development with Xamarin, from setting up a development environment on your PC or Mac to testing and distribution through the Apple Store with plenty of practical examples along the way.

The book begins by discussing the installation of the IDE (for both PC and Mac) as well as how to set up your PC so it can be used to develop for iOS. From there, successive chapters cover the user interface, views, view controllers, customisation of controls, animation, events and event handling, getting the most from your app using threading, creating your own settings system, the internal database system and LINQ, sending texts, making calls, taking photos, videos, and audio recordings as well as using the mapping system. The book culminates by showing you how to test your app using testflight and finally how to release your app on the Apple Store. It is an all-encompassing book that leaves nothing out.

Publication date:
October 2013


Chapter 1. Installing the Xamarin Product Range for Android and iOS

The Xamarin product range covers iOS, OS X, and Android development. This enables the .NET Framework development on devices that do not natively support it via the respected and mature Mono framework.

In this chapter we will cover the following topics:

  • Installing Xamarin.iOS, Xamarin.Android, and Xamarin Studio

  • Setting up a Windows machine to develop apps for iOS


Installing Xamarin.iOS and Xamarin.Android

Installing Xamarin for Windows and OS X is a very similar and simple process. Before you download, you will need to ensure that your computer has the following requirements as the minimum specifications:



  • Windows 7 or Windows 8

  • Visual Studio 2010 or 2012

  • OS X Lion or Mountain Lion

  • Xcode v4.6 or above

For both, the general rule is the more memory you have the better. You also need to have a live network connection.

Downloading the software

The website is able to check the operating system you are using and, when you select download, the correct version for your operating system will be downloaded.

You will need to give Xamarin some basic information before you are allowed to download the evaluation copy. The evaluation will allow you to develop and deploy apps for 30 days, after which you will need to purchase a copy. If you have placed any apps on the Apple store or Google Play, they will no longer function.

On a PC, double-click on the XamarinInstaller.exe file (Windows 8 users should run this file as an administrator). For Mac users, double-click on the installer.

Installing the software

Depending on your network connection, this can take anywhere up to an hour as each package is downloaded in turns and then installed. The installation process is automatic, and anything required for the software to work is installed with the exception of Xcode—it is simple to check whether you have this installed on your Mac: click on the Applications directory and look near the bottom for the icon. If it's not there, go to the App Store and type in Xcode. The download is free. Unless you have a reason to change the defaults, accept the default setup options by clicking on Next each time an option is presented.


Enabling Visual Studio to build and run iOS applications

For Windows to create, build, and deploy iOS applications, it must be connected to a Mac somewhere on a network. The Mac must also have Xamarin.iOS installed. This is a two-part process.

On the Mac

  1. Click on the Apple icon and select System Preferences.

  2. Then you need to select the Security & Privacy preference option.

  3. Then the firewall will need to be switched off. While this is not normally a good idea, a majority of internal networks have a sufficiently good firewall at any router. If you are not happy with this, leave the setting—you just won't be able to run or develop for iOS under Windows.

On the PC

When Xamarin.iOS for Visual Studio is installed, it also installs a small listener service called Bonjour. When you try to create an iOS application, Bonjour will attempt to automatically find a Mac on your network. This may fail, and if it does you will see the following screenshot:

You don't need to worry about the error. Click on Dismiss. You will be presented with a window that allows you to enter the IP address of your Mac.

In this example, the IP address from the Mac on my network has the address shown in the preceding screenshot. When you click on OK, Bonjour will attempt to attach to Mac. If it is successful, you will be presented with the following screenshot:

As soon as you see the window shown in the preceding screenshot on your screen, you are nearly there. The next step is to click on the host machine (highlighted in the preceding screenshot) and click on Connect. Once done, you're set up on the PC to develop for iOS under Windows.

All of the tools for development (like the Simulator—a simulated iOS device) can be either on one of the iPhone or iPad ranges).

If the Bonjour service was unable to automatically determine the Mac, you may need to manually set up the service. This can be performed very easily.

Assuming you're on Windows 7, the following steps will help you set up the Bonjour service:

  1. Click on the Start button and select Control Panel.

  2. On the Control Panel, click on Administrative Tools and from there select Services. You will be presented with a window, as shown in the following screenshot:

  3. Ensure that the status is Started and the startup type is Automatic. (This will start the Bonjour service when Windows is restarted.)


    When using a PC to develop iOS applications, ensure that both the PC and Mac are running the same version of Xamarin.iOS—if they are out of step, you will need to install a newer version of Xamarin.iOS on the device that is out of step.


Installing additional code for Android development

This is different under iOS and PC but the end effect is the same.

When Xamarin.Android is installed on either platform, the compiler and the minimal set of the Android Software Developers Kit (SDK) is installed. This will let you get going with the development but not allow you to target a range of devices. It is, therefore, important to install the SDK for other versions of the Android operating system. This is preformed using the Android SDK Manager.

To access SDK Manager on a PC, select Start and on the All Programs menu there is a menu option called Android SDK Tools under which is the Android SDK Manager. Select the SDK Manager and you will be presented with a new window that allows you to select the SDK you want.

For iOS users

A part of the installation process on a Mac installs the Xamarin IDE (Integrated Development Environment)—Xamarin Studio. This is similar in many ways to Visual Studio and performs a very similar job.

To access the SDK Manager on Xamarin Studio, select Tools followed by Open Android SDK Manager.

In both cases, you will be presented with the following screenshot from the SDK Manager. It is simplest to select all the SDKs and click on the Install packages... button to start the process. Depending on your network connection speed, this process may take a while.



That's it—you're set up on both a Mac and PC to create amazing applications for Android and iOS. Your development environments are set up. For the rest of this book, though, I will concentrate solely on the development of iOS applications and leave Android to the companion book.

About the Author

  • Paul F. Johnson

    Many years ago, from the fountains of Mount Olympus came forth upon the planet a man, a mystery, and an enigma. Over many years, he grew; he developed amazing biceps, an intellect to rival the greatest minds in the universe, a personality larger than a fair-sized moon, and a smile that would melt the hearts of the iciest of witches. He fought in wars, raged battles against injustice, and was generally an all-round amazing type of guy.

    This is not his story.

    You see, while he could do all of this really cool stuff, he couldn't work his mobile, and worse, he was clueless about how to make his own apps. Then stepped forth a nice chap from Liverpool, and with a bit of patience, he showed him how to do it.

    This is his story.

    What made this Scouser worthy of helping the man from Olympus? The simple answer is experience. You see, he was there at the outset of the home computer boom of the early 1980s. He developed code in BASIC, Z80, the 6502 and ARM assembler, C, C++, C#, Pascal, and FORTRAN. He has won awards for programming and is a published author with Packt Publishing.

    Add these together and you can see why he was a worthy teacher. That, and he makes a killer cup of coffee!

    Paul (for that is his name) is 44, lives with his wife, dog, cats, and son and drinks way too much coffee! You can normally find Paul on the Facebook Xamarin Developers group, where he is an admin. He is currently in the planning stage for a follow up of this book, but this time, he is concentrating on using XAML instead of pure C# to develop Xamarin.Forms applications. This will combine his lifetime love of Dr. Who with his other love that is to create fun code.

    He is currently in the middle of buying enough coffee to fuel him through it - Brazil is on high alert!

    Browse publications by this author

Latest Reviews

(1 reviews total)
Could be better, I feel that there are allot of issues that are not being covered.
Book Title
Access this book, plus 7,500 other titles for FREE
Access now