Swift packaged version of my library can't be used in other projects, xcode can't build

But the pod version works. So there's something I just can't figur eout. Any help would be gladly appreciated.

I've pasted my Package.d below. And the compiler error is:

error: unable to open dependencies file (/Users/aliak/Library/Developer/Xcode/DerivedData/Tasker-ccymmsbfnrczrcfuvnbmrlkjysbs/Build/Intermediates.noindex/Tasker.build/Debug/Tasker.build/Objects-normal/x86_64/task-PACKAGE:/Users/aliak/dev/Tasker::MAINGROUP::REF_1::REF_2.d)

When I open Package.swift with xcode, and hit Build, it succeeds but shows that compiler error anyway. And when I hit test it goes:

2020-06-03 21:51:30.224832+0200 xctest[32817:992992] The bundle “TaskerTests.xctest” couldn’t be loaded because its executable couldn’t be located. Try reinstalling the bundle.
Program ended with exit code: 1

Has anyone seen this before or has any hints on how to go about fixing this?

I also have a github issue for it here: https://github.com/aliak00/Tasker/issues/14

let package = Package(
    name: "Tasker",
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "Tasker",
            targets: ["Tasker"]),
    ],
    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 which this package depends on.
        .target(
            name: "Tasker",
            dependencies: [],
            path: "Sources"),
        .testTarget(
            name: "TaskerTests",
            dependencies: ["Tasker"],
            path: "Tests"),
    ]
)

You have both a task.swift and a Task.swift in separate subdirectories.

SwiftPM nests build intermediates in the same directory structure as the sources, which is why it works with swift build and swift test.

Xcode flattens everything and puts all intermediates in the same directory, leading to both a task.d and a Task.d in the same directory. On some file systems, the two filenames are identical, so they overwrite each other. On others, the two files can coexist, but Xcode’s indexing can’t seem to tell the difference.

The immediate workaround is to rename one of the two files.

You should also report the Xcode bug with its Feedback Assistant.

1 Like

Wow. Ok renaming one file fixed all the things! Thank you :bowing_man:
Feedback submitted as well.
Cheers!