Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>2</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<string>0.1.1</string>
<key>LSMinimumSystemVersion</key>
<string>14.0</string>
<key>LSUIElement</key>
Expand Down
21 changes: 14 additions & 7 deletions Sources/uppod/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,23 @@ enum Theme {
}
}

/// Loads a bundled PNG by name, trying the packaged `.app` bundle first, then the SwiftPM module
/// bundle (dev / `swift run`). Centralizes the dual-lookup that the UI used to repeat per call site.
/// Loads a bundled PNG by name. Release `.app` builds use `Bundle.main`; debug SwiftPM runs can
/// fall back to `Bundle.module`.
enum AppImage {
static func png(_ name: String) -> NSImage? {
for bundle in [Bundle.main, Bundle.module] {
if let url = bundle.url(forResource: name, withExtension: "png"),
let image = NSImage(contentsOf: url) {
return image
}
if let image = png(name, in: Bundle.main) {
return image
}
#if DEBUG
if let image = png(name, in: Bundle.module) {
return image
}
#endif
return nil
}

private static func png(_ name: String, in bundle: Bundle) -> NSImage? {
guard let url = bundle.url(forResource: name, withExtension: "png") else { return nil }
return NSImage(contentsOf: url)
}
}
Loading