Xamarin.IOS Introduction

From WikiOD

Remarks[edit | edit source]

Xamarin.iOS allows you to create native iOS applications using the same UI controls you would in Objective-C and Xcode, but with the flexibility and elegance of a modern language (C#), the power of the .NET Base Class Library (BCL), and two first-class IDEs - Xamarin Studio and Visual Studio - at your fingertips.

For more information on installing Xamarin.iOS on your Mac or Windows machine, refer to the Getting Started guides on the Xamarin developer center

Versions[edit | edit source]

Version Release Date
1.0 2009-09-14
2.0 2010-04-05
3.0 2010-04-16
4.0 2011-04-06
5.0 2011-10-12
6.0 2012-09-19
7.0 2013-09-18
8.0 2014-09-10
9.0 2015-09-17
9.2 2015-11-17
9.4 2015-12-09
9.6 2016-03-22

Detailed info for each release can be found here: https://developer.xamarin.com/releases/ios/

Get Started in Visual Studio[edit | edit source]

  1. Browse to File > New > Project to bring you up the New Project dialog.
  2. Navigate to Visual C# > iOS > iPhone and select Single View App: Getting_started_with_Xamarin.iOS
  3. Give your app a Name and press OK to create your project.
  4. Select the Mac Agent icon from the toolbar, as illustrated below: Getting_started_with_Xamarin.iOS
  5. Select the Mac that will build your application from the list (make sure you Mac is set up to receive the connection!), and press Connect: Getting_started_with_Xamarin.iOS
  6. To run your application, select the Debug | iPhoneSimulator configuration, and press the Play button:Getting_started_with_Xamarin.iOS
  7. This will launch the iOS Simulator on the Mac, and will display your empty application: Getting_started_with_Xamarin.iOS

Get Started in Xamarin Studio[edit | edit source]

  1. Browse to File > New > Solution to bring you up the new project dialog
  2. Select Single View App and press Next
  3. Configure your app by setting your app name and organization ID, and press Next: Getting_started_with_Xamarin.iOS
  • Set your Project name and Solution name, or leave as the default name. Click Create to create your project.
  • To run your application, select the Debug | iPhone 6s iOS 9.x configuration, and press the Play button: Getting_started_with_Xamarin.iOS
  • This will launch the iOS Simulator, and will display your empty application: Getting_started_with_Xamarin.iOS

Hello, World[edit | edit source]

  1. Double click on the Main.Storyboard file.
  2. Set View As to iPhone 6:Getting_started_with_Xamarin.iOS
  3. Drag a label and a button from the Toolbox to the design surface so that it looks like the image below:Getting_started_with_Xamarin.iOS
  4. In the Properties pad, give the label and button the following properties:
nothing Name Title
Label lblClicks [blank]
Button clickMe Click Me!
  • Add the following code to the ViewDidLoad method inside the ViewController class:
clickMe.TouchUpInside += (sender, e) =>
{
    totalClicks++;
    if (totalClicks == 1)
    {
        lblClicks.Text = totalClicks + " Click";
    }

   else {
       lblClicks.Text = totalClicks + " Clicks";
   }
};
  • Run the application

Credit:Stack_Overflow_Documentation