Fix custom menu bar icon packaging

This commit is contained in:
diyaa
2026-07-27 02:49:32 +02:00
parent 24efe36d8e
commit a078e8a4ec
5 changed files with 19 additions and 9 deletions
+1 -2
View File
@@ -7,8 +7,7 @@ let package = Package(
targets: [
.executableTarget(
name: "FchatiApp",
path: "Sources/FchatiApp",
resources: [.process("Resources")]
path: "Sources/FchatiApp"
),
.testTarget(
name: "FchatiAppTests",

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

+13 -2
View File
@@ -14,13 +14,24 @@ struct FchatiApp: App {
RootView()
.background(WindowConfigurator())
} label: {
Image("MenuBarIcon", bundle: .module)
.renderingMode(.original)
MenuBarIcon()
}
.menuBarExtraStyle(.window)
}
}
private struct MenuBarIcon: View {
var body: some View {
if let url = Bundle.main.url(forResource: "MenuBarIcon", withExtension: "png"),
let image = NSImage(contentsOf: url) {
Image(nsImage: image)
.renderingMode(.original)
} else {
Image(systemName: "message")
}
}
}
// Prevents the popover from closing when clicking outside.
private struct WindowConfigurator: NSViewRepresentable {
func makeNSView(context: Context) -> NSView {