Skip to content
Docs Try Aspire

MauiiOSExtensions Methods

Class Methods 6 members
Provides extension methods for adding iOS platform resources to MAUI projects.
AddiOSDevice(IResourceBuilder<MauiProjectResource>) Section titled AddiOSDevice(IResourceBuilder<MauiProjectResource>) extension IResourceBuilder<MauiiOSDeviceResource>
Adds an iOS physical device resource to run the MAUI application on an iOS device.
public static class MauiiOSExtensions
{
public static IResourceBuilder<MauiiOSDeviceResource> AddiOSDevice(
this IResourceBuilder<MauiProjectResource> builder)
{
// ...
}
}
builder IResourceBuilder<MauiProjectResource> The MAUI project resource builder.
IResourceBuilder<MauiiOSDeviceResource> A reference to the ApplicationModel.IResourceBuilder`1.
This method creates a new iOS device platform resource that will run the MAUI application targeting the iOS platform using dotnet run. The resource does not auto-start and must be explicitly started from the dashboard by clicking the start button.

The resource name will default to "{projectName}-ios-device".

This will run the application on a physical iOS device connected via USB. The device must be provisioned before deployment. For more information, see https://learn.microsoft.com/dotnet/maui/ios/device-provisioning

If only one device is attached, it will automatically use that device. If multiple devices are connected, use the overload with deviceId parameter to specify which device to use by UDID. You can find the device UDID in Xcode under Window > Devices and Simulators > Devices tab.

Add an iOS device to a MAUI project:

var builder = DistributedApplication.CreateBuilder(args);
var maui = builder.AddMauiProject("mauiapp", "../MyMauiApp/MyMauiApp.csproj");
var iOSDevice = maui.AddiOSDevice();
builder.Build().Run();
AddiOSDevice(IResourceBuilder<MauiProjectResource>, string) Section titled AddiOSDevice(IResourceBuilder<MauiProjectResource>, string) extension IResourceBuilder<MauiiOSDeviceResource>
Adds an iOS physical device resource to run the MAUI application on an iOS device with a specific name.
public static class MauiiOSExtensions
{
public static IResourceBuilder<MauiiOSDeviceResource> AddiOSDevice(
this IResourceBuilder<MauiProjectResource> builder,
string name)
{
// ...
}
}
builder IResourceBuilder<MauiProjectResource> The MAUI project resource builder.
name string The name of the iOS device resource.
IResourceBuilder<MauiiOSDeviceResource> A reference to the ApplicationModel.IResourceBuilder`1.
This method creates a new iOS device platform resource that will run the MAUI application targeting the iOS platform using dotnet run. The resource does not auto-start and must be explicitly started from the dashboard by clicking the start button.

Multiple iOS device resources can be added to the same MAUI project if needed, each with a unique name.

This will run the application on a physical iOS device connected via USB. The device must be provisioned before deployment. For more information, see https://learn.microsoft.com/dotnet/maui/ios/device-provisioning

If only one device is attached, it will automatically use that device. If multiple devices are connected, use the overload with deviceId parameter to specify which device to use by UDID. You can find the device UDID in Xcode under Window > Devices and Simulators > Devices tab.

Add multiple iOS devices to a MAUI project:

var builder = DistributedApplication.CreateBuilder(args);
var maui = builder.AddMauiProject("mauiapp", "../MyMauiApp/MyMauiApp.csproj");
var device1 = maui.AddiOSDevice("ios-device-1");
var device2 = maui.AddiOSDevice("ios-device-2");
builder.Build().Run();
AddiOSDevice(IResourceBuilder<MauiProjectResource>, string, string?) Section titled AddiOSDevice(IResourceBuilder<MauiProjectResource>, string, string?) extension IResourceBuilder<MauiiOSDeviceResource>
Adds an iOS physical device resource to run the MAUI application on an iOS device with a specific name and device UDID.
public static class MauiiOSExtensions
{
public static IResourceBuilder<MauiiOSDeviceResource> AddiOSDevice(
this IResourceBuilder<MauiProjectResource> builder,
string name,
string? deviceId = null)
{
// ...
}
}
builder IResourceBuilder<MauiProjectResource> The MAUI project resource builder.
name string The name of the iOS device resource.
deviceId string? optional Optional device UDID to target a specific iOS device. If not specified, uses the only attached device (requires exactly one device to be connected).
IResourceBuilder<MauiiOSDeviceResource> A reference to the ApplicationModel.IResourceBuilder`1.
This method creates a new iOS device platform resource that will run the MAUI application targeting the iOS platform using dotnet run. The resource does not auto-start and must be explicitly started from the dashboard by clicking the start button.

Multiple iOS device resources can be added to the same MAUI project if needed, each with a unique name.

This will run the application on a physical iOS device connected via USB. The device must be provisioned before deployment. For more information, see https://learn.microsoft.com/dotnet/maui/ios/device-provisioning

To target a specific device when multiple are connected, provide the device UDID. You can find the device UDID in Xcode under Window > Devices and Simulators > Devices tab, or right-click on the device and select "Copy Identifier".

Add multiple iOS devices to a MAUI project:

var builder = DistributedApplication.CreateBuilder(args);
var maui = builder.AddMauiProject("mauiapp", "../MyMauiApp/MyMauiApp.csproj");
// Default device (only one attached)
var device1 = maui.AddiOSDevice("ios-device-default");
// Specific device by UDID
var device2 = maui.AddiOSDevice("ios-device-iphone13", "00008030-001234567890123A");
builder.Build().Run();
AddiOSSimulator(IResourceBuilder<MauiProjectResource>) Section titled AddiOSSimulator(IResourceBuilder<MauiProjectResource>) extension IResourceBuilder<MauiiOSSimulatorResource>
Adds an iOS simulator resource to run the MAUI application on an iOS simulator.
public static class MauiiOSExtensions
{
public static IResourceBuilder<MauiiOSSimulatorResource> AddiOSSimulator(
this IResourceBuilder<MauiProjectResource> builder)
{
// ...
}
}
builder IResourceBuilder<MauiProjectResource> The MAUI project resource builder.
IResourceBuilder<MauiiOSSimulatorResource> A reference to the ApplicationModel.IResourceBuilder`1.
This method creates a new iOS simulator platform resource that will run the MAUI application targeting the iOS platform using dotnet run. The resource does not auto-start and must be explicitly started from the dashboard by clicking the start button.

