Get URL to a local file with SPM (Swift Package Manager)
问题 I am trying to read .json file in my unit test and running it within Swift Package. Using Xcode 11 and Swift 5.1 let path = Bundle.main.url(forResource: filename, withExtension: "json") // Path is nil I've been told that Swift packages don't have bundles any more. So how can I workaround this? Part of my Swift.package .testTarget( name: "ProjectTests", dependencies: [ .target(name: "Project") ], path: "Tests", exclude: [ "Folder/File.swift" ] ) 回答1: The solution we have found is FileManager .