Xamarin & MvvmCross Handbook
  • Introduction
  • Using MvvmCross to create your first Xamarin App
    • Creating the Core project
      • Understanding MVVM
      • Adding a simple Service
      • Adding a ViewModel
      • Adding an App class
    • Creating the Android project
      • Adding an Android Application class
      • Adding the Android Layout View (AXML)
      • Understanding the data-binding syntax
      • Adding the View class
    • Creating the iOS project
      • Updating the AppDelegate class
      • Adding the iOS View for the first ViewModel
      • Understanding the data-binding syntax
    • Creating the UWP project
      • Updating the App.xaml.cs and the App.xaml
      • Adding the UWP View
      • Understanding the data-binding syntax
    • Creating the REST API Service
      • Creating the models
      • Creating the interface and the implementation for the PostService
      • Creating the ViewModel
      • Adding the View for the Android project
      • Adding the View for the iOS project
      • Adding the View for the UWP project
    • Navigation
      • Creating the PostDetail View & ViewModel
      • Command with the parameter
      • Retrieving the param from the previous ViewModel
      • Understanding the IMvxNavigationService
      • Responding the events from different controls in the ListView
      • Retrieving the return result from the previous ViewModel
    • Creating the Xamarin.Forms project
      • Creating the Forms.UI project
      • Adding the App.xaml and the App.xaml.cs
      • Adding the View
      • Creating the Android project
      • Creating the iOS project
      • Creating the UWP project
      • Summary For Forms
    • Summary
  • Implementing MasterDetail layout in Xamarin.Forms by MvvmCross
    • Introduction
    • Creating the project by MvxScaffolding
    • Creating the MasterDetailPage
      • Creating the ViewModel
      • Creating the XAML file
    • Creating the MasterPage
      • Creating the ViewModel
      • Creating the XAML file
    • Creating the DetailPages
      • Creating the ViewModels
      • Creating the XAML files
    • Implementing the Menu functionalities
      • Displaying the MasterPage and the DetailPage
      • Setting the menu navigation
      • The other approaches to set the data-binding
    • Fine-tuning the UI
      • Adding the hamburger icon for iOS
      • Adding the header bar for Android and iOS
      • Adjust the height of the item for UWP
    • Summary
Powered by GitBook
On this page

Was this helpful?

  1. Using MvvmCross to create your first Xamarin App
  2. Creating the Xamarin.Forms project

Creating the iOS project

PreviousCreating the Android projectNextCreating the UWP project

Last updated 6 years ago

Was this helpful?

Add an iOS App (Xamarin) project called MvvmCrossDemo.Forms.iOS into the solution, like this:

Note that do not use iOS XAML App (Xamarin.Forms) template. Use the Blank App template and select it for iPhone:

Then install the Xamarin.Forms package to the project through the NuGet Package Manager:

Or install it by the command below in the NuGet Manager Console:

Install-Package Xamarin.Forms

Install the MvvmCross.Forms package in the NuGet Package Manager:

Or you can install it by the command below in the NuGet Manager Console:

Install-Package MvvmCross.Forms

Because we use Newtonsoft.Json and AutoMapper in the MvvmCrossDemo.Core project, so do not forget to install them from the NuGet Package Manager or your NuGet Manager Console.

Like the Android project, add the reference to the MvvmCrossDemo.Core project and the MvvmCrossDemo.Forms.UI project. Update the default namespace of the MvvmCrossDemo.Forms.iOS project to MvvmCrossDemo.Forms.iOS instead of Blank, like this:

Open the AppDelegate.cs file and update the class to inherit from MvxFormsApplicationDelegate<MvxFormsIosSetup<Core.App, UI.App>, Core.App, UI.App> instead of UIApplicationDelegate. Then delete all the pre-populated methods in the AppDelegate class, as shown below:

using Foundation;
using MvvmCross.Forms.Platforms.Ios.Core;

namespace MvvmCrossDemo.Forms.iOS
{
    // The UIApplicationDelegate for the application. This class is responsible for launching the
    // User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
    [Register("AppDelegate")]
    public class AppDelegate : MvxFormsApplicationDelegate<MvxFormsIosSetup<Core.App, UI.App>, Core.App, UI.App>
    {

    }
}

That is it! All the Views of the iOS project are handled by the MvvmCrossDemo.Forms.UI project so we can reuse a lot of codes between these projects.

You can find the sample code of it here: .

https://github.com/MvvmCross/MvvmCross/blob/develop/ContentFiles/Forms/iOSContent/AppDelegate.cs.pp