The resource name will default to "{projectName}-ios-simulator".

This will run the application on the default iOS simulator. If no simulator is currently running, Xcode will launch the default simulator. To target a specific simulator, use the overload with simulatorId parameter.

Add an iOS simulator to a MAUI project:

var builder = DistributedApplication.CreateBuilder(args);
var maui = builder.AddMauiProject("mauiapp", "../MyMauiApp/MyMauiApp.csproj");
var iOSSimulator = maui.AddiOSSimulator();
builder.Build().Run();
AddiOSSimulator(IResourceBuilder<MauiProjectResource>, string) Section titled AddiOSSimulator(IResourceBuilder<MauiProjectResource>, string) extension IResourceBuilder<MauiiOSSimulatorResource>
Adds an iOS simulator resource to run the MAUI application on an iOS simulator with a specific name.
public static class MauiiOSExtensions
{
public static IResourceBuilder<MauiiOSSimulatorResource> AddiOSSimulator(
this IResourceBuilder<MauiProjectResource> builder,
string name)
{
// ...
}
}
builder IResourceBuilder<MauiProjectResource> The MAUI project resource builder.
name string The name of the iOS simulator resource.
IResourceBuilder<MauiiOSSimulatorResource> A reference to the ApplicationModel.IResourceBuilder`1.
This method creates a new iOS simulator platform resource that will run the MAUI application targeting the iOS platform using dotnet run. The resource does not auto-start and must be explicitly started from the dashboard by clicking the start button.

Multiple iOS simulator resources can be added to the same MAUI project if needed, each with a unique name.

This will run the application on the default iOS simulator. If no simulator is currently running, Xcode will launch the default simulator. To target a specific simulator, use the overload with simulatorId parameter.

Add multiple iOS simulators to a MAUI project:

var builder = DistributedApplication.CreateBuilder(args);
var maui = builder.AddMauiProject("mauiapp", "../MyMauiApp/MyMauiApp.csproj");
var simulator1 = maui.AddiOSSimulator("ios-simulator-1");
var simulator2 = maui.AddiOSSimulator("ios-simulator-2");
builder.Build().Run();
AddiOSSimulator(IResourceBuilder<MauiProjectResource>, string, string?) Section titled AddiOSSimulator(IResourceBuilder<MauiProjectResource>, string, string?) extension IResourceBuilder<MauiiOSSimulatorResource>
Adds an iOS simulator resource to run the MAUI application on an iOS simulator with a specific name and simulator UDID.
public static class MauiiOSExtensions
{
public static IResourceBuilder<MauiiOSSimulatorResource> AddiOSSimulator(
this IResourceBuilder<MauiProjectResource> builder,
string name,
string? simulatorId = null)
{
// ...
}
}
builder IResourceBuilder<MauiProjectResource> The MAUI project resource builder.
name string The name of the iOS simulator resource.
simulatorId string? optional Optional simulator UDID to target a specific iOS simulator. If not specified, uses the default simulator.
IResourceBuilder<MauiiOSSimulatorResource> A reference to the ApplicationModel.IResourceBuilder`1.
This method creates a new iOS simulator platform resource that will run the MAUI application targeting the iOS platform using dotnet run. The resource does not auto-start and must be explicitly started from the dashboard by clicking the start button.

Multiple iOS simulator resources can be added to the same MAUI project if needed, each with a unique name.

To target a specific simulator, provide the simulator UDID. You can find simulator UDIDs in Xcode under Window > Devices and Simulators > Simulators tab, right-click on a simulator and select "Copy Identifier", or use the command: /Applications/Xcode.app/Contents/Developer/usr/bin/simctl list

Add multiple iOS simulators to a MAUI project:

var builder = DistributedApplication.CreateBuilder(args);
var maui = builder.AddMauiProject("mauiapp", "../MyMauiApp/MyMauiApp.csproj");
// Default simulator
var simulator1 = maui.AddiOSSimulator("ios-simulator-default");
// Specific simulator by UDID
var simulator2 = maui.AddiOSSimulator("ios-simulator-iphone15", "E25BBE37-69BA-4720-B6FD-D54C97791E79");
builder.Build().Run();