Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,15 @@
</ItemGroup>
</Target>

<!-- https://github.com/xamarin/xamarin-macios/issues/19037 -->
<!-- The trimmer will set the RootMode for the current assembly to 'EntryPoint', but that doesn't work for app extension projects, because those are library projects that don't have entry points.
So here we set RootMode=Library for these cases. -->
<Target Name="_FixRootAssemblyForAppExtensions" AfterTargets="PrepareForILLink" Condition="'$(IsAppExtension)' == 'true'">
<ItemGroup>
<TrimmerRootAssembly Update="@(TrimmerRootAssembly)" Condition=" '%(TrimmerRootAssembly.RootMode)' == 'EntryPoint' " RootMode="Library" />
</ItemGroup>
</Target>

<Target Name="_CreateAOTDedupAssembly"
Condition="'$(_RunAotCompiler)' == 'true' And '$(IsMacEnabled)' == 'true'"
DependsOnTargets="_ComputeManagedAssemblyToLink"
Expand Down
18 changes: 18 additions & 0 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,24 @@ public void BuildProjectsWithExtensionsAndFrameworks (ApplePlatform platform)
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);
}


[TestCase (ApplePlatform.iOS)]
[TestCase (ApplePlatform.TVOS)]
[TestCase (ApplePlatform.MacOSX)]
// [TestCase ("MacCatalyst", "")] - No extension support yet
public void BuildTrimmedExtensionProject (ApplePlatform platform)
{
Configuration.IgnoreIfIgnoredPlatform (platform);
var project_path = GetProjectPath ("ExtensionProject", platform: platform);

Clean (project_path);

var properties = GetDefaultProperties ();
properties ["MtouchLink"] = "Full";
properties ["LinkMode"] = "Full";
DotNet.AssertBuild (project_path, properties);
}

[TestCase (ApplePlatform.iOS, "iossimulator-x64;iossimulator-arm64")]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64")]
Expand Down