Post

Replies

Boosts

Views

Activity

Reply to Detect if Bundle.module is available
I've found a solution for this. But this is just a workaround, so you should only use this until someone can find an official way to resolve this. import class Foundation.Bundle private class BundleFinder {} extension Foundation.Bundle { 		/// Returns the resource bundle associated with the current Swift module. 		static var current: Bundle = { 				// This is your `target.path` (located in your `Package.swift`) by replacing all the `/` by the `_`. 				let bundleName = "AAA_BBB" 				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 						} 				} 				 				return Bundle(for: BundleFinder.self) 		}() }
Jul ’20