I have a dotnet 8 MAUI IOS app that I am attempting to build and run on a physical IOS device connected to my Mac via a USB. When I run the debugger I am getting the following error:
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/targets/Xamarin.Shared.Sdk.targets(1455,3): error : clang exited with code 1: [/Users/user/Projects/cds-tims-mobile-client/TIMS.csproj]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/targets/Xamarin.Shared.Sdk.targets(1455,3): error : In file included from /Users/user/Projects/cds-tims-mobile-client/obj/Debug/net8.0-ios/ios-arm64/linker-cache/registrar.mm:3: [/Users/user/Projects/cds-tims-mobile-client/TIMS.csproj]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/targets/Xamarin.Shared.Sdk.targets(1455,3): error : /Users/user/Projects/cds-tims-mobile-client/obj/Debug/net8.0-ios/ios-arm64/linker-cache/registrar.h:257:43: warning: 'retain (or strong)' attribute on property 'window' does not match the property inherited from 'UIApplicationDelegate' [-Wproperty-attribute-mismatch] [/Users/user/Projects/cds-tims-mobile-client/TIMS.csproj]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/targets/Xamarin.Shared.Sdk.targets(1455,3): error : 257 | @property (nonatomic, assign) UIWindow * window; [/Users/user/Projects/cds-tims-mobile-client/TIMS.csproj]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/targets/Xamarin.Shared.Sdk.targets(1455,3): error : | ^ [/Users/user/Projects/cds-tims-mobile-client/TIMS.csproj]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/targets/Xamarin.Shared.Sdk.targets(1455,3): error : /Users/user/Projects/cds-tims-mobile-client/obj/Debug/net8.0-ios/ios-arm64/linker-cache/registrar.h:289:43: warning: 'retain (or strong)' attribute on property 'window' does not match the property inherited from 'UIApplicationDelegate' [-Wproperty-attribute-mismatch] [/Users/user/Projects/cds-tims-mobile-client/TIMS.csproj]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/targets/Xamarin.Shared.Sdk.targets(1455,3): error : 289 | @property (nonatomic, assign) UIWindow * window; [/Users/user/Projects/cds-tims-mobile-client/TIMS.csproj]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/targets/Xamarin.Shared.Sdk.targets(1455,3): error : | ^ [/Users/user/Projects/cds-tims-mobile-client/TIMS.csproj]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8303/targets/Xamarin.Shared.Sdk.targets(1455,3): error : /Users/user/Projects/cds-tims-mobile-client/obj/Debug/net8.0-ios/ios-arm64/linker-cache/regist [/Users/user/Projects/cds-tims-mobile-client/TIMS.csproj]
9 Warning(s)
1 Error(s)
The relevant part here I think is
warning: 'retain (or strong)' attribute on property 'window' does not match the property inherited from 'UIApplicationDelegate' [-Wproperty-attribute-mismatch] [/Users/user/Projects/cds-tims-mobile-client/TIMS.csproj]
I googled around a bit and have tried a few things. I changed my AppDelegate file:
using Foundation;
using UIKit; // Add this to resolve UIWindow
namespace TIMS;
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
[Export("window")]
public override UIWindow? Window { get; set; }
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
Adding this part:
[Export("window")]
public override UIWindow? Window { get; set; }
That didn't change anything. Someone on Github also recommended setting MtouchLink
in the csproj
file to sdkOnly
:
<MtouchLink>SdkOnly</MtouchLink>
But this also did not help. I have also made sure to delete the obj
and bin
folder and try again but that still did not help.
Any assistance would be greatly appreciated.
EDIT:
Upon further testing I am not sure if I was on the right track whatsoever. I have altered my app delegate class to look like this:
using Foundation;
namespace TIMS;
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
and I still get the same error.
I have research this a bit and my problem seems to be more specifically this:
The attribute on my window
property (nonatomic, assign)
does not match what UIApplicationDelegate
expects (retain or strong)
. The line @property (nonatomic, assign) UIWindow * window;
is in an automatically generated Objective-C header file (registrar.h)
that is generated during the build process in a Xamarin or .NET MAUI iOS project. It is part of the Objective-C interop code generated by the Xamarin.iOS or .NET MAUI toolchain, which is responsible for marshaling between C# and Objective-C during the build.
So I need to find a way to get my AppDelegate
to generate the line @property (nonatomic, strong) UIWindow * window;
instead of @property (nonatomic, assign) UIWindow * window;
.
warning: 'retain (or strong)' attribute on property 'window' does not match the property inherited from 'UIApplicationDelegate' [-Wproperty-attribute-mismatch] [/Users/user/Projects/cds-tims-mobile-client/TIMS.csproj]
but the app never actual built or ran on my phone. Every subsequent time I have tried running it on the phone I get the exact same error as my above app
You can report your situation on this issue: warning "retain (or strong)' attribute on property ... #10722, or create a new issue for it on MAUI GitHub issue. Let our developers know and deal with it.