BarcodeScanner.Mobile icon indicating copy to clipboard operation
BarcodeScanner.Mobile copied to clipboard

ResolveNativeReferences FAILED when building iOS

Open YeldarOralov opened this issue 2 years ago • 21 comments

Hello, I am trying to use the scanner on MAUI I used your sources and copied them in full to our local nuget. Android build and works succesfully. But on iOS there is an error.

I tried to build your sample for maui, but the same error occurs.

build_log.txt

May I know which versions of iOS SDK you are using?

YeldarOralov avatar Jul 27 '22 04:07 YeldarOralov

Just checking the log and seems the error is

 Tool /usr/bin/unzip execution started with arguments: -u -o -d "obj\\Release\\net6.0-ios\\ios-arm64\\MLKit.Core.resources.zip" "C:\\Nuget\\xamarin.mlkit.ios.core.jimmypun610\\5.0.0.1\\lib\\net6.0-ios15.4\\MLKit.Core.resources.zip"
1>        C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.414\tools\msbuild\iOS\Xamarin.Shared.targets(143,3): error MSB4018: The "ResolveNativeReferences" task failed unexpectedly.
1>        C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.414\tools\msbuild\iOS\Xamarin.Shared.targets(143,3): error MSB4018: System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: The system cannot find the file specified

Not sure why the file is not downloading to your repo. I am using Visual Studio for Mac preview 17.4 and iOS 15.6

JimmyPun610 avatar Aug 12 '22 00:08 JimmyPun610

I also received this error, are there any known work arounds at the moment?

DSlutter avatar Aug 12 '22 10:08 DSlutter

If you are using Windows to connect mac, you may try #124 to see if it can fix the issue.

JimmyPun610 avatar Aug 12 '22 11:08 JimmyPun610

I've already tried that as I had the same issue. I've put my packages in a folder called 'N' at the start of my drive so I can't shorten the directory url any further.

DSlutter avatar Aug 12 '22 11:08 DSlutter

I've already tried that as I had the same issue. I've put my packages in a folder called 'N' at the start of my drive so I can't shorten the directory url any further.

You could try to extract the zip the to folder path mentioned and see if it works or not. https://drive.google.com/file/d/1j8XQfbKSVcOO2HcY-fLeqhPnsvBy9EXg/view?usp=sharing

JimmyPun610 avatar Aug 12 '22 14:08 JimmyPun610

That didn't work. Tried it with the nuget package installed as well.

DSlutter avatar Aug 15 '22 07:08 DSlutter

@JimmyPun610 I already tried everything you wrote, but nothing helped me.

YeldarOralov avatar Aug 22 '22 04:08 YeldarOralov

@YeldarOralov I am having exactly the same issue - did you resolve it?

clough360 avatar Sep 30 '22 12:09 clough360

Was anyone able to solve this issue?

sikandaramla avatar Oct 24 '22 08:10 sikandaramla

I can't add anything other than I have a Xamarin project linked to a Mac and running the barcode scanner perfectly. I have the translated Maui app on the same Windows machine linked to the same Mac and it is failing with the ResolveNativeReferences issue. It compiles, runs and packages fine on Android though. Also, on Visual Studio for Mac on a Mac, it does compile. It shows a black screen on the simulator without running but I think that is unrelated to this.

ajz1966 avatar Nov 11 '22 20:11 ajz1966

I can't add anything other than I have a Xamarin project linked to a Mac and running the barcode scanner perfectly. I have the translated Maui app on the same Windows machine linked to the same Mac and it is failing with the ResolveNativeReferences issue. It compiles, runs and packages fine on Android though. Also, on Visual Studio for Mac on a Mac, it does compile. It shows a black screen on the simulator without running but I think that is unrelated to this.

Microsoft has resolved this issue with the latest version (17.4.0). Get the latest for both Windows and Mac.

sikandaramla avatar Nov 12 '22 04:11 sikandaramla

