---
title: "Building an iOS application using the Universal Tracker SDK in Visual Studio for Mac (Xamarin Studio)"
slug: "building-an-ios-application-using-the-universal-tracker-sdk-in-visual-studio-for-mac--xamarin-studio-"
abstract: ""
---
# Building an iOS application using the Universal Tracker SDK in Visual Studio for Mac (Xamarin Studio)

This section describes how to install the Universal Tracker SDK and create an iOS application in Visual Studio for Mac.

To build an iOS application using the Universal Tracker SDK in Visual Studio for Mac:

1. Create a project in Visual Studio for Mac. In the project creation wizard, select **iOS > App > Single View App**

    ![template selection dialog](<https://doc.sitecore.com/api/markdown-image/xp/en/developers/92/sitecore-experience-platform/images/template%20selection%20dialog.png>)

2. In the **Solution Pad**, right-click the project node.
3. In the context menu, select **Add**, and then click **Add NuGet Packages…**

    ![add nuget packages](<https://doc.sitecore.com/api/markdown-image/xp/en/developers/92/sitecore-experience-platform/images/add%20nuget%20packages.png>)

4. In the **Add Packages** dialog box, enter the *Sitecore.UniversalTracker.MobileSDK* ID in the search field. The ID is case insensitive.
5. Select *Sitecore.UniversalTracker.MobileSDK* in the search result and click **Add Package**.

    ![add packages list](<https://doc.sitecore.com/api/markdown-image/xp/en/developers/92/sitecore-experience-platform/images/add%20packages%20list.png>)

    Once the NuGet package has been added, you can see the updated project references.

    ![universaltrackerdemo packages](<https://doc.sitecore.com/api/markdown-image/xp/en/developers/92/sitecore-experience-platform/images/universaltrackerdemo%20packages.png>)

    Now you can use the Universal Tracker SDK.

6. In the editor, add the following code to the `ViewDidAppear()` function of your application:

    ```csharp
    public override async void ViewDidAppear(bool animated)
    {
      string instanceUrl = "http://my.site.com";
      string channelId = "27b4e611-a73d-4a95-b20a-811d295bdf65";
      string definitionId = "01f8ffbf-d662-4a87-beee-413307055c48";

      var defaultInteraction = UTEntitiesBuilder.Interaction()
                                               .ChannelId(channelId)
                                               .Initiator(InteractionInitiator.Contact)
                                               .Contact("jsdemo", "demo")
                                               .Build();

      using (session = SitecoreUTSessionBuilder.SessionWithHost(instanceUrl)
                                               .DefaultInteraction(defaultInteraction)
                                               .BuildSession()
            )
      {

        var eventRequest = UTRequestBuilder.EventWithDefinitionId(definitionId)
                                          .Build();

        var eventResponse = await session.TrackEventAsync(eventRequest);

        Console.WriteLine("Track EVENT RESULT: " + eventResponse.StatusCode);

            var okAlertController = UIAlertController.Create("Event response code",
                eventResponse.StatusCode,
                UIAlertControllerStyle.Alert);
             okAlertController.AddAction(UIAlertAction.Create("OK",
                UIAlertActionStyle.Default,
                alert => Console.WriteLine("Ok")))

         PresentViewController(okAlertController, true, null);

       }
    }
    ```

7. Add the following namespaces to your project to make the code compile properly:

    ```csharp
    using System;
    using System.Drawing;
    using System.Threading.Tasks;

    using MonoTouch.Foundation;
    using MonoTouch.UIKit;

    	using Sitecore.UniversalTrackerClient.Entities;
    	using Sitecore.UniversalTrackerClient.Request.RequestBuilder;
    	using Sitecore.UniversalTrackerClient.Session.SessionBuilder;
    ```

When launched, the application should display an alert with the StatusCode value.

![mobile event response code message](<https://doc.sitecore.com/api/markdown-image/xp/en/developers/92/sitecore-experience-platform/images/mobile%20event%20response%20code%20message.png>)