danger / swift

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

Dangerfile cannot be compiled when using Xcode 16 #615

Open AndrewVebster opened 1 month ago

AndrewVebster commented 1 month ago

Hi 👋

When running danger-swift on a device with Xcode 16 the command fails with this error:

  7 | let danger = Danger()
    |              `- error: cannot call value of non-function type 'module<Danger>'

Running locally and on Bitrise - the error is the same. Using this command: swift run danger-swift local --cwd ../../ or this on CI swift run danger-swift ci --no-publish-check -f --cwd ../../

I believe my setup is pretty standard:

let danger = Danger()


⚠️  **The same setup works fine with Xcode 15.**

### Environment
- Xcode 16.0 beta 4 (16A5211f)
- Running locally on macOS 15.0 Beta (24A5298h)
- or running on Bitrise CI, the error is the same

### Other Info

My assumption is that `import Danger` doesn't work as expected. Because compiler doesn't see other types and functions. For example, `fail` function:

19 | fail(message: "Message", file: $0, line: 2) | `- error: cannot find 'fail' in scope


Or `DangerDSL`.

I tried installing danger-swift from `brew` instead of SMP when running on CI but the result is the same.

---

<details>
  <summary>Full command & result</summary>

swift run danger-swift local --cwd ../../ Building for debugging... [1/1] Write swift-version-39B54973F684ADAB.txt Build of product 'danger-swift' complete! (0.34s) (node:51429) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created) /var/folders/gj/tj6dnp8d1s71sp3sj5tlkh000000gn/T/danger/B52A4EC1-CE42-45E0-955E-3E50FB477100/_tmp_dangerfile.swift:7:14: error: cannot call value of non-function type 'module' 5 | import Foundation 6 | 7 | let danger = Danger() | `- error: cannot call value of non-function type 'module' 8 | 9 |

ERROR: Dangerfile eval failed at Dangerfile.swift ERROR: Could not get the results JSON file at /var/folders/gj/tj6dnp8d1s71sp3sj5tlkh000000gn/T/danger/B52A4EC1-CE42-45E0-955E-3E50FB477100/danger-response.json

Danger: ⅹ Failing the build, there is 1 fail.

Failures

danger-swift failed.

Markdowns

Log

/var/folders/gj/tj6dnp8d1s71sp3sj5tlkh000000gn/T/danger/B52A4EC1-CE42-45E0-955E-3E50FB477100/_tmp_dangerfile.swift:7:14: error: cannot call value of non-function type 'module' 5 | import Foundation 6 | 7 | let danger = Danger() | `- error: cannot call value of non-function type 'module' 8 | 9 | ERROR: Dangerfile eval failed at Dangerfile.swift ERROR: Could not get the results JSON file at /var/folders/gj/tj6dnp8d1s71sp3sj5tlkh000000gn/T/danger/B52A4EC1-CE42-45E0-955E-3E50FB477100/danger-response.json


</details>

<details>
  <summary>My Package.swift</summary>

// 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: "DangerDependencies", products: [ .library( name: "DangerDeps", type: .dynamic, targets: ["DangerDependencies"]), ], dependencies: [ .package(url: "https://github.com/danger/swift.git", from: "3.18.1"), ], targets: [ .target( name: "DangerDependencies", dependencies: [ .product(name: "Danger", package: "swift") ] ), ] )


</details>

<details>
  <summary>My Dangerfile.swift</summary>

import Danger import Foundation

let danger = Danger()


</details>
radude89 commented 1 week ago

I could reproduce the problem with Xcode 16 beta 6 (16A5230g). Do we have any updates about this issue or a possible workaround? Thank you!

marcomasser commented 6 days ago

I just ran into this issue with Xcode 16.0 RC 1 (16A242). Is there any update on this?

oronbz commented 4 days ago

Same here with RC

f-meloni commented 3 hours ago
let danger = Danger()
    |              `- error: cannot call value of non-function type 'module<Danger>'

Is it possible that it thinks you are referring to the Danger module and not the Danger function? Would Danger.Danger() work?

marcomasser commented 3 hours ago

Unfortunately, this doesn’t solve the issue:

$ swift run danger-swift pr https://github.com/…
Building for debugging...
[1/1] Write swift-version--6E9C300FE98E0E3E.txt
Build of product 'danger-swift' complete! (0.34s)
Starting Danger PR on …
/var/folders/vk/v4gx2v6x4972w9v5r1xggx000000gn/T/_tmp_dangerfile.swift:13:14: error: module 'Danger' has no member named 'Danger'
 11 | import Danger
 12 | 
 13 | let danger = Danger.Danger()
    |              `- error: module 'Danger' has no member named 'Danger'
 14 | let pullRequest = danger.github.pullRequest
 15 | let git = danger.git