Convert Figma logo to code with AI

dotnet logomacios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#

2,644
536
2,644
692

Top Related Projects

A framework for building native applications using React

169,302

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.

⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.

22,629

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.

Quick Overview

Xamarin.iOS and Xamarin.Mac are open-source projects that allow developers to create native iOS, tvOS, watchOS, and macOS applications using C# and .NET. This repository contains the source code for these projects, enabling developers to build cross-platform mobile and desktop applications with a shared codebase.

Pros

  • Cross-platform development using C# and .NET
  • Access to native iOS and macOS APIs
  • Shared codebase for multiple platforms
  • Integration with Visual Studio for a seamless development experience

Cons

  • Learning curve for developers new to iOS/macOS development
  • Potential performance overhead compared to native Swift/Objective-C apps
  • Dependency on Xamarin/Microsoft for updates and support
  • Limited community compared to native iOS/macOS development

Code Examples

  1. Creating a simple iOS button:
var button = new UIButton(UIButtonType.System);
button.SetTitle("Click me", UIControlState.Normal);
button.Frame = new CGRect(20, 200, 280, 44);
button.TouchUpInside += (sender, e) => {
    Console.WriteLine("Button clicked!");
};
View.AddSubview(button);
  1. Implementing a table view in iOS:
public class MyTableSource : UITableViewSource
{
    string[] tableItems;
    string cellIdentifier = "TableCell";

    public MyTableSource(string[] items)
    {
        tableItems = items;
    }

    public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
    {
        UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier);
        if (cell == null)
            cell = new UITableViewCell(UITableViewCellStyle.Default, cellIdentifier);

        cell.TextLabel.Text = tableItems[indexPath.Row];

        return cell;
    }

    public override nint RowsInSection(UITableView tableview, nint section)
    {
        return tableItems.Length;
    }
}
  1. Creating a simple macOS window:
public partial class MainWindowController : NSWindowController
{
    public MainWindowController(IntPtr handle) : base(handle)
    {
    }

    public override void WindowDidLoad()
    {
        base.WindowDidLoad();

        var label = new NSTextField(new CGRect(20, 20, 200, 30))
        {
            StringValue = "Hello, Xamarin.Mac!",
            Editable = false,
            Bezeled = false,
            DrawsBackground = false
        };

        ContentView.AddSubview(label);
    }
}

Getting Started

  1. Install Visual Studio with Xamarin support
  2. Create a new Xamarin.iOS or Xamarin.Mac project
  3. Add the following code to your AppDelegate.cs file:
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    Window = new UIWindow(UIScreen.MainScreen.Bounds);
    Window.RootViewController = new UIViewController();
    Window.MakeKeyAndVisible();

    var label = new UILabel(new CGRect(20, 200, 280, 44))
    {
        Text = "Welcome to Xamarin.iOS!",
        TextAlignment = UITextAlignment.Center
    };
    Window.RootViewController.View.AddSubview(label);

    return true;
}
  1. Build and run the project on a simulator or device

Competitor Comparisons

A framework for building native applications using React

Pros of React Native

  • Larger community and ecosystem, with more third-party libraries and resources
  • Faster development cycle with hot reloading
  • Single codebase for both iOS and Android platforms

Cons of React Native

  • Performance can be slower for complex, graphics-intensive applications
  • Less direct access to native APIs and features
  • Steeper learning curve for developers without JavaScript experience

Code Comparison

React Native:

import React from 'react';
import { View, Text } from 'react-native';

const App = () => (
  <View>
    <Text>Hello, World!</Text>
  </View>
);

Xamarin.iOS:

using UIKit;

public class ViewController : UIViewController
{
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        View.AddSubview(new UILabel(new CGRect(20, 200, 300, 40)) { Text = "Hello, World!" });
    }
}

Both frameworks allow for cross-platform mobile development, but React Native uses JavaScript and a more declarative approach, while Xamarin.iOS uses C# and follows a more traditional object-oriented programming style. React Native's code is typically more concise, but Xamarin.iOS provides closer integration with native APIs and potentially better performance for complex applications.

169,302

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Pros of Flutter

  • Single codebase for multiple platforms (iOS, Android, web, desktop)
  • Hot reload feature for faster development
  • Rich set of customizable widgets for UI development

Cons of Flutter

  • Larger app size compared to native apps
  • Limited access to platform-specific features
  • Steeper learning curve for developers new to Dart language

Code Comparison

Flutter (Dart):

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Flutter App')),
        body: Center(child: Text('Hello, World!')),
      ),
    );
  }
}

Xamarin.iOS (C#):

using UIKit;

namespace MyApp
{
    public class AppDelegate : UIApplicationDelegate
    {
        public override UIWindow Window { get; set; }

        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            Window = new UIWindow(UIScreen.MainScreen.Bounds);
            Window.RootViewController = new UIViewController();
            Window.MakeKeyAndVisible();

            return true;
        }
    }
}

The Flutter code demonstrates a simple app structure with a material design, while the Xamarin.iOS code shows the basic setup for an iOS application. Flutter's code is more concise and focuses on UI components, whereas Xamarin.iOS requires more boilerplate code for app initialization.

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.

