Skip to content

Commit 5fc0f83

Browse files
committed
Add actual path of the icon to the resources so that it appears in the generated output
1 parent 53f87c1 commit 5fc0f83

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

XCode/PBXResourcesBuildPhase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
// Icon discovery methods
3434
- (NSString *) discoverAppIcon;
35+
- (NSString *) discoverAppIconPath;
3536
- (BOOL) copyAppIconToResources: (NSString *)iconFilename;
3637

3738
// Info.plist generation methods

XCode/PBXResourcesBuildPhase.m

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,19 @@ - (NSString *) discoverAppIcon
118118
return filename;
119119
}
120120

121+
- (NSString *) discoverAppIconPath
122+
{
123+
NSString *filename = [self discoverAppIcon];
124+
if (filename != nil)
125+
{
126+
NSString *productName = [_target name];
127+
NSString *assetsDir = [productName stringByAppendingPathComponent: @"Assets.xcassets"];
128+
NSString *appIconDir = [assetsDir stringByAppendingPathComponent: @"AppIcon.appiconset"];
129+
return [appIconDir stringByAppendingPathComponent: filename];
130+
}
131+
return nil;
132+
}
133+
121134
- (BOOL) copyAppIconToResources: (NSString *)iconFilename
122135
{
123136
if (iconFilename == nil)
@@ -530,13 +543,16 @@ - (BOOL) generate
530543

531544
// Discover app icon separately from Info.plist generation
532545
NSString *iconFile = [self discoverAppIcon];
546+
NSString *iconPath = [self discoverAppIconPath];
533547
xcputs([[NSString stringWithFormat: @"\t* Discovered app icon: %@", iconFile ? iconFile : @"(none)"] cString]);
534-
NSString *appIconPath = [iconFile stringByDeletingFirstPathComponent];
535-
[resources addObject: appIconPath];
536548

537-
// Copy app icon to resources if found
538-
if (iconFile != nil)
549+
// Add icon file to resources if found
550+
if (iconPath != nil)
539551
{
552+
xcputs([[NSString stringWithFormat: @"\t* Adding app icon to resources: %@", iconPath] cString]);
553+
[resources addObject: iconPath];
554+
555+
// Copy app icon to resources directory
540556
BOOL iconCopied = [self copyAppIconToResources: iconFile];
541557
if (iconCopied)
542558
{

0 commit comments

Comments
 (0)