Open source CapCut alternative.
TypeScript
fix(app): load resource bundles from Contents/Resources, not Bundle.module
David Le9b1b1c40d862
diff --git a/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swift b/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swiftindex 11a1e976..665d830c 100644--- a/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swift+++ b/apps/Donkey/Sources/Donkey/DonkeyLoginWindowController.swift@@ -1,4 +1,5 @@import AppKit+import DonkeyRuntimeimport SwiftUI@MainActor@@ -219,7 +220,7 @@ private struct DonkeyAppIconMark: View {}private static let image: NSImage = {- if let url = Bundle.module.url(forResource: "donkey-app-icon", withExtension: "png"),+ if let url = DonkeyResourceBundle.app?.url(forResource: "donkey-app-icon", withExtension: "png"),let image = NSImage(contentsOf: url) {return image}@@ -244,7 +245,7 @@ private struct GoogleContinueAsset: View {}private static let image: NSImage? = {- guard let url = Bundle.module.url(+ guard let url = DonkeyResourceBundle.app?.url(forResource: "google-continue-dark-rounded",withExtension: "png") else {diff --git a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swiftindex b869141e..b0a932ed 100644--- a/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift+++ b/apps/Donkey/Sources/Donkey/UserQueryOverlayModel.swift@@ -1773,7 +1773,7 @@ final class UserQueryOverlayModel: ObservableObject, UserQueryIntentSink {}private static func bundledTheme() -> UserQueryTheme {- guard let themeURL = Bundle.module.url(forResource: "theme", withExtension: "json"),+ guard let themeURL = DonkeyResourceBundle.app?.url(forResource: "theme", withExtension: "json"),let themeData = try? Data(contentsOf: themeURL),let themeConfig = try? JSONDecoder().decode(UserQueryThemeConfig.self, from: themeData),let theme = UserQueryTheme.fromConfig(themeConfig) else {diff --git a/apps/Donkey/Sources/DonkeyRuntime/BundledTools.swift b/apps/Donkey/Sources/DonkeyRuntime/BundledTools.swiftindex 8fa2c0be..3f007857 100644--- a/apps/Donkey/Sources/DonkeyRuntime/BundledTools.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/BundledTools.swift@@ -60,7 +60,7 @@ public enum BundledTools {/// Load the bundled manifest from the app's resources. Returns nil if it is missing or malformed.public static func loadManifest() -> Manifest? {- guard let url = Bundle.module.url(forResource: "bundled-tools", withExtension: "json"),+ guard let url = DonkeyResourceBundle.runtime?.url(forResource: "bundled-tools", withExtension: "json"),let data = try? Data(contentsOf: url)else { return nil }return try? JSONDecoder().decode(Manifest.self, from: data)diff --git a/apps/Donkey/Sources/DonkeyRuntime/DonkeyResourceBundle.swift b/apps/Donkey/Sources/DonkeyRuntime/DonkeyResourceBundle.swiftnew file mode 100644index 00000000..7d1cb1b4--- /dev/null+++ b/apps/Donkey/Sources/DonkeyRuntime/DonkeyResourceBundle.swift@@ -0,0 +1,34 @@+import Foundation++/// Locates a SwiftPM-generated resource bundle (`<Package>_<Target>.bundle`) inside a packaged,+/// code-signed macOS app.+///+/// The compiler-generated `Bundle.module` accessor only looks for the bundle at+/// `Bundle.main.bundleURL` — the `.app` root — and `fatalError`s when it is absent. A signed,+/// notarized app may not keep loose content at the bundle root (codesign rejects it as "unsealed+/// contents present in the bundle root"), so packaging stages these bundles under+/// `Contents/Resources`. Reaching for `Bundle.module` in the shipped app therefore traps on first+/// access. This resolver searches the signing-valid locations instead and returns nil rather than+/// crashing when a bundle is genuinely missing.+public enum DonkeyResourceBundle {+ /// The bundle named `name` (with or without the `.bundle` suffix), or nil if it cannot be found.+ /// Searches `Contents/Resources` first (the packaged app) and then the executable's own+ /// directory (the `swift build` / `swift run` layout), which together cover release and dev.+ public static func named(_ name: String) -> Bundle? {+ let fileName = name.hasSuffix(".bundle") ? name : name + ".bundle"+ let searchRoots = [Bundle.main.resourceURL, Bundle.main.bundleURL].compactMap { $0 }+ for root in searchRoots {+ if let bundle = Bundle(url: root.appendingPathComponent(fileName)) {+ return bundle+ }+ }+ return nil+ }++ /// The DonkeyRuntime target's own resource bundle (`bundled-tools.json`, the local-app finder+ /// profiles, and the BuiltInSkills tree).+ public static let runtime = named("Donkey_DonkeyRuntime")++ /// The Donkey executable target's resource bundle (app icon, sign-in art, theme).+ public static let app = named("Donkey_Donkey")+}diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalAppCatalogProfiles.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalAppCatalogProfiles.swiftindex 68480880..f2c96be0 100644--- a/apps/Donkey/Sources/DonkeyRuntime/LocalAppCatalogProfiles.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalAppCatalogProfiles.swift@@ -172,7 +172,7 @@ public struct LocalAppFinderProfileStore: Sendable {public static var defaultStore: LocalAppFinderProfileStore {let directory = defaultDirectoryURLreturn LocalAppFinderProfileStore(- seedCatalogURL: Bundle.module.url(+ seedCatalogURL: DonkeyResourceBundle.runtime?.url(forResource: "local-app-finder-profiles",withExtension: "json"),diff --git a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swift b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swiftindex 43af3536..1a4dfde7 100644--- a/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swift+++ b/apps/Donkey/Sources/DonkeyRuntime/LocalAppTaskSkillContext.swift@@ -4,7 +4,7 @@ import Foundationpublic enum BuiltInLocalAppSkillPacks {public static var rootURL: URL? {- Bundle.module.resourceURL?.appendingPathComponent("BuiltInSkills", isDirectory: true)+ DonkeyResourceBundle.runtime?.resourceURL?.appendingPathComponent("BuiltInSkills", isDirectory: true)}/// Built-in skills ship inside the bundle and never change at runtime, so discover them (which