danger / swift

⚠️ Stop saying "you forgot to …" in code review
https://danger.systems/swift/
MIT License
1.04k stars 136 forks source link

error: link command failed with exit code 1 #494

Closed briancordanyoung closed 2 years ago

briancordanyoung commented 2 years ago

I am new to danger. This is the first time I've tried to set up danger-swift. When I try to run locally on a PR it fails with the error below. I get the same error when running the homebrew installed danger-swift command or through swift build.

Does this look familiar to anyone?

My enviornment:

Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
Target: x86_64-apple-macosx11.0
Xcode: 13.2.1
macOS: Big Sur 11.6.1

Error

Starting Danger PR on danger/swift#440
error: link command failed with exit code 1 (use -v to see invocation)

ld: file not found: runner

ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/dz/8_0tx44j0196mybncxd0vygc0000gn/T/danger-response.json

Danger: ⅹ Failing the build, there is 1 fail.
## Failures
danger-swift` failed.
## Markdowns
### Log

```sh
error: link command failed with exit code 1 (use -v to see invocation)
ld: file not found: runner
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/dz/8_0tx44j0196mybncxd0vygc0000gn/T/danger-response.json
\ ```

Package.swift:

// swift-tools-version:5.5
import PackageDescription

let package = Package(
    name: "DangerSetup",
    dependencies: [
      .package(url: "https://github.com/danger/swift.git", from: "1.0.0")
    ],
    targets: [
        // This is just an arbitrary Swift file in our app, that has
        // no dependencies outside of Foundation, the dependencies section
        // ensures that the library for Danger gets build also.
        .target(
            name: "DangerSetup",
            dependencies: [.product(name: "Danger", package: "swift")], 
            path: "dummy", 
            sources: ["dummy.swift"]
        ),
    ]
)
f-meloni commented 2 years ago

Hey! Danger is now at version 3.12.3 https://github.com/danger/swift/releases/tag/3.12.3 I think a Package.swift like this should work

// swift-tools-version:5.5
import PackageDescription

let package = Package(
    name: "DangerSetup",
    products: [
      .library(name: "DangerDeps", type: .dynamic, targets: ["DangerSetup"]) // Danger needs to build and link this in order to work correcly
    ],
    dependencies: [
      .package(url: "https://github.com/danger/swift.git", from: "3.0.0")
    ],
    targets: [
        // This is just an arbitrary Swift file in our app, that has
        // no dependencies outside of Foundation, the dependencies section
        // ensures that the library for Danger gets build also.
        .target(
            name: "DangerSetup",
            dependencies: [.product(name: "Danger", package: "swift")], 
            path: "dummy", 
            sources: ["dummy.swift"]
        ),
    ]
)
briancordanyoung commented 2 years ago

Ahhhh. 🤦‍♂️ Thank you!