Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application referencing iOS Binding library with framework failing with 'is not a valid framework' #16001

Closed
Tracked by #19926
Bohdandn opened this issue Sep 16, 2022 · 16 comments · Fixed by #18103
Closed
Tracked by #19926
Assignees
Labels
binding-projects Issue or PR that affects binding projects bug If an issue is a bug or a pull request a bug fix iOS Issues affecting iOS macOS Issues affecting macOS windows-only The issue only occur on Windows
Milestone

Comments

@Bohdandn
Copy link

Bohdandn commented Sep 16, 2022

I'm trying to port Xamarin Forms application to MAUI. In order to do it I need MAUI port of https://www.nuget.org/packages/Xam.WebRtc.iOS, that is iOS binding library with WebRTC framework. I've created port the same way as its done in Xamarin WebRTC libraries but compilation of the application referencing this library failing with:

MT0140: File '/Users/{user}/Library/Caches/Xamarin/mtbs/builds/MauiSampleApp/b3c13bb1433487ce5b24cf495411e441634999a662cda182181bc982da09cb9c/obj/Debug/net6.0-ios/ios-arm64/linker-cache/WebRTC.framework/WebRTC' is not a valid framework

Running that project on device directly from mac terminal works just fine.

I see several issues related to this one but no solution:

You can find some additional details about solution + example in my repo - https://github.com/Bohdandn/MAUI.WebRTC.Demo
Also there is another binding repo that has the same problem - https://github.com/melihercan/WebRTCme/tree/master/WebRTCme.Bindings/Maui/WebRTCme.Bindings.Maui.iOS

I see questions in the internet related to MAUI and WebRTC or iOS binding, would be really great to finally have it solved so somebody could make nuget package and close MAUI WebRTC question for good.

Steps to Reproduce

  1. git clone https://github.com/Bohdandn/MAUI.WebRTC.Demo
  2. cd \src\MauiSampleApp\
  3. dotnet build -f:net6.0-ios /p:ServerAddress={addr} /p:ServerUser={login} /p:ServerPassword={pw} /p:TcpPort=58181 /p:_DotNetRootRemoteDirectory=/Users/{login}/Library/Caches/Xamarin/XMA/SDKs/dotnet/ /t:Run /p:RuntimeIdentifier=ios-arm64

Expected Behavior

  • Compiled WebRtc.iOS library (that can be packed in to nuget)
  • Running Application in iOS device

Actual Behavior

  • Compilation error described above

Environment

I left environment parameters that I consider important for you.

Build server:

  • macOS Monterey 12.6
  • Xcode 13.4.1

Dev machine:

  • Windows 11 with last updates
  • dotnet sdk 6.0.401
  • maui workloads:

Installed Workload Ids Manifest Version Installation Source

maui 6.0.536/6.0.400 SDK 6.0.400
runtimes-windows 6.0.4/6.0.300 VS 17.4.32912.340
maui-windows 6.0.536/6.0.400 VS 17.4.32912.340, VS 17.3.32901.215
maui-maccatalyst 6.0.536/6.0.400 VS 17.4.32912.340, VS 17.3.32901.215
maccatalyst 15.4.447/6.0.400 VS 17.4.32912.340, VS 17.3.32901.215
maui-ios 6.0.536/6.0.400 VS 17.4.32912.340, VS 17.3.32901.215
ios 15.4.447/6.0.400 VS 17.4.32912.340, VS 17.3.32901.215
maui-android 6.0.536/6.0.400 VS 17.4.32912.340, VS 17.3.32901.215
android 32.0.468/6.0.400 VS 17.4.32912.340, VS 17.3.32901.215

Build Logs

MSBuild version 17.3.1+2badb37d1 for .NET
Determining projects to restore...
Restored C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\WebRtc.Android\WebRtc.Android.csproj (in 133 ms).
Restored C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj (in 493 ms).
1 of 3 projects are up-to-date for restore.
Executing SayHello Task to establish a connection to a Remote Server.
Properties:
SessionId={XXX},
Addresss={ip},
SshPort=22,
TcpPort=,
User={user},
AppName=MauiSampleApp,
VisualStudioProcessId=,
ContinueOnDisconnected=true
Executing SayHello Task to establish a connection to a Remote Server.
Properties:
SessionId={XXX},
Addresss={ip},
SshPort=22,
TcpPort=,
User={user},
AppName=MauiSampleApp,
VisualStudioProcessId=,
ContinueOnDisconnected=true
Detected signing identity:

