dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

[iOS] Building the MAUI base app raise warnings with RuntimeIdentifier=ios-arm64 #19012

Closed riccardominato closed 6 months ago

riccardominato commented 1 year ago

Description

Creating and building a fresh .NET MAUI app for a physical device raise some warning on iOS. This should be already fixed as described in https://github.com/xamarin/xamarin-macios/issues/18964.

The same thing doesn't happen with a fresh .NET iOS app. The build command is exactly the same.

XCode version: 15.0.1 (15A507)

Steps to Reproduce

  1. Create a new .NET MAUI app --> dotnet new maui.
  2. Build the app with the following command --> dotnet build -f net8.0-ios -p:RuntimeIdentifier=ios-arm64.
  3. Check the warnings.

To check that .NET iOS doesn't have this problem replace point 1 with dotnet new ios.

Link to public reproduction project repository

Just create a new .NET MAUI app

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

17

Did you find any workaround?

No response

Relevant log output

ILLINK : warning MT4189: The class 'PassKit.PKDisbursementAuthorizationController' will not be registered it has been removed from the iOS SDK. [/Users/***/Desktop/testios/testmaui/testiosmaui/testiosmaui.csproj::TargetFramework=net8.0-ios]
ILLINK : warning MT4189: The class 'PassKit.PKDisbursementAuthorizationControllerDelegate' will not be registered it has been removed from the iOS SDK. [/Users/***/Desktop/testios/testmaui/testiosmaui/testiosmaui.csproj::TargetFramework=net8.0-ios]
ILLINK : warning MT4178: The class 'NewsstandKit.NKAssetDownload' will not be registered because the NewsstandKit framework has been removed from the iOS SDK. [/Users/***/Desktop/testios/testmaui/testiosmaui/testiosmaui.csproj::TargetFramework=net8.0-ios]
ILLINK : warning MT4178: The class 'NewsstandKit.NKLibrary' will not be registered because the NewsstandKit framework has been removed from the iOS SDK. [/Users/***/Desktop/testios/testmaui/testiosmaui/testiosmaui.csproj::TargetFramework=net8.0-ios]
ILLINK : warning MT4178: The class 'NewsstandKit.NKIssue' will not be registered because the NewsstandKit framework has been removed from the iOS SDK. [/Users/***/Desktop/testios/testmaui/testiosmaui/testiosmaui.csproj::TargetFramework=net8.0-ios]
PureWeen commented 1 year ago

@rolfbjarne thoughts?

rolfbjarne commented 1 year ago

This happens because MAUI disables the linker:

https://github.com/dotnet/maui/blob/4a31ee1f34942b77549ffa69a3e969c0cbfd8880/src/Controls/src/Build.Tasks/nuget/buildTransitive/net6.0-ios10.0/Microsoft.Maui.Controls.iOS.targets#L4

and when the linker is disabled, the app will effectively contain bindings for these PassKit and NewsstandKit types, and then the build process ends up showing these warnings that these types won't work as expected.

Note that the linker is only disabled by default in the Debug configuration, so if you build for Release there are no warnings:

dotnet build -p:RuntimeIdentifier=ios-arm64 -p:Configuration=Release

riccardominato commented 1 year ago

Thank you @rolfbjarne. I've seen that these warnings can throw unhandled exceptions at runtime (https://github.com/dotnet/maui/issues/18528, https://github.com/xamarin/xamarin-macios/issues/18964).

If I need to debug a iOS app on a physical device, should I be worried of unexpected crashes due to this issue? Are these warnings meant to be there during physical devices debug sessions or should we expect a fix?

rolfbjarne commented 1 year ago

I've seen that these warnings can throw unhandled exceptions at runtime (#18528, xamarin/xamarin-macios#18964).

No, these warnings do not indicate that you'll get unhandled exceptions at runtime (unless you use PassKit/NewsstandKit - but then again you shouldn't do that, because it won't work anyway since Apple removed those frameworks). The warnings are just a side-effect of the fix for the unhandled exceptions.

riccardominato commented 1 year ago

Ok, it's more clear now.

Nonetheless, I think having warnings in a simple build, even if they're harmless, should be avoided. Surely not the most urgent task, though.

Thank you again!

kevinxufei commented 7 months ago

Verified this issue with Visual Studio 17.10.0 Preview 3 (8.0.20 & 8.0.0-rc.2.9530). Can repro this issue. If you change the linker setting to ‘Link Framework SDKs Only’ and build again, the warning will disappear.

PureWeen commented 6 months ago

This issue was moved to xamarin/xamarin-macios#20670