I have tried solutions in this question: Generating resource_bundle_accessor, Type 'Bundle' has no member 'module' however it still does not work.
I am trying to access a simple JSON file in my unit tests. Here is my Package.swift:
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MyLibrary",
platforms: [.iOS("11.0"), .macOS(SupportedPlatform.MacOSVersion.v10_12)],
products: [
.library(name: "MyLibrary", targets: ["MyLibrary"])],
dependencies: [],
targets: [
.target(name: "MyLibrary", dependencies: []),
.testTarget(
name: "MyLibraryTests",
resources: [
.process("recommendations.json"
],
dependencies: ["MyLibrary"]
),
]
)
- I am using swift-tools 5.3
- I have added the
recommendations.json
to my package.swift.
I have closed and re-opened Xcode 5 times, yet still it does not create the Bundle.module
extension. Here is my file structure:
How can I access my JSON file in my unit tests?
resources: [.process("recommendations.json"]
into[resources: [.copy("recommendations.json"]]
and keep the file under the test target if this is where is should be. – Archiepiscopal