Code Signing Key: "Apple Development: {ZZZ} ({ZZZ})" ({ZZZ})
Provisioning Profile: "iOS Team Provisioning Profile: *" ({ZZZ})
Bundle Id: com.company.test
App Id: {ZZZ}.com.company.test

Executing SayHello Task to establish a connection to a Remote Server.
Properties:
SessionId={YYY},
Addresss={ip},
SshPort=22,
TcpPort=,
User={user},
AppName=WebRtc.iOS,
VisualStudioProcessId=,
ContinueOnDisconnected=true
C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\WebRtc.iOS\obj\Debug\net6.0-ios\ios-arm64\iOS\WebRtc.iOS\RTCCertificate.g.cs(94,27): warning CS8767: Nullability of reference types in type of parameter 'zone' of 'NSObject RTCCertificate.Copy(NSZone zone)' doesn't match implicitly implemented member 'NSObject INSCopying.Copy(NSZone? zone)' (possibly because of nullability attributes). [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\WebRtc.iOS\WebRtc.iOS.csproj]
WebRtc.iOS -> C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\WebRtc.iOS\bin\Debug\net6.0-ios\ios-arm64\WebRtc.iOS.dll
MauiSampleApp -> C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\bin\Debug\net6.0-ios\ios-arm64\MauiSampleApp.dll
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.Shared.targets(143,3): warning : Expected a 'manifest' file in the directory C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\WebRtc.iOS\bin\Debug\net6.0-ios\ios-arm64\WebRtc.iOS
.resources. [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]
/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/dotnet "/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/sdk/6.0.401/Sdks/Microsoft.NET.ILLink.Tasks/build/../tools/net6.0/illink.dll" -a "obj/Debug/net6.0-ios/ios-arm64/MauiSampleApp.dll"
-a "obj/Debug/net6.0-ios/ios-arm64/MauiSampleApp.dll"
-reference "C:/Users/{user}/.nuget/packages/microsoft.extensions.configuration/6.0.1/lib/netstandard2.0/Microsoft.Extensions.Configuration.dll"
...
-reference "C:/Users/{user}/Documents/Projects/MAUI.WebRTC.Demo/src/WebRtc.iOS/bin/Debug/net6.0-ios/ios-arm64/WebRtc.iOS.dll"
--singlewarn- "WebRtc.iOS"
-reference "C:/Program Files/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.ios-arm64/6.0.9/runtimes/ios-arm64/lib/net6.0/Microsoft.CSharp.dll"
...
-reference "C:/Program Files/dotnet/packs/Microsoft.iOS.Runtime.ios-arm64/15.4.447/runtimes/ios-arm64/lib/net6.0/Microsoft.iOS.dll"
-reference "obj/Debug/net6.0-ios/ios-arm64/MauiSampleApp.dll"
--singlewarn- "MauiSampleApp"
-out "obj/Debug/net6.0-ios/ios-arm64/linked/"
--nowarn "1701;1702;IL2026;IL2041;IL2042;IL2043;IL2056;IL2045;IL2046;IL2050;IL2032;IL2055;IL2057;IL2058;IL2059;IL2060;IL2061;IL2096;IL2062;IL2063;IL2064;IL2065;IL2066;IL2067;IL2068;IL2069;IL2070;IL2071;IL2072;IL2073;IL2074;IL2075;IL2076;IL2077;IL2078;IL2079;IL2080;I
L2081;IL2082;IL2083;IL2084;IL2085;IL2086;IL2087;IL2088;IL2089;IL2090;IL2091;IL2092;IL2093;IL2094;IL2095;IL2097;IL2098;IL2099;IL2106;IL2103;IL2107;IL2109;IL2110;IL2111;IL2114;IL2115;IL2112;IL2113;1701;1702"
--warn "5"
--warnaserror- --warnaserror ";NU1605"
--feature Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability true
--feature System.AggressiveAttributeTrimming true
--feature System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization false
--feature System.Diagnostics.Debugger.IsSupported true
--feature System.Diagnostics.Tracing.EventSource.IsSupported false
--feature System.Globalization.Invariant false
--feature System.Net.Http.EnableActivityPropagation false
--feature System.Net.Http.UseNativeHttpHandler true
--feature System.Reflection.NullabilityInfoContext.IsSupported false
--feature System.Resources.ResourceManager.AllowCustomResourceTypes false
--feature System.Resources.UseSystemResourceKeys false
--feature System.Runtime.InteropServices.BuiltInComInterop.IsSupported false
--feature System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization false
--feature System.StartupHookProvider.IsSupported false
--feature System.Threading.Thread.EnableAutoreleasePool true
--feature System.Text.Encoding.EnableUnsafeUTF7Encoding false
--trim-mode link
--action copy
--custom-step "-MarkStep:Xamarin.SetupStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "-MarkStep:Xamarin.Linker.CollectAssembliesStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "-MarkStep:MonoTouch.Tuner.CoreTypeMapStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "-MarkStep:MonoTouch.Tuner.RegistrarRemovalTrackingStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "-MarkStep:Xamarin.Linker.Steps.PreMarkDispatcher,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.Linker.Steps.PreserveBlockCodeHandler,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.Linker.OptimizeGeneratedCodeHandler,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.Linker.BackingFieldDelayHandler,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.Linker.MarkIProtocolHandler,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.Linker.Steps.MarkDispatcher,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.Linker.Steps.PreserveSmartEnumConversionsHandler,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "+SweepStep:Xamarin.Linker.Steps.PostSweepDispatcher,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "-OutputStep:Xamarin.Linker.Steps.ListExportedSymbols,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "-OutputStep:Xamarin.Linker.LoadNonSkippedAssembliesStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "-OutputStep:Xamarin.Linker.ExtractBindingLibrariesStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "-OutputStep:Xamarin.Linker.Steps.PreOutputDispatcher,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.Linker.RegistrarStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.GenerateMainStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.GenerateReferencesStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.GatherFrameworksStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.Linker.ComputeNativeBuildFlagsStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.Linker.ComputeAOTArguments,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--custom-step "Xamarin.Linker.DoneStep,/Users/{user}/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/tools/dotnet-linker/dotnet-linker.dll"
--skip-unresolved true --custom-data "LinkerOptionsFile=obj/Debug/net6.0-ios/ios-arm64/custom-linker-options.txt" --verbose -b --disable-opt unusedtypechecks --feature ObjCRuntime.Runtime.Arch.IsSimulator false

