xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.42k stars 507 forks source link

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

Open PureWeen opened 1 month ago

PureWeen commented 1 month ago

Issue moved from dotnet/maui#19012


From @riccardominato on Friday, November 24, 2023 2:36:20 PM

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 month ago

Issue moved from dotnet/maui#19012


From @PureWeen on Monday, November 27, 2023 3:29:13 PM

@rolfbjarne thoughts?

PureWeen commented 1 month ago

Issue moved from dotnet/maui#19012


From @rolfbjarne on Tuesday, November 28, 2023 7:23:36 AM

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

PureWeen commented 1 month ago

Issue moved from dotnet/maui#19012


From @riccardominato on Tuesday, November 28, 2023 7:32:48 AM

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?

PureWeen commented 1 month ago

Issue moved from dotnet/maui#19012


From @rolfbjarne on Tuesday, November 28, 2023 7:46:51 AM

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.

PureWeen commented 1 month ago

Issue moved from dotnet/maui#19012


From @riccardominato on Tuesday, November 28, 2023 7:54:52 AM

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!

PureWeen commented 1 month ago

Issue moved from dotnet/maui#19012


From @kevinxufei on Tuesday, April 16, 2024 9:20:38 AM

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.

riccardominato commented 4 weeks ago

@PureWeen You have moved this issue from MAUI repo to the Xamarin one, but if you read the description I verified that this is not a problem with .NET iOS.

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

rolfbjarne commented 4 weeks ago

@PureWeen You have moved this issue from MAUI repo to the Xamarin one, but if you read the description I verified that this is not a problem with .NET iOS.

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

You can repro in a .NET iOS project as well if you disable the linker.