Skip to content

Commit 075513b

Browse files
committed
Adaptive Icons on iOS
1 parent 3fee36b commit 075513b

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

src/lime/tools/AdaptiveIcon.hx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
package lime.tools;
22

3+
import sys.FileSystem;
4+
import haxe.io.Path;
5+
6+
/**
7+
This file is a wrapper to save to path and some properties about the AdaptiveIcon format from Android
8+
It is also used to store Apple's Icon Composer .icon file for iOS since its also a dynamic icon file
9+
**/
310
class AdaptiveIcon
411
{
512
public var path:String;
6-
public var hasRoundIcon:Bool;
13+
public var hasRoundIcon:Bool; // No use on iOS
14+
public var iconComposerFile:Bool; // No use on Android
715

816
public function new(path:String, hasRoundIcon:Bool)
917
{
1018
this.path = path;
11-
this.hasRoundIcon = hasRoundIcon;
19+
this.hasRoundIcon = hasRoundIcon;
20+
21+
// macOS files are actually folders with a file extension
22+
this.iconComposerFile = Path.extension(path) == "icon" && FileSystem.isDirectory(path);
1223
}
1324

1425
public function clone():AdaptiveIcon

templates/ios/template/{{app.file}}.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
792E75C91C6C876900D01DE1 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 792E75C81C6C876900D01DE1 /* CoreText.framework */; };
2828
7C1D3D2F27403D7800CFEBE5 /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7C1D3D2E27403D7800CFEBE5 /* CoreHaptics.framework */; };
2929
::if (IOS_LAUNCH_STORYBOARD != null)::D099CA9021A64C87003837AD /* ::IOS_LAUNCH_STORYBOARD::.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D099CA8F21A64C86003837AD /* ::IOS_LAUNCH_STORYBOARD::.storyboard */; };::end::
30+
::if (IOS_ADAPTIVE_ICON != null)::D4E8A1F09C3B47E2F6A5D0BC /* AppIcon.icon in Resources */ = {isa = PBXBuildFile; fileRef = A7F3C9201B8E4D6FA1C2B7D9 /* AppIcon.icon */; };::end::
3031
::ADDL_PBX_BUILD_FILE::
3132

3233
/* End PBXBuildFile section */
@@ -78,6 +79,7 @@
7879
792E75C81C6C876900D01DE1 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; };
7980
7C1D3D2E27403D7800CFEBE5 /* CoreHaptics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreHaptics.framework; path = System/Library/Frameworks/CoreHaptics.framework; sourceTree = SDKROOT; };
8081
::if (IOS_LAUNCH_STORYBOARD != null)::D099CA8F21A64C86003837AD /* ::IOS_LAUNCH_STORYBOARD::.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "::APP_FILE::/::IOS_LAUNCH_STORYBOARD::.storyboard"; sourceTree = "<group>"; };::end::
82+
::if (IOS_ADAPTIVE_ICON != null)::A7F3C9201B8E4D6FA1C2B7D9 /* AppIcon.icon */ = {isa = PBXFileReference; lastKnownFileType = file; path = "::APP_FILE::/AppIcon.icon"; sourceTree = "<group>"; };::end::
8183
::ADDL_PBX_FILE_REFERENCE::
8284

8385
8D1107310486CEB800E47090 /* ::APP_FILE::-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "::APP_FILE::/::APP_FILE::-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
@@ -178,6 +180,7 @@
178180
children = (
179181
4257533E1A5EFD8C004AA45B /* Images.xcassets */,
180182
::if (IOS_LAUNCH_STORYBOARD != null)::D099CA8F21A64C86003837AD /* ::IOS_LAUNCH_STORYBOARD::.storyboard */,::end::
183+
::if (IOS_ADAPTIVE_ICON != null)::A7F3C9201B8E4D6FA1C2B7D9 /* AppIcon.icon */,::end::
181184
8D1107310486CEB800E47090 /* ::APP_FILE::/::APP_FILE::-Info.plist */,
182185
1E2E17A5131E8B5D0048F3C7 /* ::APP_FILE::/assets */,
183186
::ADDL_PBX_RESOURCE_GROUP::
@@ -257,6 +260,7 @@
257260
files = (
258261
1E2E17AD131E8B5D0048F3C7 /* ::APP_FILE::/assets in Resources */,
259262
::if (IOS_LAUNCH_STORYBOARD != null)::D099CA9021A64C87003837AD /* ::IOS_LAUNCH_STORYBOARD::.storyboard in Resources */,::end::
263+
::if (IOS_ADAPTIVE_ICON != null)::D4E8A1F09C3B47E2F6A5D0BC /* AppIcon.icon in Ressources */,::end::
260264
4257533F1A5EFD8C004AA45B /* Images.xcassets in Resources */,
261265
::ADDL_PBX_RESOURCES_BUILD_PHASE::
262266
);
@@ -393,6 +397,7 @@
393397
buildSettings = {
394398
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
395399
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
400+
::if (IOS_ADAPTIVE_ICON != null)::ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;::end::
396401
::if (IOS_LAUNCH_STORYBOARD == null)::ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;::end::
397402
CODE_SIGN_ENTITLEMENTS = "::APP_FILE::/::APP_FILE::.entitlements";
398403
::if DEVELOPMENT_TEAM_ID::DEVELOPMENT_TEAM = ::DEVELOPMENT_TEAM_ID::;::end::
@@ -458,6 +463,7 @@
458463
buildSettings = {
459464
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
460465
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
466+
::if (IOS_ADAPTIVE_ICON != null)::ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;::end::
461467
::if (IOS_LAUNCH_STORYBOARD == null)::ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;::end::
462468
CODE_SIGN_ENTITLEMENTS = "::APP_FILE::/::APP_FILE::.entitlements";
463469
::if DEVELOPMENT_TEAM_ID::DEVELOPMENT_TEAM = ::DEVELOPMENT_TEAM_ID::;::end::

tools/platforms/IOSPlatform.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,11 @@ class IOSPlatform extends PlatformTarget
621621

622622
context.HAS_ICON = true;
623623

624+
if (project.adaptiveIcon != null && project.adaptiveIcon.iconComposerFile) {
625+
context.IOS_ADAPTIVE_ICON = project.adaptiveIcon.path;
626+
ProjectHelper.recursiveSmartCopyDirectory(project, project.adaptiveIcon.path, Path.combine(projectDirectory, "AppIcon.icon"), context);
627+
}
628+
624629
var iconPath = Path.combine(projectDirectory, "Images.xcassets/AppIcon.appiconset");
625630
System.mkdir(iconPath);
626631

tools/tools.n

830 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)