Pros of Ionic Framework

  • Cross-platform development for web, iOS, and Android using web technologies (HTML, CSS, JavaScript)
  • Large ecosystem with pre-built UI components and plugins
  • Easier learning curve for web developers

Cons of Ionic Framework

  • Performance may be slower compared to native apps
  • Limited access to native device features without additional plugins
  • Dependency on Cordova for native functionality

Code Comparison

Xamarin.iOS (C#):

public override void ViewDidLoad()
{
    base.ViewDidLoad();
    var label = new UILabel(new CGRect(20, 20, 300, 40));
    label.Text = "Hello, Xamarin.iOS!";
    View.AddSubview(label);
}

Ionic Framework (TypeScript):

import { Component } from '@angular/core';

@Component({
  selector: 'app-home',
  template: '<ion-label>Hello, Ionic!</ion-label>'
})
export class HomePage {}

Summary

Xamarin.iOS offers native performance and full access to iOS APIs but requires C# knowledge. Ionic Framework provides cross-platform development using web technologies, making it more accessible to web developers but potentially sacrificing some performance and native functionality. The choice between the two depends on project requirements, team expertise, and performance needs.

⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.

Pros of NativeScript

  • Uses JavaScript or TypeScript, allowing web developers to easily transition to mobile development
  • Provides direct access to native APIs without requiring plugins or bridges
  • Supports Angular, Vue.js, and plain JavaScript for app development

Cons of NativeScript

  • Smaller community and ecosystem compared to Xamarin
  • Performance can be slower than native or Xamarin apps in some scenarios
  • Limited IDE support compared to Xamarin's Visual Studio integration

Code Comparison

NativeScript (JavaScript):

import { Label } from "@nativescript/core";

export function createLabel() {
    const label = new Label();
    label.text = "Hello, NativeScript!";
    return label;
}

xamarin-macios (C#):

using UIKit;

public class MyViewController : UIViewController
{
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        var label = new UILabel(View.Frame);
        label.Text = "Hello, Xamarin!";
        View.AddSubview(label);
    }
}

Both examples create a simple label with text, but NativeScript uses JavaScript and a more platform-agnostic approach, while xamarin-macios uses C# and iOS-specific classes.

22,629

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.

Pros of MAUI

  • Unified framework for cross-platform development (iOS, Android, macOS, Windows)
  • Better integration with .NET ecosystem and modern C# features
  • Improved performance and smaller app sizes

Cons of MAUI

  • Newer framework with potential stability issues and fewer resources
  • Limited support for older .NET versions and legacy Xamarin projects
  • Steeper learning curve for developers transitioning from Xamarin.Forms

Code Comparison

xamarin-macios:

[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
    public override UIWindow Window { get; set; }
    public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    {
        // iOS-specific initialization code
    }
}

MAUI:

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder.UseMauiApp<App>();
        return builder.Build();
    }
}

The xamarin-macios code shows iOS-specific initialization, while MAUI demonstrates a more unified approach for cross-platform app creation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

.NET for iOS, Mac Catalyst, macOS, tvOS

Welcome!

This module is the main repository for:

  • .NET for iOS
  • .NET for Mac Catalyst
  • .NET for macOS
  • .NET for tvOS

These SDKs allow us to create native iOS, Mac Catalyst, macOS and tvOS applications using the same UI controls we would in Objective-C and Xcode, except with the flexibility and elegance of a modern language (C#), the power of the .NET Base Class Library (BCL), and first-class IDEs and editors—Visual Studio and Visual Studio Code—at our fingertips.

This repository is where we do development for the .NET for iOS, Mac Catalyst, macOS, and tvOS SDKs. .NET for iOS, Mac Catalyst, macOS, and tvOS are part of .NET MAUI, and may also be used independently for native iOS and macOS development with .NET.

There are a few ways that you can contribute, for example:

Support

.NET for iOS, Mac Catalyst, macOS, and tvOS are part of .NET MAUI, since it was introduced in May 2022 as part of .NET 6, and is currently supported as described on the .NET MAUI Support Policy.

Support for Xamarin.iOS and Xamarin.Mac ended on May 1, 2024 as per the Xamarin Support Policy:

Xamarin support ended on May 1, 2024 for all Xamarin SDKs including Xamarin.Forms. Android API 34 and Xcode 15 SDKs (iOS and iPadOS 17, macOS 14) are the final versions Xamarin targets from existing Xamarin SDKs (i.e. no new APIs are planned).

Contributing

If you are interested in fixing issues and contributing directly to the code base, please see the document How to Contribute, which covers the following:

Downloads

The preferred method for installing Xamarin.iOS and Mac is to use the Visual Studio installers (Windows, Mac).

The team also strongly recommends using the latest Xamarin SDK and Xcode whenever possible.

However, we provide links to older Xamarin.iOS and Mac packages for macOS downgrades and build machine configuration, see Downloads.

Feedback

Discord

License

Copyright (c) .NET Foundation Contributors. All rights reserved. Licensed under the MIT License.