TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
211 stars 49 forks source link

Problem when compiling Plugin.Firebase with iOS .NET MAUI app (NET 7.0) - errors MT4116, IL7000, IL7000, NETSDK1144 #130

Closed Juansero29 closed 10 months ago

Juansero29 commented 1 year ago

I have developed an app with .NET MAUI that I have been compiling only on android, now I started compiling in iOS and the build fails because of some linking issue with Plugin.Firebase, here are the four errors that the build gives:

  1. ILLink : iOS error IL7000: An error occured while executing the custom linker steps. Please review the build log for more information. (when clicking on this error I am sent to the build output console)
  2. ILLINK : error MT4116: Could not register the assembly 'Plugin.Firebase': System.ArgumentNullException: Value cannot be null. (Parameter 'key') (when clicking on this error I am sent to https://learn.microsoft.com/en-us/xamarin/ios/troubleshooting/mtouch-errors#MT4116)
  3. ILLINK : error MT2362: The linker step 'Registrar' failed during processing: Could not register the assembly 'Plugin.Firebase': System.ArgumentNullException: Value cannot be null. (Parameter 'key') - this error sends me to (https://learn.microsoft.com/en-us/xamarin/ios/troubleshooting/mtouch-errors#MT2362)
  4. /usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.ILLink.Tasks/build/Microsoft.NET.ILLink.targets(86,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false. - clicking this error sends me to line 86 of the following path "/usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.ILLink.Tasks/build/Microsoft.NET.ILLink.targets

I tried setting the "PublishTrimmed" to false for iOS, but then I get an error message saying "iOS projects must build with PublishTrimmed=true"

Here is the full buld output with the errors that are shown to me

--custom-step "-MarkStep:Xamarin.SetupStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "-MarkStep:Xamarin.Linker.CollectAssembliesStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "-MarkStep:MonoTouch.Tuner.CoreTypeMapStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "-MarkStep:MonoTouch.Tuner.RegistrarRemovalTrackingStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "-OutputStep:Xamarin.Linker.Steps.ListExportedSymbols,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "-OutputStep:Xamarin.Linker.LoadNonSkippedAssembliesStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "-OutputStep:Xamarin.Linker.ExtractBindingLibrariesStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "-OutputStep:Xamarin.Linker.Steps.PreOutputDispatcher,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "Xamarin.Linker.RegistrarStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "Xamarin.GenerateMainStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "Xamarin.GenerateReferencesStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "Xamarin.GatherFrameworksStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "Xamarin.Linker.ComputeNativeBuildFlagsStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "Xamarin.Linker.ComputeAOTArguments,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --custom-step "Xamarin.Linker.DoneStep,/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1024/tools/dotnet-linker/dotnet-linker.dll"
    --skip-unresolved true  --notrimwarn --custom-data "LinkerOptionsFile=/Users/juansero29/Projects/Nou/Nou/obj/Debug/net7.0-ios/ios-arm64/custom-linker-options.txt" --custom-data DisableMarkingOfCopyAssemblies=true --verbose -b --disable-opt unusedtypechecks --feature ObjCRuntime.Runtime.Arch.IsSimulator false --enable-serialization-discovery

    ILLink : iOS error IL7000: An error occured while executing the custom linker steps. Please review the build log for more information.
    ILLINK : error MT4116: Could not register the assembly 'Plugin.Firebase': System.ArgumentNullException: Value cannot be null. (Parameter 'key')
       at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
       at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
       at Registrar.StaticRegistrar.GetCustomAttributes(ICustomAttributeProvider provider, String namespace, String name, Boolean inherits)+MoveNext() in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/StaticRegistrar.cs:line 607
       at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
       at Registrar.StaticRegistrar.HasAttribute(ICustomAttributeProvider provider, String namespace, String name, Boolean inherits) in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/StaticRegistrar.cs:line 637
       at Registrar.StaticRegistrar.CollectInterfaces(List`1& ifaces, TypeDefinition type) in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/StaticRegistrar.cs:line 345
       at Registrar.StaticRegistrar.PrepareInterfaceMethodMapping(TypeReference type) in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/StaticRegistrar.cs:line 365
       at Registrar.StaticRegistrar.PrepareMethodMapping(TypeReference type) in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/StaticRegistrar.cs:line 1824
       at Registrar.Registrar.RegisterTypeUnsafe(TypeReference type, List`1& exceptions) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Registrar.cs:line 2348
       at Registrar.Registrar.RegisterAssembly(AssemblyDefinition assembly) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Registrar.cs:line 2509

    ILLINK : error MT2362: The linker step 'Registrar' failed during processing: Could not register the assembly 'Plugin.Firebase': System.ArgumentNullException: Value cannot be null. (Parameter 'key')
       at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
       at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
       at Registrar.StaticRegistrar.GetCustomAttributes(ICustomAttributeProvider provider, String namespace, String name, Boolean inherits)+MoveNext() in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/StaticRegistrar.cs:line 607
       at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
       at Registrar.StaticRegistrar.HasAttribute(ICustomAttributeProvider provider, String namespace, String name, Boolean inherits) in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/StaticRegistrar.cs:line 637
       at Registrar.StaticRegistrar.CollectInterfaces(List`1& ifaces, TypeDefinition type) in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/StaticRegistrar.cs:line 345
       at Registrar.StaticRegistrar.PrepareInterfaceMethodMapping(TypeReference type) in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/StaticRegistrar.cs:line 365
       at Registrar.StaticRegistrar.PrepareMethodMapping(TypeReference type) in /Users/builder/azdo/_work/1/s/xamarin-macios/tools/common/StaticRegistrar.cs:line 1824
       at Registrar.Registrar.RegisterTypeUnsafe(TypeReference type, List`1& exceptions) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Registrar.cs:line 2348
       at Registrar.Registrar.RegisterAssembly(AssemblyDefinition assembly) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Registrar.cs:line 2509

    Build continuing because "ContinueOnError" on the task "ILLink" is set to "ErrorAndContinue".
Done building target "_RunILLink" in project "Nou.csproj" -- FAILED.
Target ILLink:
    /usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.ILLink.Tasks/build/Microsoft.NET.ILLink.targets(86,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.
Done building target "ILLink" in project "Nou.csproj" -- FAILED.

Done building project "Nou.csproj" -- FAILED.

Build FAILED.

ILLink : iOS error IL7000: An error occured while executing the custom linker steps. Please review the build log for more information.
ILLINK : error MT4116: Could not register the assembly 'Plugin.Firebase': System.ArgumentNullException: Value cannot be null. (Parameter 'key')
ILLINK : error MT2362: The linker step 'Registrar' failed during processing: Could not register the assembly 'Plugin.Firebase': System.ArgumentNullException: Value cannot be null. (Parameter 'key')
/usr/local/share/dotnet/sdk/7.0.102/Sdks/Microsoft.NET.ILLink.Tasks/build/Microsoft.NET.ILLink.targets(86,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.
    0 Warning(s)
    4 Error(s)

Time Elapsed 00:00:08.28

========== Build: 0 succeeded, 1 failed, 3 up-to-date, 0 skipped ==========

Build: 4 errors, 0 warnings

Any help of workaround would be very appreciated... Thanks a lot

Juansero29 commented 1 year ago

As additional info, here's the .csproj of my .NET MAUI project if it can help: https://gist.github.com/Juansero29/415b695ac20020bc70d139384c05e84c

omxie commented 1 year ago

Not sure whether this helps but I was having a lot of issues iOS as well, so I started the project with the latest version of VS Preview & also updated XCode to the latest. After doing that majority of the errors disappeared.

eyeveye commented 1 year ago

I am encountering the same problem. Tried to look at @Juansero29 file and retry some of the configuration. Still the same. @omxie did you face the same error before upgrading to the newest version? I am a bit reluctant to go to the latest version especially preview version.

eyeveye commented 1 year ago

Just got it working for .NET7.0 by removing editing this in the project file: <MtouchLink>None</MtouchLink>

Ghevi commented 1 year ago

@eyeveye I'm using this plugin for push notifications, but when using .net7.0 there an error occurs, Framework not found System and it seems caused by something like google authentication of this package. I tried both the mtouchlink none and without it...what package version are you using?

eyeveye commented 1 year ago

@eyeveye I'm using this plugin for push notifications, but when using .net7.0 there an error occurs, Framework not found System and it seems caused by something like google authentication of this package. I tried both the mtouchlink none and without it...what package version are you using?

I am using 1.2.5

Juansero29 commented 1 year ago

@TobiasBuchholz wondering if you have any insight on this problem as I can still not compile my app on iOS due to this errors?

TobiasBuchholz commented 1 year ago

Hey @Juansero29, unfortunately I don't have any insights on this problem sorry. Did you try the newest version of the plugin or to include just the package for the specific feature you are going to use? It would also be helpful for investigation if you were able to provide a sample project that reproduces this issue.

Juansero29 commented 1 year ago

@TobiasBuchholz couldn't find any solution for dotnet 7 so i ended up removing this package and opting for another one: https://github.com/Gekidoku/BetterFireBaseNotificationsPlugin since I was using this one only for notifications anyway.

chema-code commented 6 months ago

I haven't been able to get it to work either, or rather to comply in any way. I have also filed a ticket in the visual studio support channel but... they are still working on it.

For now I changed to this library that does work https://github.com/thomasgalliker/Plugin.FirebasePushNotifications