I can't add anything other than I have a Xamarin project linked to a Mac and running the barcode scanner perfectly. I have the translated Maui app on the same Windows machine linked to the same Mac and it is failing with the ResolveNativeReferences issue. It compiles, runs and packages fine on Android though. Also, on Visual Studio for Mac on a Mac, it does compile. It shows a black screen on the simulator without running but I think that is unrelated to this.

Microsoft has resolved this issue with the latest version (17.4.0). Get the latest for both Windows and Mac.

It still gets the ResolveNativeReferences error upon compiling while pointed toward an iOS simulator even with 17.4

ajz1966 avatar Nov 14 '22 13:11 ajz1966

This issues still occurs with 17.4.0. Reading a diagnostic dump, the offending issues seems to be: 1> Tool /usr/bin/unzip execution started with arguments: -u -o -d "obj\Debug\net7.0-ios\iossimulator-x64\MLKit.Core.resources.zip" "C:\Users\xx\.nuget\packages\xamarin.mlkit.ios.core.jimmypun610\5.0.0.1\lib\net6.0-ios15.4\MLKit.Core.resources.zip"

So, something with missing file MLKit.Core.resources.zip missing from xamarin.mlkit.ios.core.jimmypun610???

ajz1966 avatar Nov 16 '22 12:11 ajz1966

You're likely experiencing this issue - which happens for any nuget package that contains an iOS native resources zip file, but only when using pair-to-mac on a Windows machine.

https://github.com/xamarin/xamarin-macios/issues/16001

mattjohnsonpint avatar Nov 30 '22 19:11 mattjohnsonpint

It seems to me this should be tagged as a bug rather than a question.

ajz1966 avatar Dec 13 '22 13:12 ajz1966

I'm encountering this issue with VS 17.4.3 too when compiling iOS using a remote mac. The issue only happen for MAUI, not Xamarin.

programatix avatar Jan 03 '23 09:01 programatix

I'm encountering this issue with VS 17.4.3 too when compiling iOS using a remote mac. The issue only happen for MAUI, not Xamarin.

I think mattjohnsonpint's reply from November 30 sums it up but it's doesn't help me solve anything. I ended up switching to the Zxing.Net.Maui library. However, I'm finding that library is not working for me either. At least it compiles but the hot reloader stops and it is stuck in a loop deploying. That is much better than the JimmyPun610 Maui library which can't compile at all neither in my project or this Github sample project. I have tried to compile from a PC linked to a Mac and using VS for Mac on a Mac which doesn't work though I admit Apple is an unknown and alien environment for me. It's a shame as the Xamarin version was absolutely perfect. We have stopped development on our device app. Xamarin isn't keeping up and Maui is not ready to handle a robust app that can use a device's camera to take pictures, read bar codes, etc. I should qualify that and say, Maui is pretty good at doing many things across multiple Android devices (our app works perfectly on Android) but not iOS. I can't fault Jimmy Pun but I sure do fault the Maui team for giving developers a tool that is supposed to be a develop in one place, deploy across multiple platform tool yet we have to dance around with a jury rigged setup of a prelease of Visual Studio, multiple XCode versions, SDK's versions, .net versions, etc and, if they do not work in concert with each other, a project that compiled and deployed yesterday may not do so today.

ajz1966 avatar Jan 03 '23 13:01 ajz1966

Sorry for the late reply, just an update that below thread may help with this issue. https://github.com/JimmyPun610/BarcodeScanner.Mobile/issues/100#issuecomment-1445404196

Unfortunately I do not have a Windows + Mac to test it with Pair to Mac.

JimmyPun610 avatar Feb 26 '23 16:02 JimmyPun610

Hello, Thread 100 (comment) not working for me

