Skip to content

Commit c9d831e

Browse files
committed
Fix a fatal error that app icon mask image assets could not be displayed properly
1 parent 863764e commit c9d831e

File tree

9 files changed

+45
-14
lines changed

9 files changed

+45
-14
lines changed

Sources/NSIcon/Extensions.swift

-11
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@ import SwiftUI
22

33
extension NSImage: @unchecked Sendable {}
44

5-
extension Image {
6-
init(packageResource name: String, ofType type: String) {
7-
guard let path = Bundle.module.path(forResource: name, ofType: type),
8-
let image = NSImage(contentsOfFile: path) else {
9-
self.init(name)
10-
return
11-
}
12-
self.init(nsImage: image)
13-
}
14-
}
15-
165
extension CGImage {
176
func containsTransparentPixels() async -> Bool {
187
guard let imageData = self.dataProvider?.data,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "AppIconMask.svg",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "AppIconMaskBorder.svg",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "MacAppIconMask.svg",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}

Sources/NSIcon/NSAsyncIcon.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public struct NSAsyncIcon: Icon {
4646
let shadowRadius = min(geometry.size.width, geometry.size.height) * (10/1024)
4747
image
4848
.resizable()
49-
.mask(Image(packageResource: "MacAppIconMask", ofType: "svg").resizable())
49+
.mask(Image("MacAppIconMask", bundle: .module).resizable())
5050
.aspectRatio(contentMode: .fit)
5151
.scaleEffect(824/1024)
5252
.shadow(color: .black.opacity(0.3), radius: shadowRadius, y: shadowRadius)
@@ -57,7 +57,7 @@ public struct NSAsyncIcon: Icon {
5757
case .iOS:
5858
image
5959
.resizable()
60-
.mask(Image(packageResource: "AppIconMask", ofType: "svg").resizable())
60+
.mask(Image("AppIconMask", bundle: .module).resizable())
6161
.aspectRatio(contentMode: .fit)
6262
}
6363
} else {
@@ -81,7 +81,7 @@ public struct NSAsyncIcon: Icon {
8181
}
8282
.overlay {
8383
if addMask && !containsTransparentPixel && platform == .iOS {
84-
Image(packageResource: "AppIconMaskBorder", ofType: "svg").resizable()
84+
Image("AppIconMaskBorder", bundle: .module).resizable()
8585
}
8686
}
8787
.task {

0 commit comments

Comments
 (0)