C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(327,3): warning MT1302: Could not extract the native library 'WebRTC.framework' from '/Users/{user}/Library/Caches/Xamarin/mtbs/builds/MauiSampleApp/b3c13bb1433487ce5b24cf495411e441634999a662cda182181bc982da09cb9c/obj/Debug/net6.0-ios/ios-arm64/linker-cache/WebRTC.framework.zip'. Please ensure the native library was properly embedded in the managed assembly (if the assembly was built using a binding project, the nati
ve library must be included in the project, and its Build Action must be 'ObjcBindingNativeLibrary'). [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]

C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(327,3): error IL7000: An error occured while executing the custom linker steps. Please review the build log for more information. [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]
C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(327,3): error MT0140: File '/Users/{user}/Library/Caches/Xamarin/mtbs/builds/MauiSampleApp/b3c13bb1433487ce5b24cf495411e441634999a662cda182181bc982da09cb9c/obj/Debug/net6.0-ios/ios-arm64/linker-cache/WebRTC.framework/WebRTC' is not a valid framework. [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]

C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(327,3): error MT2342: The linker step 'Extract Binding Libraries' failed during processing: File '/Users/{user}/Library/Caches/Xamarin/mtbs/builds/MauiSampleApp/{XXX}/obj/Debug/net6.0-ios/ios-arm64/linker-cache/WebRTC.framework/WebRTC' is not a valid framework. [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]

