'swift-package: unable to add json to the package manifest

I just can't believe how unintuitive this process is and how complicated and convoluted #apple has made this normally simple process.

I've been spending the past 2 hours trying to add a test suite json file for some offline tests on my new package. I tried looking at the official apple way and another source on the internet but nothing works.

I'm just trying to add the following:

.target(
  name: "testJSON",
  resources: [
    .copy("test.json")
  ]
)

In the package manifest, which is below:

let package = Package( name: "SwiftHorizons", products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "SwiftHorizons", targets: ["SwiftHorizons"]), ], dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "SwiftHorizons", dependencies: []), .testTarget( name: "SwiftHorizonsTests", dependencies: ["SwiftHorizons"]), ] )

The file is in the sources folder at the moment. I tried putting it in the test folder, just the file itself, everywhere. None work, either give me an error message or none but when running the test suite, 0 tests are run.

This is the most stupid non work morning I have ever experienced with an apple product.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source