<Target Name="_CollectHotRestartFrameworksFromPackages" BeforeTargets="_CollectHotRestartFrameworks" Condition="'$(IsHotRestartBuild)' == 'true'"> <ItemGroup> <_PackageResourcesDirs Include="@(AssembliesWithFrameworks -> '%(RootDir)%(Directory)%(FileName).resources')" Condition="Exists('%(RootDir)%(Directory)%(FileName).resources')" /> <_PackageResourcesZips Include="@(AssembliesWithFrameworks -> '%(RootDir)%(Directory)%(FileName).resources.zip')" Condition="Exists('%(RootDir)%(Directory)%(FileName).resources.zip')" /> </ItemGroup> <PropertyGroup> <HotRestartPackageResourcesDir>$(TEMP)\Xamarin\HotRestart\Resources\</HotRestartPackageResourcesDir> </PropertyGroup> <Unzip ZipFilePath="@(_PackageResourcesZips)" ExtractionPath="$(HotRestartPackageResourcesDir)%(NuGetPackageId)\%(NuGetPackageVersion)" Condition="'@(_PackageResourcesZips)' != '' And !Exists('$(HotRestartPackageResourcesDir)%(NuGetPackageId)\%(NuGetPackageVersion)')" /> <ItemGroup Condition="'@(_PackageResourcesZips)' != ''"> <_PackageResourcesDirs Include="@(_PackageResourcesZips -> '$(HotRestartPackageResourcesDir)%(NuGetPackageId)\%(NuGetPackageVersion)')" /> </ItemGroup> <ItemGroup Condition="'@(_PackageResourcesDirs)' != ''"> <_PackageResourcesFrameworkFiles Include="%(_PackageResourcesDirs.Identity)\*.framework\*" /> <_PackageResourcesFrameworkFiles Include="%(_PackageResourcesDirs.Identity)\**\*.xcframework\ios-arm64\*.framework\*" /> <_HotRestartFrameworksFromPackages Include="@(_PackageResourcesFrameworkFiles -> '%(RootDir)%(Directory)')" KeepDuplicates="false" /> <_HotRestartFrameworks Include="@(_HotRestartFrameworksFromPackages -> TrimEnd('\'))" /> </ItemGroup> </Target>

When debug (pair to Mac) get error

error MSB4018: The "ResolveNativeReferences" task failed unexpectedly. error MSB4018: System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: The system cannot find the file specified error MSB4018: at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) error MSB4018: at Xamarin.Utils.Execution.<>c__DisplayClass24_1.<RunAsync>b__0() in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/Execution.cs:line 103

hoangtutravinh avatar Feb 27 '23 02:02 hoangtutravinh

hi, is there any workaround for this? i have tried all the solutions above and still no luck...

lpierpoint avatar Jun 20 '23 23:06 lpierpoint

I got also that error, is there a solution for this problem? Visual Studio Community 2022 -Version 17.7.2

Severity Code Description Project File Line Suppression State Error MSB4018 The "ResolveNativeReferences" task failed unexpectedly. System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at Xamarin.Utils.Execution.<>c__DisplayClass24_1.<RunAsync>b__0() in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/Execution.cs:line 103 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Xamarin.MacDev.Tasks.XamarinTask.<ExecuteAsync>d__24.MoveNext() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs:line 120 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Xamarin.MacDev.Tasks.ResolveNativeReferencesBase.ProcessSidecar(ITaskItem r, String resources, List1 native_frameworks) in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.MacDev.Tasks/Tasks/ResolveNativeReferencesBase.cs:line 133 at Xamarin.MacDev.Tasks.ResolveNativeReferencesBase.Execute() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.MacDev.Tasks/Tasks/ResolveNativeReferencesBase.cs:line 104 at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() ---> (Inner Exception #0) System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at Xamarin.Utils.Execution.<>c__DisplayClass24_1.<RunAsync>b__0() in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/Execution.cs:line 103 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Xamarin.MacDev.Tasks.XamarinTask.<ExecuteAsync>d__24.MoveNext() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs:line 120<--- BarcodeGenerator C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.4.7089\tools\msbuild\iOS\Xamarin.Shared.targets 137

geertgeerits avatar Aug 29 '23 12:08 geertgeerits