/Xamarin.SwiftUI

.NET bindings for SwiftUI

Primary LanguageC#MIT LicenseMIT

Xamarin.SwiftUI

A managed binding to SwiftUI.

Build Status

.github/workflows/build.yml

Project Status:

Active.

Xamarin.SwiftUI provides a managed binding to Apple's next-generation SwiftUI toolkit. Using your favourite .NET language, you should be able to create SwiftUI apps. However, only a handful of APIs are currently bound. Work is ongoing on a binding generator to automatically cover the entire API surface.

Example

A simple custom view with state:

using SwiftUI;
using static SwiftUI.Views;

public partial record ClickView : View
{
	readonly State<int> clicks = new State<int> (0);
	public View Body
		=> Button ($"Clicked {clicks.Value} times", () => clicks.Value++);
}

Building from Source

Prerequisites

  • .NET 6 SDK
  • Xcode 13 or newer

Building

dotnet msbuild /restore build.proj

If you need to make changes to the SwiftUIGlue native glue library during development, you can rebuild just those bits by running:

dotnet msbuild build.proj /t:SwiftUIGlue

Packaging

The major and minor version of nuget packages created by the CI pipeline is controlled by the VERSION file. This does not need to be bumped for patch releases.

For local development, the version of the package produced can be overridden:

dotnet msbuild /restore build.proj /t:Pack /p:Version=X.X.XXX

For more information about the internals and guidance on developing the binding itself, see the document titled Hacking.