Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger swift package plugin as dependency of target #1813

Open
valentinvarbanov opened this issue Aug 7, 2024 · 1 comment
Open

Trigger swift package plugin as dependency of target #1813

valentinvarbanov opened this issue Aug 7, 2024 · 1 comment

Comments

@valentinvarbanov
Copy link

I want to include swift format into a custom swift package that runs every time the package is being build.

Here is the Package.swift file:

// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "test-format",
    products: [
        // Products define the executables and libraries a package produces, making them visible to other packages.
        .library(
            name: "test-format",
            targets: ["test-format"]),
    ],
    dependencies: [
//        .package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", from: "0.55.1"), // this works
        .package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.54.0"),
    ],
    targets: [
        // Targets are the basic building blocks of a package, defining a module or a test suite.
        // Targets can depend on other targets in this package and products from dependencies.
        .target(
            name: "test-format",
            plugins: [
//                .plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLintPlugins"), // this works
                .plugin(name: "SwiftFormatPlugin", package: "SwiftFormat"),
            ]),
        .testTarget(
            name: "test-formatTests",
            dependencies: ["test-format"]),
    ]
)

When I try and build the package from within Xcode (cmd + B), I get the following error (same for running tests):
Screenshot 2024-08-07 at 13 58 55

When attempting to build from command line I get a different error:
Screenshot 2024-08-07 at 14 01 10

Environment:

  • clean swift package created using Xcode 14.2

Goal:

@petomuro
Copy link

petomuro commented Aug 19, 2024

The same problem. Did anybody find a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants