Skip to content

$(TargetPlatformIdentifier) is not being set correctly for iOS #22238

@bzd3y

Description

@bzd3y

Apple platform

iOS

Framework version

net9.0-*

Affected platform version

VS 2022 17.13.1

Description

I split this from an issue I created earlier: #22235, but I am going to close that because I think I added it in the wrong place and need to report that through the VS Feedback feature. I'm also not sure I am adding this issue in the right place.
 
I have a project configured with the following:

		<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'ios'">13.0</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'android'">23.0</SupportedOSPlatformVersion>

The last line, for Android, works. The MacCatalyst line also appears to work, though I haven't tested it all the way to deploying.

The first line does not work when deploying to an iOS with an OS version below 18.2. The condition is not met and so the SupportedOSPlatformVersion defaults to 18.2.

Adding a Target to the project file to output the value of $(TargetPlatformIdentifier) has some strange behavior.

When doing a solution rebuild it will output a 'MacCatalyst' (this is why I think the above line for MacCatalyst works) and 'Android'. It will not output 'iOS'.

However, if I do a build by running the app on a remote iOS device, it only outputs 'iOS', as expected. But after that the deploy fails due to the device not having the minimum required OS version of 18.2. It looks like mtouch is what outputs the error. The error is long and formatted all on one line, but it contains the following messages:

INFO: ?<App Name>? Requires a Newer Version of iOS (IXUserPresentableErrorDomain error 16 (0x10))
INFO: NSLocalizedRecoverySuggestion = The system version is lower than the minimum OS version specified for bundle at /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.iePTy3/extracted/Payload/<App>.Maui.app. Have 17.6.1; need 18.2
INFO: The system version is lower than the minimum OS version specified for bundle at /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.iePTy3/extracted/Payload/<App>.Maui.app. Have 17.6.1; need 18.2 (MIInstallerErrorDomain error 9 (0x09))

The following configurations do work:

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">13.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'android'">23.0</SupportedOSPlatformVersion>

and

<TargetPlatformIdentifier Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>

<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'ios'">13.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'android'">23.0</SupportedOSPlatformVersion>

For some additional information, if the minimum OS version is set in Info.plist to "13.0" then an error (or warning? I don't remember) is output stating that the value conflicts with the value from the project of "18.2", indicating that it isn't getting picked up and is being defaulted to 18.2.

This part might be subjective, but it seems strange to default the minimum OS version to the maximum OS version. I would think the default OS version should be the minimum OS version supported by the framework. To that point, the configuration from the MAUI template sets SupportedOSPlatformVersion to "11.0". It seems like that should be the default for SupportedOSPlatformVersion isn't specified at all.

Steps to Reproduce

Create a MAUI 9.0 project and add the above lines to the project file. Run the project on a device running a version lower than iOS 18.2. It will build, but not deploy.

Did you find any workaround?

Yes, the last two configurations described above.

Build logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions