Search code examples
c#iosxamarinlinkermaui

MAUI iOS build fails due to Linker missing libmono-component-hot_reload-stub-static.a file


I updated my project to .NET 8 and the Mac to MacOS 14 and XCode 15. When I build a MAUI iOS project, it fails with the following build log:

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)

I checked the folders on my Windows laptop and 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 exists (about 45KB) but on the Mac I do not see /Users/lukevo/Library/Caches/Xamarin folder at all.

I also tried to disable Hot Reload since I do not use it but the issue still happens. I also ran dotnet nuget locals all --clear before trying to build again but the issue still happens.

This also happens to a newly created MAUI Blazor Hybrid with Bundle Signing setup (no error if there is no signing).

Please tell me how to fix it or suggest the next step to diagnose the problem.


Solution

  • If your log files show a problem during the "Installing", "Uploading", or "Starting" steps for any of Mac agents, you can try deleting the XMA cache folder to force Visual Studio to re-upload them.

    As stated in Clearing the Broker, IDB, Build, and Designer Agents on the Mac, you may try deleting the XMA folder for both Mac and Windows. (This doc is about Xamarin and it applies to MAUI as well).

    For Macos, the XMA folder places in "$HOME/Library/Caches/Xamarin/XMA".

    For Windows, the XMA folder places in %localappdata%\Temp\Xamarin\XMA.

    Delete both of them. When starting next time, Visual Studio will detect and re-upload them. After deleting the folder, restart visual studio and visual studio for mac.

    More info about troubleshooting when using pair to mac, you may also refer to Connection Troubleshooting for a Xamarin.iOS Build Host.