forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBundleExtension.swift
More file actions
33 lines (28 loc) · 1.22 KB
/
Copy pathBundleExtension.swift
File metadata and controls
33 lines (28 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import Foundation
// Custom Bundle accessor for our resource bundle.
// This is necessary because:
// 1. Swift PM generates code that looks for the bundle at the app root
// 2. macOS code signing doesn't allow files at the app root (outside Contents/)
// 3. We need the bundle in Contents/Resources/ for proper code signing
// Note: We use "resourceBundle" instead of "module" to avoid conflicts with Swift PM's generated accessor
extension Foundation.Bundle {
static let resourceBundle: Bundle = {
let bundleName = "Omi Computer_Omi Computer"
// For macOS app bundles, look in Contents/Resources/
let resourcesPath = Bundle.main.bundleURL
.appendingPathComponent("Contents/Resources")
.appendingPathComponent("\(bundleName).bundle")
.path
// Fallback: direct child of main bundle (for development builds)
let mainPath = Bundle.main.bundleURL
.appendingPathComponent("\(bundleName).bundle")
.path
if let bundle = Bundle(path: resourcesPath) {
return bundle
} else if let bundle = Bundle(path: mainPath) {
return bundle
}
// If none found, crash with helpful message
Swift.fatalError("could not load resource bundle: tried \(resourcesPath), \(mainPath)")
}()
}