Created
June 2, 2022 08:05
-
-
Save ctreffs/ad9d23e08d586cf75e4d1c3bb1b1061f to your computer and use it in GitHub Desktop.
Revisions
-
ctreffs created this gist
Jun 2, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ import class Foundation.Bundle private class BundleFinder {} extension Foundation.Bundle { /// Returns the resource bundle associated with the current Swift module. static var module: Bundle = { let bundleName = "<PACKAGENAME_MODULENAME>" 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 <PACKAGENAME_MODULENAME>") }() }