Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Conversation

@jonathanpeppers
Copy link
Member

We are defining global usings in the mobile workloads
AutoImports.props such as:

<ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and ('$(ImplicitUsings)' == 'true' or '$(ImplicitUsings)' == 'enable') ">
  <Using Include="Android.App" />
  <Using Include="Android.Widget" />
  <Using Include="Android.OS.Bundle" Alias="Bundle" />
</ItemGroup>

So we should simply define $(TargetPlatformIdentifier) and this will
work for iOS and Android.

I found the import here actually never worked:

<Import Condition=" '$(TargetFrameworkIdentifier)' == 'MonoAndroid' " Sdk="Microsoft.Android.Sdk" Project="AutoImport.props" />

$(TargetFrameworkIdentifier) is always blank. The reason it worked
at all, was because Xamarin.Legacy.Sdk defines:

<EnableDefaultAndroidItems Condition=" '$(EnableDefaultAndroidItems)' == '' ">true</EnableDefaultAndroidItems>

So let's add this to the iOS side.

We are defining global usings in the mobile workloads
`AutoImports.props` such as:

    <ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and ('$(ImplicitUsings)' == 'true' or '$(ImplicitUsings)' == 'enable') ">
      <Using Include="Android.App" />
      <Using Include="Android.Widget" />
      <Using Include="Android.OS.Bundle" Alias="Bundle" />
    </ItemGroup>

So we should simply define `$(TargetPlatformIdentifier)` and this will
work for iOS and Android.

I found the import here actually never worked:

    <Import Condition=" '$(TargetFrameworkIdentifier)' == 'MonoAndroid' " Sdk="Microsoft.Android.Sdk" Project="AutoImport.props" />

`$(TargetFrameworkIdentifier)` is always blank. The reason it worked
at all, was because Xamarin.Legacy.Sdk defines:

    <EnableDefaultAndroidItems Condition=" '$(EnableDefaultAndroidItems)' == '' ">true</EnableDefaultAndroidItems>

So let's add this to the iOS side.
@jonathanpeppers jonathanpeppers merged commit ba6d6ad into main Aug 19, 2021
@jonathanpeppers jonathanpeppers deleted the csharp-10-global-using-part-2 branch August 19, 2021 14:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants