无法 运行 本机 iOS 使用 .net 6.0 构建的应用程序:libhostpolicy.dylib 缺失
Unable to run native iOS App built with .net 6.0: libhostpolicy.dylib missing
我正在尝试使用 .net 6.0.100 (RC1) 构建 & 运行 本机 iOS 应用程序。我不 使用 MAUI。我同时使用 Visual Studio 2022 for Mac 和 Jetbrains' Rider。该应用程序是默认应用程序。 .csproj
文件如下所示:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-ios14.0</TargetFramework>
<SupportedOSPlatformVersion>14.0</SupportedOSPlatformVersion>
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
<AssemblyName>Application.iOS</AssemblyName>
<RootNamespace>Application.iOS</RootNamespace>
<LangVersion>default</LangVersion>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
</PropertyGroup>
</Project>
我可以成功构建应用程序,但我不能运行它:
Cannot use file stream for [/Users/xxx/Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/Application.iOS.deps.json]: No such file or directory
A fatal error was encountered. The library 'libhostpolicy.dylib' required to execute the application was not found in '/Users/xxx/Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/'.
Failed to run as a self-contained app.
- The application was run as a self-contained app because '/Users/xxx/Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/Application.iOS.runtimeconfig.json' did not specify a framework.
- If this should be a framework-dependent app, specify the appropriate framework in '/Users/xxx/Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/Application.iOS.runtimeconfig.json'.
文件内容如下Application.iOS.runtimeconfig.json
:
{
"runtimeOptions": {
"tfm": "net6.0",
"includedFrameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "6.0.0-rc.1.21451.13"
},
{
"name": "Microsoft.iOS",
"version": "**FromWorkload**"
}
],
"configProperties": {
"System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization": false,
"System.Diagnostics.Debugger.IsSupported": true,
"System.Diagnostics.Tracing.EventSource.IsSupported": false,
"System.Globalization.Invariant": false,
"System.Net.Http.EnableActivityPropagation": false,
"System.Net.Http.UseNativeHttpHandler": true,
"System.Resources.ResourceManager.AllowCustomResourceTypes": false,
"System.Resources.UseSystemResourceKeys": false,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
"System.StartupHookProvider.IsSupported": false,
"System.Threading.Thread.EnableAutoreleasePool": true,
"System.Text.Encoding.EnableUnsafeUTF7Encoding": false
}
}
}
我知道 libhostpolicy.dylib
文件存在于 dotnet
的安装文件夹中。我复制了文件,却得到了这个错误:
/usr/local/share/dotnet/dotnet /Users/***/Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/Application.iOS.dll
Cannot use file stream for [/Users/***Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/Application.iOS.deps.json]: No such file or directory
Failed to create CoreCLR, HRESULT: 0x80004005
问题
如何在 .net 6 上 运行 构建/运行 本机 iOS 应用程序?
Rider 尚未准备好 运行 iOS .net6 上的应用程序。也就是说,应用程序可以通过 运行ning 以下命令启动:
dotnet build -t:run
我正在尝试使用 .net 6.0.100 (RC1) 构建 & 运行 本机 iOS 应用程序。我不 使用 MAUI。我同时使用 Visual Studio 2022 for Mac 和 Jetbrains' Rider。该应用程序是默认应用程序。 .csproj
文件如下所示:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-ios14.0</TargetFramework>
<SupportedOSPlatformVersion>14.0</SupportedOSPlatformVersion>
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
<AssemblyName>Application.iOS</AssemblyName>
<RootNamespace>Application.iOS</RootNamespace>
<LangVersion>default</LangVersion>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
</PropertyGroup>
</Project>
我可以成功构建应用程序,但我不能运行它:
Cannot use file stream for [/Users/xxx/Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/Application.iOS.deps.json]: No such file or directory
A fatal error was encountered. The library 'libhostpolicy.dylib' required to execute the application was not found in '/Users/xxx/Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/'.
Failed to run as a self-contained app.
- The application was run as a self-contained app because '/Users/xxx/Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/Application.iOS.runtimeconfig.json' did not specify a framework.
- If this should be a framework-dependent app, specify the appropriate framework in '/Users/xxx/Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/Application.iOS.runtimeconfig.json'.
文件内容如下Application.iOS.runtimeconfig.json
:
{
"runtimeOptions": {
"tfm": "net6.0",
"includedFrameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "6.0.0-rc.1.21451.13"
},
{
"name": "Microsoft.iOS",
"version": "**FromWorkload**"
}
],
"configProperties": {
"System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization": false,
"System.Diagnostics.Debugger.IsSupported": true,
"System.Diagnostics.Tracing.EventSource.IsSupported": false,
"System.Globalization.Invariant": false,
"System.Net.Http.EnableActivityPropagation": false,
"System.Net.Http.UseNativeHttpHandler": true,
"System.Resources.ResourceManager.AllowCustomResourceTypes": false,
"System.Resources.UseSystemResourceKeys": false,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
"System.StartupHookProvider.IsSupported": false,
"System.Threading.Thread.EnableAutoreleasePool": true,
"System.Text.Encoding.EnableUnsafeUTF7Encoding": false
}
}
}
我知道 libhostpolicy.dylib
文件存在于 dotnet
的安装文件夹中。我复制了文件,却得到了这个错误:
/usr/local/share/dotnet/dotnet /Users/***/Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/Application.iOS.dll
Cannot use file stream for [/Users/***Application/src/Application.iOS/bin/iPhoneSimulator/Debug/net6.0-ios14.0/iossimulator-x64/Application.iOS.deps.json]: No such file or directory
Failed to create CoreCLR, HRESULT: 0x80004005
问题
如何在 .net 6 上 运行 构建/运行 本机 iOS 应用程序?
Rider 尚未准备好 运行 iOS .net6 上的应用程序。也就是说,应用程序可以通过 运行ning 以下命令启动:
dotnet build -t:run