我将项目更新为 .NET 8,将 Mac 更新为 MacOS 14 和 XCode 15。当我构建 MAUI iOS 项目时,它失败并显示以下构建日志:
15:01:05:572 1> Target _LinkNativeExecutable:
15:01:05:572 1> Task "WriteLinesToFile"
15:01:05:634 1> Done executing task "WriteLinesToFile".
15:01:05:634 1> Task "LinkNativeCode"
15:01:08:377 1> Tool xcrun execution finished (exit code = 1).
15:01:08:377 1> ld: file too small (length=0) file '/Users/lukevo/Library/Caches/Xamarin/mtbs/builds/QrCodeGenerator/e8f6ae8766723632f111f0b174d6655fba863f7868f747ef284c64d3142ef3f3/C:/Program Files/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.ios-arm64/8.0.0/runtimes/ios-arm64/native/libmono-component-hot_reload-stub-static.a'
15:01:08:377 1> clang: error: linker command failed with exit code 1 (use -v to see invocation)
15:01:08:377 1> C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.0.8478\targets\Xamarin.Shared.Sdk.targets(1556,3): error : clang++ exited with code 1:
15:01:08:377 1> C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.0.8478\targets\Xamarin.Shared.Sdk.targets(1556,3): error : ld: file too small (length=0) file '/Users/lukevo/Library/Caches/Xamarin/mtbs/builds/QrCodeGenerator/e8f6ae8766723632f111f0b174d6655fba863f7868f747ef284c64d3142ef3f3/C:/Program Files/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.ios-arm64/8.0.0/runtimes/ios-arm64/native/libmono-component-hot_reload-stub-static.a'
15:01:08:377 1> C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.0.8478\targets\Xamarin.Shared.Sdk.targets(1556,3): error : clang: error: linker command failed with exit code 1 (use -v to see invocation)
15:01:08:451 1> Done executing task "LinkNativeCode" -- FAILED.
15:01:08:451 1> Done building target "_LinkNativeExecutable" in project "QrCodeGenerator.csproj" -- FAILED.
15:01:08:451 1>
15:01:08:451 1> Done building project "QrCodeGenerator.csproj" -- FAILED.
15:01:08:455 1> Done executing task "MSBuild" -- FAILED.
15:01:08:455 1>
15:01:08:455 1>Done building project "QrCodeGenerator.csproj" -- FAILED.
15:01:08:455 1>
15:01:08:455 1>Build FAILED.
15:01:08:455 1>
15:01:08:455 1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.0.8478\tools\msbuild\iOS\Xamarin.Shared.targets(1174,3): warning : The given path's format is not supported.
15:01:08:455 1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.0.8478\targets\Xamarin.Shared.Sdk.targets(743,3): warning MT7091: The framework C:/Users/lukev/.nuget/packages/xamarin.firebase.ios.core/8.10.0.3/lib/net6.0-ios15.4/Firebase.Core.resources/GoogleUtilitiesComponents.xcframework/ios-arm64/GoogleUtilitiesComponents.framework is a framework of static libraries, and will not be copied to the app.
15:01:08:455 1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.0.8478\targets\Xamarin.Shared.Sdk.targets(743,3): warning MT7091: The framework C:/Users/lukev/AppData/Local/XamarinBuildDownloadCache/FAdM-8.13.0/Frameworks/GoogleMobileAdsFramework-Current/GoogleMobileAds.xcframework/ios-arm64_armv7/GoogleMobileAds.framework is a framework of static libraries, and will not be copied to the app.
15:01:08:455 1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.0.8478\targets\Xamarin.Shared.Sdk.targets(743,3): warning MT7091: The framework C:/Users/lukev/AppData/Local/XamarinBuildDownloadCache/GAppM-8.9.1/GoogleAppMeasurement-8.9.1/Frameworks/GoogleAppMeasurement.xcframework/ios-arm64_armv7/GoogleAppMeasurement.framework is a framework of static libraries, and will not be copied to the app.
15:01:08:455 1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.0.8478\targets\Xamarin.Shared.Sdk.targets(1556,3): error : clang++ exited with code 1:
15:01:08:455 1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.0.8478\targets\Xamarin.Shared.Sdk.targets(1556,3): error : ld: file too small (length=0) file '/Users/lukevo/Library/Caches/Xamarin/mtbs/builds/QrCodeGenerator/e8f6ae8766723632f111f0b174d6655fba863f7868f747ef284c64d3142ef3f3/C:/Program Files/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.ios-arm64/8.0.0/runtimes/ios-arm64/native/libmono-component-hot_reload-stub-static.a'
15:01:08:455 1>C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.0.8478\targets\Xamarin.Shared.Sdk.targets(1556,3): error : clang: error: linker command failed with exit code 1 (use -v to see invocation)
我检查了 Windows 笔记本电脑上的文件夹,发现
C:/Program Files/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.ios-arm64/8.0.0/runtimes/ios-arm64/native/libmono-component-hot_reload-stub-static.a
存在(约 45KB),但在 Mac 上我根本看不到 /Users/lukevo/Library/Caches/Xamarin
文件夹。
我还尝试禁用热重载,因为我不使用它,但问题仍然发生。在尝试再次构建之前我也运行了
dotnet nuget locals all --clear
,但问题仍然发生。
新创建的具有捆绑签名设置的 MAUI Blazor Hybrid 也会发生这种情况(如果没有签名,则不会出现错误)。
请告诉我如何修复它或建议下一步诊断问题。
如果您的日志文件在任何 Mac 代理的“安装”、“上传”或“启动”步骤中显示问题,您可以尝试删除 XMA 缓存文件夹以强制 Visual Studio 重新上传它们。
如清除 Mac 上的 Broker、IDB、Build 和 Designer Agents 中所述,您可以尝试删除 Mac 和 Windows 上的 XMA 文件夹。 (本文档是关于 Xamarin 的,它也适用于 MAUI)。
对于 Macos,XMA 文件夹位于
"$HOME/Library/Caches/Xamarin/XMA"
。
对于 Windows,XMA 文件夹位于
%localappdata%\Temp\Xamarin\XMA
。
将它们都删除。下次启动时,Visual Studio 将检测并重新上传它们。删除文件夹后,重新启动 Visual Studio 和 Visual Studio for mac。
有关使用配对到 mac 时进行故障排除的更多信息,您还可以参阅Xamarin.iOS 构建主机的连接故障排除。