Package resources from a directory named with an extension

We're adding SPM support to a pre-existing project. We have PNG resources inside a foo.bundle.

But it appears that because the parent directory has an extension (e.g. ".bundle"), SPM doesn't copy (or "process") the PNG.

Is that expected?

The following test illustrates the problem. (derived from https://github.com/apple/swift-package-manager/blob/main/Tests/BuildTests/BuildPlanTests.swift#L2358)

    func testSwiftBundleAccessor() throws {
        // This has a Swift and ObjC target in the same package.
        let fs = InMemoryFileSystem(emptyFiles:
            "/PkgA/Sources/Foo/Foo.swift",
            "/PkgA/Sources/Foo/foo.txt",
            "/PkgA/Sources/Foo/sub.sub/subfoo.txt"
        )

        let diagnostics = DiagnosticsEngine()

        let graph = try loadPackageGraph(
            fs: fs,
            diagnostics: diagnostics,
            manifests: [
                Manifest.createManifest(
                    name: "PkgA",
                    path: "/PkgA",
                    url: "/PkgA",
                    v: .v5_3,
                    packageKind: .root,
                    targets: [
                        TargetDescription(
                            name: "Foo",
                            exclude: [ "sub.sub" ],
                            resources: [
                                .init(rule: .copy, path: "foo.txt"),
                                .init(rule: .process, path: "sub.sub/subfoo.txt"),
                            ]
                        ),
                    ]
                )
            ]
        )
        
        XCTAssertNoDiagnostics(diagnostics)

        let plan = try BuildPlan(
            buildParameters: mockBuildParameters(),
            graph: graph,
            diagnostics: diagnostics,
            fileSystem: fs
        )

        try testWithTemporaryDirectory { path in
            let yaml = path.appending(component: "debug.yaml")
            let llbuild = LLBuildManifestBuilder(plan)
            try llbuild.generateManifest(at: yaml)
            let contents = try localFileSystem.readFileContents(yaml).description
            XCTAssertMatch(contents, .contains("subfoo.txt"))
        }

    }
Terms of Service

Privacy Policy

Cookie Policy