-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBundleFinder.swift
More file actions
39 lines (31 loc) · 1.18 KB
/
BundleFinder.swift
File metadata and controls
39 lines (31 loc) · 1.18 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
34
35
36
37
38
39
//
// BundleFinder.swift
// LocalizedDeviceModel
//
// Created by Benoit Deldicque on 30/05/2021.
//
import Foundation
import class Foundation.Bundle
// This file will help building package using a scheme for Swift Package Index.
private class BundleFinder {}
extension Foundation.Bundle {
/// Returns the resource bundle associated with the current Swift module.
static var module: Bundle = {
let bundleName = "LocalizedDeviceModel_LocalizedDeviceModel"
let candidates = [
// Bundle should be present here when the package is linked into an App.
Bundle.main.resourceURL,
// Bundle should be present here when the package is linked into a framework.
Bundle(for: BundleFinder.self).resourceURL,
// For command-line tools.
Bundle.main.bundleURL,
]
for candidate in candidates {
let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
return bundle
}
}
fatalError("Unable to find bundle named LocalizedDeviceModel_LocalizedDeviceModel")
}()
}