-
Notifications
You must be signed in to change notification settings - Fork 559
Add support for Composer Icons #24722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 9 commits
7679b9e
8d29605
4d27b7f
3dad65e
c58f712
24c7f45
478d2c3
99a4a0b
1c1bbf4
40f00db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| using System; | ||
| using Foundation; | ||
|
|
||
| #if !__MACOS__ | ||
| using UIKit; | ||
| #endif | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace AppWithComposerIcon { | ||
| #if !(__MACCATALYST__ || __MACOS__) | ||
| public class AppDelegate : UIApplicationDelegate { | ||
| public override bool FinishedLaunching (UIApplication app, NSDictionary options) | ||
| { | ||
| return true; | ||
| } | ||
| } | ||
| #endif | ||
|
|
||
| public class Program { | ||
| static int Main (string [] args) | ||
| { | ||
| #if __MACCATALYST__ || __MACOS__ | ||
| GC.KeepAlive (typeof (NSObject)); // prevent linking away the platform assembly | ||
|
|
||
| Console.WriteLine (Environment.GetEnvironmentVariable ("MAGIC_WORD")); | ||
|
|
||
| return args.Length; | ||
| #else | ||
| UIApplication.Main (args, null, typeof (AppDelegate)); | ||
| return 0; | ||
| #endif | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-maccatalyst</TargetFramework> | ||
| </PropertyGroup> | ||
| <Import Project="..\shared.csproj" /> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include ../shared.mk |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "groups" : [ | ||
| { | ||
| "layers" : [ | ||
| { | ||
| "image-name" : "back.png", | ||
| "name" : "back" | ||
| }, | ||
| { | ||
| "image-name" : "front.png", | ||
| "name" : "front" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-ios</TargetFramework> | ||
| </PropertyGroup> | ||
| <Import Project="..\shared.csproj" /> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include ../shared.mk |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "groups" : [ | ||
| { | ||
| "layers" : [ | ||
| { | ||
| "image-name" : "back.png", | ||
| "name" : "back" | ||
| }, | ||
| { | ||
| "image-name" : "front.png", | ||
| "name" : "front" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-macos</TargetFramework> | ||
| </PropertyGroup> | ||
| <Import Project="..\shared.csproj" /> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include ../shared.mk |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "groups" : [ | ||
| { | ||
| "layers" : [ | ||
| { | ||
| "image-name" : "back.png", | ||
| "name" : "back" | ||
| }, | ||
| { | ||
| "image-name" : "front.png", | ||
| "name" : "front" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
|
|
||
| <ApplicationTitle>AppWithComposerIcon</ApplicationTitle> | ||
| <ApplicationId>com.xamarin.appwithcomposericon</ApplicationId> | ||
|
|
||
| <UseInterpreter>true</UseInterpreter> <!-- this is only to speed up the build --> | ||
| </PropertyGroup> | ||
|
|
||
| <Import Project="../../common/shared-dotnet.csproj" /> | ||
|
|
||
| <PropertyGroup> | ||
| <AppIcon>AppIcon</AppIcon> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="../*.cs" /> | ||
|
|
||
| <!-- ImageAssets: included by default (each platform has a Resources/AppIcon.icon directory) --> | ||
| </ItemGroup> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| TOP=../../../.. | ||
| TESTNAME=AppWithComposerIcon | ||
| include $(TOP)/tests/common/shared-dotnet.mk |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-tvos</TargetFramework> | ||
| </PropertyGroup> | ||
| <Import Project="..\shared.csproj" /> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include ../shared.mk |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "groups" : [ | ||
| { | ||
| "layers" : [ | ||
| { | ||
| "image-name" : "back.png", | ||
| "name" : "back" | ||
| }, | ||
| { | ||
| "image-name" : "front.png", | ||
| "name" : "front" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -672,5 +672,35 @@ void TestXCAssetsImpl (ApplePlatform platform, string runtimeIdentifiers, Dictio | |||||||||||||||||||||
| throw; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| [TestCase (ApplePlatform.iOS, "iossimulator-x64")] | ||||||||||||||||||||||
| [TestCase (ApplePlatform.TVOS, "tvossimulator-x64")] | ||||||||||||||||||||||
| [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64")] | ||||||||||||||||||||||
| [TestCase (ApplePlatform.MacOSX, "osx-x64")] | ||||||||||||||||||||||
| public void ComposerIcon (ApplePlatform platform, string runtimeIdentifiers) | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); | ||||||||||||||||||||||
| Configuration.IgnoreIfIgnoredPlatform (platform); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var project = "AppWithComposerIcon"; | ||||||||||||||||||||||
| var projectPath = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); | ||||||||||||||||||||||
| Clean (projectPath); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var properties = GetDefaultProperties (runtimeIdentifiers); | ||||||||||||||||||||||
| DotNet.Execute ("build", projectPath, properties); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var resourcesDirectory = GetResourcesDirectory (platform, appPath); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Verify that the raw .icon files are not in the app bundle as BundleResources | ||||||||||||||||||||||
| var iconJsonInBundle = Path.Combine (resourcesDirectory, "AppIcon.icon", "icon.json"); | ||||||||||||||||||||||
| Assert.That (iconJsonInBundle, Does.Not.Exist, "icon.json should not be in the app bundle as a raw BundleResource"); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var frontPngInBundle = Path.Combine (resourcesDirectory, "AppIcon.icon", "Assets", "front.png"); | ||||||||||||||||||||||
| Assert.That (frontPngInBundle, Does.Not.Exist, "front.png should not be in the app bundle as a raw BundleResource"); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var backPngInBundle = Path.Combine (resourcesDirectory, "AppIcon.icon", "Assets", "back.png"); | ||||||||||||||||||||||
| Assert.That (backPngInBundle, Does.Not.Exist, "back.png should not be in the app bundle as a raw BundleResource"); | ||||||||||||||||||||||
|
||||||||||||||||||||||
| Assert.That (backPngInBundle, Does.Not.Exist, "back.png should not be in the app bundle as a raw BundleResource"); | |
| Assert.That (backPngInBundle, Does.Not.Exist, "back.png should not be in the app bundle as a raw BundleResource"); | |
| // Verify that the compiled asset catalog exists in the app bundle | |
| string? assetsCarPath = null; | |
| foreach (var file in Directory.GetFiles (resourcesDirectory, "Assets.car", SearchOption.AllDirectories)) { | |
| assetsCarPath = file; | |
| break; | |
| } | |
| Assert.That (assetsCarPath, Is.Not.Null, "Compiled asset catalog (Assets.car) should exist in the app bundle"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppDelegate.csis not formatted consistently with the rest of the test apps in this repo (missing tab indentation and standard brace layout). Please reformat to match the existing style (seetests/dotnet/AppWithXCAssets/AppDelegate.csfor an in-repo example) so that future diffs remain readable and editors can apply the repo's.editorconfigsettings cleanly.