C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(368,3): error MSB3371: The file "obj\Debug\net6.0-ios\ios-arm64\linked\Link.semaphore" cannot be created. Could not find a part of the path 'C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\obj\Debug\net6.0-ios\ios-arm64\linked\Link.semaphore'. [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]

Build FAILED.

C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\WebRtc.iOS\obj\Debug\net6.0-ios\ios-arm64\iOS\WebRtc.iOS\RTCCertificate.g.cs(94,27): warning CS8767: Nullability of reference types in type of parameter 'zone' of 'NSObject RTCCertificate.Copy(NSZone zone)' doesn't match implicitly implemented member 'NSObject INSCopying.Copy(NSZone? zone)' (possibly because of nullability attributes). [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\WebRtc.iOS\WebRtc.iOS.csproj]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.Shared.targets(143,3): warning : Expected a 'manifest' file in the directory C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\WebRtc.iOS\bin\Debug\net6.0-ios\ios-arm64\WebRtc.iOS.resources. [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]
C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(327,3): warning MT1302: Could not extract the native library 'WebRTC.framework' from '/Users/{user}/Library/Caches/Xamarin/mtbs/builds/MauiSampleApp/b3c13bb1433487ce5b24cf495411e441634999a662cda182181bc982da09cb9c/obj/Debug/net6.0-ios/ios-arm64/linker-cache/WebRTC.framework.zip'. Please ensure the native library was properly embedded in the managed assembly (if the assembly was built using a binding project, the nati
ve library must be included in the project, and its Build Action must be 'ObjcBindingNativeLibrary'). [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]
C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(327,3): error IL7000: An error occured while executing the custom linker steps. Please review the build log for more information. [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]
C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(327,3): error MT0140: File '/Users/{user}/Library/Caches/Xamarin/mtbs/builds/MauiSampleApp/b3c13bb1433487ce5b24cf495411e441634999a662cda182181bc982da09cb9c/obj/Debug/net6.0-ios/ios-arm64/linker-cache/WebRTC.framework/WebRTC' is not a valid framework. [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]
C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(327,3): error MT2342: The linker step 'Extract Binding Libraries' failed during processing: File '/Users/{user}/Library/Caches/Xamarin/mtbs/builds/MauiSampleApp/{XXX}/obj/Debug/net6.0-ios/ios-arm64/linker-cache/WebRTC.framework/WebRTC' is not a valid framework. [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]
C:\Program Files\dotnet\packs\Microsoft.iOS.Windows.Sdk\15.4.447\tools\msbuild\iOS\Xamarin.iOS.Common.After.targets(368,3): error MSB3371: The file "obj\Debug\net6.0-ios\ios-arm64\linked\Link.semaphore" cannot be created. Could not find a part of the path 'C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\obj\Debug\net6.0-ios\ios-arm64\linked\Link.semaphore'. [C:\Users{user}\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp\MauiSampleApp.csproj]
3 Warning(s)
4 Error(s)

Time Elapsed 00:00:48.96

Example Project (If Possible)

https://github.com/Bohdandn/MAUI.WebRTC.Demo

@tj-devel709
Copy link
Member

Thank you for the feedback, @Bohdandn. The WebRTC lib seems to be a valid framework. We will continue to look into this.

@rolfbjarne Chris and I took a look into the framework found here and it appears to be hitting the MT0140 exception inside MachO.cs. It appears as though MachO should not be complaining as the framework appears valid:

