I have a dotnet 8 MAUI IOS application that I have developed using VS code. I would really like to take advantage of the built in debugger but it won’t boot the app in a simulator. I have seen many similar posts like this all without resolution or if they were resolved the solution did not work for me. First, here is my launch and tasks files:
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET MAUI iOS Simulator",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net8.0-ios/iossimulator-arm64/TIMS.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\bNow listening on:\s+(https?://\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/TIMS.csproj",
"-c", "Debug",
"-r", "iossimulator-arm64", // Runtime Identifier for Simulator
"-f", "net8.0-ios"
],
"problemMatcher": "$msCompile"
}
]
}
This is in my csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-ios</TargetFramework>
<RuntimeIdentifiers>iossimulator-arm64</RuntimeIdentifiers>
<MtouchLink>SdkOnly</MtouchLink>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<SelfContained>false</SelfContained>
<OutputType>Exe</OutputType>
<RootNamespace>TIMS</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>TIMS</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.edu.tims</ApplicationId>
<ApplicationIdGuid>baa91138-79c0-4181-a545-399c98881b95</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>6.9</ApplicationDisplayVersion>
<ApplicationVersion>6.9</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
<CodesignProvision>Automatic</CodesignProvision>
<CodesignKey>iPhone Distribution</CodesignKey>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<MtouchLink>None</MtouchLink> <!-- No linking for Debug builds -->
<MtouchDebug>true</MtouchDebug> <!-- Enables debug mode -->
<MtouchUseLlvm>false</MtouchUseLlvm> <!-- Disables LLVM to avoid inlining issues -->
<UseNativeHttpHandler>false</UseNativeHttpHandler>
<SelfContained>false</SelfContained>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
<CodesignProvision>Automatic</CodesignProvision>
<CodesignKey>iPhone Distribution</CodesignKey>
<SelfContained>false</SelfContained>
</PropertyGroup>
I am not getting any errors anywhere other than the debugger console where I am getting these:
A fatal error was encountered. The library 'libhostpolicy.dylib' required to execute the application was not found in '/bin/Debug/net8.0-ios/iossimulator-arm64/'.
Failed to run as a self-contained app.
- The application was run as a self-contained app because '/bin/Debug/net8.0-ios/iossimulator-arm64/TIMS.runtimeconfig.json' did not specify a framework.
- If this should be a framework-dependent app, specify the appropriate framework in '/bin/Debug/net8.0-ios/iossimulator-arm64/TIMS.runtimeconfig.json'.
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The only problem I can find is that my runtimeconfig.json has this:
{
"runtimeOptions": {
"tfm": "net8.0",
"includedFrameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.8"
},
{
"name": "Microsoft.iOS",
"version": "17.5.8020"
}
],
And so I think that it doesn’t like “`tfmand wants
frameworks““ there instead, but that is an auto-generated file so I’m not sure how to fix this.
I really don’t know what else to try that I haven’t already. Any help is greatly appreciated.
I am using xCode version 15.4 and VS Code version 1.92.2.
1
Failed to run as a self-contained app.
The application was run as a self-contained app because ‘/bin/Debug/net8.0-ios/iossimulator-arm64/TIMS.runtimeconfig.json’ did
not specify a framework.If this should be a framework-dependent app, specify the appropriate framework in
‘/bin/Debug/net8.0-ios/iossimulator-arm64/TIMS.runtimeconfig.json’.
The error indicates that the application is not finding the required dynamic library (libhostpolicy.dylib
) and is having issues with the runtimeconfig.json
file.
- Please ensure that you’ve installed the latest .NET SDK which
supports iOS development. - As Yansho said in the comments, sometimes, cleaning and rebuilding the project can resolve issues with missing files or misconfigurations.
dotnet clean
dotnet build
- Since
runtimeconfig.json
is mentioned in the error report, you also need to checkruntimeconfig.json
. Theruntimeconfig.json
is usually auto-generated, but you can manually verify its content. Ensure it specifies the correct framework and versions. If you suspect issues with auto-generation, try regenerating it by cleaning and rebuilding the project.
2