/Users/tjlambert/Downloads/WebRTC.framework/WebRTC: Mach-O universal binary with 4 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64Mach-O 64-bit dynamically linked shared library x86_64] [i386] [arm_v7] [arm64]
/Users/tjlambert/Downloads/WebRTC.framework/WebRTC (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
/Users/tjlambert/Downloads/WebRTC.framework/WebRTC (for architecture i386):	Mach-O dynamically linked shared library i386
/Users/tjlambert/Downloads/WebRTC.framework/WebRTC (for architecture armv7):	Mach-O dynamically linked shared library arm_v7
/Users/tjlambert/Downloads/WebRTC.framework/WebRTC (for architecture arm64):	Mach-O 64-bit dynamically linked shared library arm64

@tj-devel709 tj-devel709 added this to the Future milestone Sep 19, 2022
@rolfbjarne
Copy link
Member

Since this is limited to Windows:

Running that project on device directly from mac terminal works just fine.

We might be doing something wrong when copying the file to the mac.

@Bohdandn can you try adding this to your binding project to see if that fixes it:

<PropertyGroup>
    <CompressBindingResourcePackage>true</CompressBindingResourcePackage>
</PropertyGroup>

This will zip the framework, and then we'll unzip on the Mac (and hopefully solve any problems copying individual files from Windows to the Mac).

@rolfbjarne rolfbjarne added the need-info Waiting for more information before the bug can be investigated label Sep 20, 2022
@ghost
Copy link

ghost commented Sep 20, 2022

Hi @Bohdandn. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@Bohdandn
Copy link
Author

Its still fails but with new error:

error MSB4018: The "ResolveNativeReferences" task failed unexpectedly.
System.AggregateException: One or more errors occurred. (An error occurred trying to start process '/usr/bin/unzip' with working directory 'C:\Users\bohdan\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp'. The system cannot find the file specified.)
---> System.ComponentModel.Win32Exception (2): An error occurred trying to start process '/usr/bin/unzip' with working directory 'C:\Users\bohdan\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp'. The system cannot find the file specified.
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Xamarin.Utils.Execution.<>c__DisplayClass24_1.b__0() in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/Execution.cs:line 103
--- End of stack trace from previous location ---
at Xamarin.MacDev.Tasks.XamarinTask.ExecuteAsync(String fileName, IList1 arguments, String sdkDevPath, Dictionary2 environment, Boolean mergeOutput, Boolean showErrorIfFailure, String workingDirectory) in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.MacDev.Tasks.Core/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, List`1 native_frameworks) in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/ResolveNativeReferencesBase.cs:line 134
at Xamarin.MacDev.Tasks.ResolveNativeReferencesBase.Execute() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/ResolveNativeReferencesBase.cs:line 105
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)

After running code from https://github.com/xamarin/xamarin-macios/blob/main/tools/common/Execution.cs#L103 on macOS I see that it fails if FileName = "usr/bin/unzip" and UseShellExecute = false but it does work for combinations:

  • FileName = "unzip"; UseShellExecute = false;
  • FileName = "usr/bin/unzip"; UseShellExecute = true;
    So probably you can just change the path.
    Unfortunately we still don't know if framework is not valid will appear after unzip...

Other notes:

  • you can compile binding library itself and its working just fine with and without parameter in macos and remotely from windows.
  • macos compilation outputs in library + resources folder/zip but remote compilation from windows outputs 164 files including mscorlib.dll and netstandard.dll
  • as I remember iOS binding library in Xamarin resulted in one huge dll

@ghost ghost added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Sep 20, 2022
@rolfbjarne
Copy link
Member

So if I understand correctly, a potential workaround would be to compile the binding project on the Mac, and then consume the resulting binding library directly on Windows (by referencing the .dll in your executable project).

Is that accurate?

@Bohdandn
Copy link
Author

You can compile binding library even from windows with remote Mac. What fails is compilation of maui app referencing iOS binding library from windows.

@rolfbjarne
Copy link
Member

OK, that's good to know. Since this means there's a fairly easy workaround, it might take a while for us to get around to looking at this at the moment, but I'll put it on the bug list :)

@rolfbjarne rolfbjarne modified the milestones: Future, .NET 8 Sep 23, 2022
@Bohdandn
Copy link
Author

Yeah, the only workaround is to work on Mac+Rider and not in Windows and VS that unfortunately not acceptable for me so I’ll stay in Xamarin Forms until you will fix it, thanks!

@rolfbjarne rolfbjarne added bug If an issue is a bug or a pull request a bug fix macOS Issues affecting macOS iOS Issues affecting iOS and removed need-attention An issue requires our attention/response labels Sep 23, 2022
@Csaba8472
Copy link

I've had similar issue (tried to build and run a maui app with ios binding project on windows paired to mac), in my case the issue was that in bin/Debug/net6.0-ios/XYZPROJECT.resources folder the manifest file was missing. When I built it on mac, the manifest file was there.

@Bohdandn
Copy link
Author

Bohdandn commented Nov 8, 2022

Checked after .net7 update (ios workload - 16.0.1478/7.0.100) directly from VS - behavior still the same:

error IL7000: An error occured while executing the custom linker steps. Please review the build log for more information.
error MT0140: File '/Users/user/Library/Caches/Xamarin/mtbs/builds/MauiSampleApp/e6f53c5d2fa7c74ed5fa76b98a88199210b8f9b914a5688fec42ebc2952e7d6b/obj/Debug/net7.0-ios/ios-arm64/linker-cache/WebRTC.framework/WebRTC' is not a valid framework.
error MT2342: The linker step 'Extract Binding Libraries' failed during processing: File '/Users/user/Library/Caches/Xamarin/mtbs/builds/MauiSampleApp/e6f53c5d2fa7c74ed5fa76b98a88199210b8f9b914a5688fec42ebc2952e7d6b/obj/Debug/net7.0-ios/ios-arm64/linker-cache/WebRTC.framework/WebRTC' is not a valid framework.
error : Failed to AOT compile System.Private.CoreLib.dll, the AOT compiler exited with code 134

@mattjohnsonpint
Copy link

mattjohnsonpint commented Nov 15, 2022

FYI, we are seeing the same thing with getsentry/sentry-dotnet#2037. In this case, the zip with the native framework is built on a mac and bundled with our nuget package. A Windows developer referencing our nuget package in their MAUI app, and using pair to mac to build for iOS simulator on Windows, gets an error similar to #16001 (comment) when building, as it tries to unzip the file remotely on the mac.

@mattjohnsonpint
Copy link

An error occurred trying to start process '/usr/bin/unzip' with working directory 'C:\Users\bohdan\Documents\Projects\MAUI.WebRTC.Demo\src\MauiSampleApp'. The system cannot find the file specified.

I see a similar thing:

Tool /usr/bin/unzip execution started with arguments: -u -o -d "obj\Debug\net7.0-ios\iossimulator-x64\Sentry.Bindings.Cocoa.resources.zip" "C:\Users\mattj\.nuget\packages\sentry.bindings.cocoa\3.23.1\lib\net6.0-ios16.0\Sentry.Bindings.Cocoa.resources.zip"
1> C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018: The "ResolveNativeReferences" task failed unexpectedly.
1> C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018: System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: The system cannot find the file specified

I think it's trying to unzip on Windows using the macOS /usr/bin/unzip command. Shouldn't it be trying to unzip on the mac? (Not sure how pair-to-mac works in this regard.)

@enclave-alistair
Copy link

Wanted to say that we're also experiencing the same problem when using VS paired to a Mac where the build appears to want to run /usr/bin/unzip on Windows.

C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018: The "ResolveNativeReferences" task failed unexpectedly. [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018: System.AggregateException: One or more errors occurred. (An error occurred trying to start process '/usr/bin/unzip'with working directory 'C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension'. The system cannot find the file specified.) [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018:  ---> System.ComponentModel.Win32Exception (2): An error occurred trying to start process '/usr/bin/unzip' with working directory 'C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension'. The system cannot find the file specified. [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018:    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): 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 [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018: --- End of stack trace from previous location --- [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018:    at Xamarin.MacDev.Tasks.XamarinTask.ExecuteAsync(String fileName, IList`1 arguments, String sdkDevPath, Dictionary`2 environment, Boolean mergeOutput, Boolean showErrorIfFailure, String workingDirectory) in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs:line 120 [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018:    --- End of inner exception stack trace --- [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018:    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018:    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018:    at System.Threading.Tasks.Task.Wait() [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018:    at Xamarin.MacDev.Tasks.ResolveNativeReferencesBase.ProcessSidecar(ITaskItem r, String resources, List`1 native_frameworks) in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.MacDev.Tasks/Tasks/ResolveNativeReferencesBase.cs:line 133 [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018:    at Xamarin.MacDev.Tasks.ResolveNativeReferencesBase.Execute() in /Users/builder/azdo/_work/1/s/xamarin-macios/msbuild/Xamarin.MacDev.Tasks/Tasks/ResolveNativeReferencesBase.cs:line 104 [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.0.1478\tools\msbuild\iOS\Xamarin.Shared.targets(137,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\git\enclave\fabric\src\fabric\Enclave.Fabric.iOS.Extension\Enclave.Fabric.iOS.Extension.csproj::TargetFramework=net7.0-ios]

Having to do all dev directly on macOS devices is...painful.

@rolfbjarne rolfbjarne added the binding-projects Issue or PR that affects binding projects label Dec 19, 2022
@Filastian
Copy link

@Bohdandn I ran into a similar problem on my binding project. After some investigation, I realised that the problem was with the archived dll file. The binding project was generating a *.resources folder, which contained the framework, separately from the resulting DLL.

In my case, setting the NoBindingEmbedding parameter to false in the bind project helped me.

@Bohdandn
Copy link
Author

@Filastian Thank you, it might help somebody.

<PropertyGroup>
	<NoBindingEmbedding>false</NoBindingEmbedding>
</PropertyGroup>

Unfortunately it didn't help me here, binding library compilation resulted in single dll with 299Kb size without embedded ios framework as I would expect for this option.

Simple MAUI app referencing such library is failing during compilation with:

unzip: cannot find zipfile directory in one of /Users/XXX/Library/Caches/Xamarin/mtbs/builds/MauiSampleApp/e6f53c5d2fa7c74ed5fa76b98a88199210b8f9b914a5688fec42ebc2952e7d6b/obj/Debug/net7.0-ios/ios-arm64/linker-cache/WebRTC.framework.zip or...
error MT1303: Could not decompress the native framework 'WebRTC.framework' from '...'. Please review the build log for more information from the native 'unzip' command.

Also tried with another binding project - same result. It also outputs 80Kb nuget package.

Few notes for context:

  • WebRTC framework has uncompressed size of 21Mb and compressed 10Mb
  • default behavior for old Xamarin ios binding is to output one huge dll with managed code and a framework.

Do you have anything else configured there?

@rolfbjarne
Copy link
Member

rolfbjarne commented Jan 20, 2023

We have a few issues with binding projects when building from Windows.

  • Frameworks (*.framework directories) aren't handled correctly, but this can be worked around by adding this to the binding project file:
<PropertyGroup>
	<NoBindingEmbedding>false</NoBindingEmbedding>
</PropertyGroup>
  • Unfortunately the workaround above doesn't work for xcframeworks, and the only workaround I know of is to not use .xcframeworks, but instead bind the .framework inside the .xcframework instead.

@rolfbjarne rolfbjarne self-assigned this Feb 1, 2023
@rolfbjarne rolfbjarne added the windows-only The issue only occur on Windows label Mar 14, 2023
rolfbjarne added a commit that referenced this issue May 3, 2023
…nd add tests. Fixes #16571. (#18103)

Rework Hot Restart builds to use as much as possible of the normal build
logic, because this is the easiest way to make sure the Hot Restart build is
as close as possible to normal builds (and we don't end up missing features).

This is done by executing selected parts of a normal build, and at the end we
have a new task that computes where each file goes in the various output
directories Hot Restart uses (HotRestartAppBundlePath, HotRestartContentDir,
HotRestartAppContentDir, etc.)

This PR also:

* Adds a test that runs on Windows and verifies that everything consumed in a
  build is placed in the correct location for a Hot Restart build (this is a
  variation of the BundleStructure test we already have).
* Removes tasks that aren't used anymore.
* Misc fixes to make sure existing code works on Windows.

---

This PR is best reviewed commit-by-commit.

Ref: #13924

* Fixes #16571
* Fixes #16001
* Fixes #10784
* Fixes #17579
* Contributes towards #13924.
@ghost ghost locked as resolved and limited conversation to collaborators Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
binding-projects Issue or PR that affects binding projects bug If an issue is a bug or a pull request a bug fix iOS Issues affecting iOS macOS Issues affecting macOS windows-only The issue only occur on Windows
Projects
None yet
7 participants