Open tibo opened 3 years ago
I got the same error. I changed the target from iPhone to Mac and the build was successful.
thanks for your answer @rseki-sonix how is your Danger/danger-swift installed? The project is actually a Swift Package so I don't have any xcodeproj to update.
Hi @tibo,
I see you are using danger-swift
which makes me assume you installed it via brew, if so, which version are you using?
Hi @f-meloni indeed installed with homebrew, on both machines, same versions:
$ danger --version
10.1.0
$ danger-swift --version
3.11.1
That is the last version released, I've added this change in that release which I thought would fix it, https://github.com/danger/swift/pull/462 but unfortunately I don't have an M1 Mac, so was just a try :(
Once again the weird thing is that is working on my Macbook but not on the Mac Mini. the only difference is that I tried to install it on the Mac Mini few weeks ago, and it was a fresh install on the Macbook.
I have my hands on those macs until tuesday (then I have to give them back to the company I'm leaving) Let me know if I can try something else to provide more debug
the only difference is that I tried to install it on the Mac Mini few weeks ago, and it was a fresh install on the Macbook.
Can you please try to unistall it in the mac mini and reinstall it as a fresh install?
I just did brew uninstall danger-swift danger-js
followed by brew install danger-swift
-> same result.
Last week I tried to uninstalled homebrew, remove the homebrew folder and do a fresh install of homebrew... but it didn't solved my problem either.
I've got the same issue locally on an M1 13":
avanderlee@Antoines-MBP Diagnostics % danger-swift pr https://github.com/WeTransfer/Diagnostics/pull/91
Starting Danger PR on WeTransfer/Diagnostics#91
/var/folders/85/n4sg5zw90975dnnxj09f2ynm0000gn/T/_tmp_dangerfile.swift:1:8: error: module 'Danger' was created for incompatible target arm64-apple-macosx10.10: /opt/homebrew/lib/danger/Danger.swiftmodule
import Danger
^
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/85/n4sg5zw90975dnnxj09f2ynm0000gn/T/danger-response.json
Danger: ⅹ Failing the build, there is 1 fail.
## Failures
`danger-swift` failed.
## Markdowns
### Log
```sh
/var/folders/85/n4sg5zw90975dnnxj09f2ynm0000gn/T/_tmp_dangerfile.swift:1:8: error: module 'Danger' was created for incompatible target arm64-apple-macosx10.10: /opt/homebrew/lib/danger/Danger.swiftmodule
import Danger
^
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/85/n4sg5zw90975dnnxj09f2ynm0000gn/T/danger-response.json
Then I realized I had an old version running:
avanderlee@Antoines-MBP Diagnostics % danger-swift --version
3.11.0
While I had the latest already locally. So I force linked it instead:
avanderlee@Antoines-MBP Diagnostics % brew link --overwrite danger-swift
Linking /opt/homebrew/Cellar/danger-swift/3.12.0... 24 symlinks created.
Resulting in the correct version:
avanderlee@Antoines-MBP Diagnostics % danger-swift --version
3.12.0
Yet, same result:
avanderlee@Antoines-MBP Diagnostics % danger-swift pr https://github.com/WeTransfer/Diagnostics/pull/91
Starting Danger PR on WeTransfer/Diagnostics#91
/var/folders/85/n4sg5zw90975dnnxj09f2ynm0000gn/T/_tmp_dangerfile.swift:1:8: error: module 'Danger' was created for incompatible target arm64-apple-macosx10.10: /opt/homebrew/lib/danger/Danger.swiftmodule
import Danger
^
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/85/n4sg5zw90975dnnxj09f2ynm0000gn/T/danger-response.json
Danger: ⅹ Failing the build, there is 1 fail.
## Failures
`danger-swift` failed.
## Markdowns
### Log
```sh
/var/folders/85/n4sg5zw90975dnnxj09f2ynm0000gn/T/_tmp_dangerfile.swift:1:8: error: module 'Danger' was created for incompatible target arm64-apple-macosx10.10: /opt/homebrew/lib/danger/Danger.swiftmodule
import Danger
^
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/85/n4sg5zw90975dnnxj09f2ynm0000gn/T/danger-response.json
Decided to run Danger-swift locally instead:
swift run danger-swift pr https://github.com/WeTransfer/Diagnostics/pull/91 --cwd ../../WeTransfer/Diagnostics
But same result
@AvdLee I see you posted a case that uses swift run danger-swift
and that relies on Danger to build the package to build the dependencies https://github.com/danger/swift/blob/master/Sources/RunnerLib/SPMDanger.swift#L34
I wonder if that is the issue, it should specify the arch when requests to swift to build it 🤔 Where you running the danger-swift brew with the same project, because if I remember correctly that still prefers the SPM library if available so that might be the issue.
Where you running the danger-swift brew with the same project
Yes, I tried both running through the brew install as well through a manually build SPM package.
What can I do to progress in this issue?
Same here. I'm installing DangerSwift with Package.swift, and tried both swift run danger-swift edit
and xcrun -sdk macosx swift run danger-swift edit
, both produces Module 'Danger' was created for incompatible target arm64-apple-macosx10.10: /path/to/.build/debug/Danger.swiftmodule
error, and in addition I also have got a ←this error was because one of my plugins has been out-dated.Library not found for -lDangerDepsProduct
error
Hardware: M1 Max MacBook Pro 14'' OS: macOS 12.1 Swift: 5.5.2 Xcode: 13.2.0
Edited:
I've found that under my environment swift run danger-swift pr url/to/pr
actually works, and swift run danger-swift edit
also can build successfully, but weirdly errors will be shown after the successful build.
I also tried to install Danger Swift using SwiftPM, but no luck here. swift build
runs fine and running swift run danger-swift --help
prints the help just fine, but things like swift run danger-swift edit
or swift run danger-swift pr https://github.com/danger/swift/pull/146
show the error mentioned above:
$ swift run danger-swift pr https://github.com/danger/swift/pull/146
[0/0] Build complete!
Starting Danger PR on danger/swift#146
You don't have a DANGER_GITHUB_API_TOKEN set up, this is optional, but TBH, you want to do this
Check out: http://danger.systems/js/guides/the_dangerfile.html#working-on-your-dangerfile
ERROR: Could not find a libDanger to link against at any of: [".build/debug", ".build/x86_64-unknown-linux/debug", ".build/release", "/usr/local/lib/danger", "/opt/homebrew/lib/danger"]
Or via Homebrew, or Marathon
Danger: ⅹ Failing the build, there is 1 fail.
## Failures
danger-swift` failed.
## Markdowns
### Log
sh
ERROR: Could not find a libDanger to link against at any of: [".build/debug", ".build/x86_64-unknown-linux/debug", ".build/release", "/usr/local/lib/danger", "/opt/homebrew/lib/danger"]
Or via Homebrew, or Marathon
I’m running this on an MacBook Pro with M1 Pro, macOS 12.1, Xcode 13.2 (Swift 5.5.2).
Note that unsurprisingly, find .build -name "libDanger*"
finds nothing, which I guess is the underlying problem.
@marcomasser can I please see your Package.swift?
Of course!
// swift-tools-version:5.5
import PackageDescription
let package = Package(
name: "MyApp",
dependencies: [
.package(url: "https://github.com/danger/swift.git", from: "3.12.3")
],
targets: [
.target(
name: "MyApp",
dependencies: [.product(name: "Danger", package: "swift")],
path: "Danger",
sources: ["DummyForDanger.swift"]
)
]
)
I have a tiny bit of progress to report:
I tried this with a completely fresh Xcode project, added a Package.swift
file with the above contents and did a swift build
successfully, then:
$ swift run danger-swift edit
[41/41] Build complete!
ERROR: Could not find a libDanger to link against at any of: [".build/debug", ".build/x86_64-unknown-linux/debug", ".build/release", "/usr/local/lib/danger", "/opt/homebrew/lib/danger"]
Or via Homebrew, or Marathon
Since we know that libDanger.dylib
is missing, I opened up .build/checkouts/swift/Package.swift
(the Danger Swift checkout) and modified line 10 like this, i.e. I explicitly requested a dynamic library:
- .library(name: "Danger", targets: ["Danger"]),
+ .library(name: "Danger", type: .dynamic, targets: ["Danger"]),
Then, I did another swift build
and now the library is here:
$ find .build -name "libDanger*"
.build/arm64-apple-macosx/debug/libDanger.dylib
🥳
I suspect that this is an issue I already encountered a while back where SPM and Xcode make different decisions on whether to build a dynamic or a static library. Requesting a dynamic library explicitly seems to fix this. I guess this option was added to SPM after Danger Swift was started? But I don’t know.
Also, swift run danger-swift edit
now works properly 🥳
But when I try to actually run Danger Swift against a real PR, I’m stuck at the same error that is shown in Xcode:
$ swift run danger-swift pr https://github.com/danger/swift/pull/146
[0/0] Build complete!
Starting Danger PR on danger/swift#146
You don't have a DANGER_GITHUB_API_TOKEN set up, this is optional, but TBH, you want to do this
Check out: http://danger.systems/js/guides/the_dangerfile.html#working-on-your-dangerfile
/var/folders/vk/v4gx2v6x4972w9v5r1xggx000000gn/T/_tmp_dangerfile.swift:1:8: error: module 'Danger' was created for incompatible target arm64-apple-macosx10.10: /Users/marco/Development/This is a Test/.build/debug/Danger.swiftmodule
import Danger
^
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/vk/v4gx2v6x4972w9v5r1xggx000000gn/T/danger-response.json
Danger: ⅹ Failing the build, there is 1 fail.
## Failures
danger-swift` failed.
## Markdowns
### Log
sh
/var/folders/vk/v4gx2v6x4972w9v5r1xggx000000gn/T/_tmp_dangerfile.swift:1:8: error: module 'Danger' was created for incompatible target arm64-apple-macosx10.10: /Users/marco/Development/This is a Test/.build/debug/Danger.swiftmodule
import Danger
^
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/vk/v4gx2v6x4972w9v5r1xggx000000gn/T/danger-response.json
The platform triple arm64-apple-macosx10.10
seems suspicious since I’m on macOS 12.1, so I edited my Package.swift
file to explicitly mention the platform (I added platforms: [.macOS(.v12)],
before the dependencies) and I also edited .build/checkouts/swift/Package.swift
and added that (I also had to bump the swift-tools-version
at the top to 5.5
for that). I still get the same error as before, but with the changed version number in the platform triple:
$ swift run danger-swift pr https://github.com/danger/swift/pull/146
[…]
/var/folders/vk/v4gx2v6x4972w9v5r1xggx000000gn/T/_tmp_dangerfile.swift:1:8: error: module 'Danger' was created for incompatible target arm64-apple-macosx12.0: /Users/marco/Development/This is a Test/.build/debug/Danger.swiftmodule
[…]
… which is just weird and I don’t know what to do now.
Just for clarification: Between steps, I manually deleted everything in .build/
except checkouts
, repositories
, and workspace-state.json
.
Also: I also tried using platforms: [.macOS("12.1")]
instead of platforms: [.macOS(.v12)]
with the same result (except the changed platform triple arm64-apple-macosx12.1
in the error output, of course).
Edit: Just for verification, here’s proof that arm64-apple-macosx12.0
is the target triple needed for my machine:
$ swiftc -print-target-info
{
"compilerVersion": "Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)",
"target": {
"triple": "arm64-apple-macosx12.0",
"unversionedTriple": "arm64-apple-macosx",
"moduleTriple": "arm64-apple-macos",
"swiftRuntimeCompatibilityVersion": "5.5",
"compatibilityLibraries": [ ],
"librariesRequireRPath": false
},
"paths": {
"runtimeLibraryPaths": [
"/Applications/Xcode-13.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx",
"/usr/lib/swift"
],
"runtimeLibraryImportPaths": [
"/Applications/Xcode-13.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx"
],
"runtimeResourcePath": "/Applications/Xcode-13.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift"
}
}
I just realized that when the problem seems to be that arm64-apple-macosx12.0
is considered to be incompatible, that could mean that whatever is trying to load libDanger.dylib
might not be running as arm64 – and file /opt/homebrew/bin/danger
really does indicate that the binary is for x86_64!
So, running Danger Swift using this command works for me:
swift run -Xswiftc -target -Xswiftc x86_64-apple-macos12.0 danger-swift pr https://github.com/danger/swift/pull/146
Alternatively, it also works without the -Xswiftc
flags if swiftSettings: [.unsafeFlags(["-target x86_64-apple-macos12.0"])]
is added to the target definition of the project’s Package.swift
file (although this leads to swift build
logging an error about the flag not being recognized after the build has completed 🤷♂️).
Note that both approaches still require explicitly declaring the library to be dynamic in .build/checkouts/swift/Package.swift
(the Danger Swift checkout):
- .library(name: "Danger", targets: ["Danger"]),
+ .library(name: "Danger", type: .dynamic, targets: ["Danger"]),
Can you please try to change your Package to this?
// swift-tools-version:5.5
import PackageDescription
let package = Package(
name: "MyApp",
products: [
.library(name: "DangerDeps", type: .dynamic, targets: ["MyApp"])
],
dependencies: [
.package(url: "https://github.com/danger/swift.git", from: "3.12.3")
],
targets: [
.target(
name: "MyApp",
dependencies: [.product(name: "Danger", package: "swift")],
path: "Danger",
sources: ["DummyForDanger.swift"]
)
]
)
Danger knows that has to build and link DangerDeps
if present.
Its presence in fact makes Danger go in the "SPM mode", and it should just work with swift run danger-swift
without requiring you to do any additional action.
This is how Danger is configured in this repo as well https://github.com/danger/swift/blob/master/Package.swift#L12
Nice, this seems to work fine. Thank you very much for your help!
Thanks for comments. it' works fine too.
My solution is
// swift-tools-version:5.5
import PackageDescription
let package = Package( name: "MyApp", defaultLocalization: "en", products: [ .library(name: "DangerDeps", type: .dynamic, targets: ["MyApp"]) ], dependencies: [ .package(url: "https://github.com/danger/swift.git", from: "3.12.3") ], targets: [ .target( name: "MyApp", dependencies: [.product(name: "Danger", package: "swift")], path: "", sources: ["DummyForDanger.swift"] ) ] )
2. run danger-swift edit
$ swift build $ swift run danger-swift edit
3. It's working
$ swift run pr ...
It seems to be a bug on Swift(arm64) compiler or linker. I tried to re-install with x86_64 architecture explicitly ( #521 ), and it works fine in M1 mac.
I'm sorry but https://github.com/danger/swift/issues/464#issuecomment-1139383319 was not correct and there seems to be something wrong in installing or executing _tmp_dangerfile.swift.
I tried this.
import Danger
print("Hello, Danger!")
let danger = Danger()
- Run `swift build --disable-sandbox --arch arm64 -c release` in Danger-Swift repo
- Run `swift -L /path/to/danger/swift/.build/release -I /path/to/danger/swift/.build/release -lDanger Dangerfile.swift`
Then output was
```sh
Hello, Danger!
ERROR: To execute Danger run danger-swift ci, danger-swift pr or danger-swift local on your terminal
and it seems to be succedded to build.
I tried to dump architecture in main.swift like
do {
let proc = Process()
proc.launchPath = "/usr/bin/arch"
let output = Pipe()
proc.standardOutput = output
proc.launch()
proc.waitUntilExit()
let arch = String(data: output.fileHandleForReading.availableData, encoding: .utf8)!
logger.logInfo("main.swift:L\(#line)", "Running architecture: \(arch)\n")
}
and output is below
$ swift build --disable-sandbox
Build complete! (9.72s)
$ ./.build/debug/danger-swift pr https://github.com/danger/swift/pull/440
main.swift:L47 Running architecture: arm64 <--- ✅ expected
Starting Danger PR on danger/swift#440
/var/folders/68/gc739x291c5g99fjky0_76x80000gq/T/_tmp_dangerfile.swift:1:8: error: module 'Danger' was created for incompatible target arm64-apple-macosx10.10: /path/to/danger/swift/.build/debug/Danger.swiftmodule
import Danger
^
main.swift:L47 Running architecture: i386 <------ ⛔️ Why????????
ERROR: Dangerfile eval failed at Dangerfile.swift
Danger: ⅹ Failing the build, there is 1 fail.
## Failures
`danger-swift` failed.
## Markdowns
### Log
```sh
/var/folders/68/gc739x291c5g99fjky0_76x80000gq/T/_tmp_dangerfile.swift:1:8: error: module 'Danger' was created for incompatible target arm64-apple-macosx10.10: /path/to/danger/swift/.build/debug/Danger.swiftmodule
import Danger
^
danger-results://var/folders/68/gc739x291c5g99fjky0_76x80000gq/T/danger-response.json
main.swift:L47 Running architecture: i386
ERROR: Dangerfile eval failed at Dangerfile.swift
I guessed that second dump is when call-back from danger-js, and found out that the `danger-js` binary is built on x86_64.
```sh
$ lipo -info /opt/homebrew/bin/danger
Non-fat file: /opt/homebrew/bin/danger is architecture: x86_64
There would be 2 possible solutions.
Hey i wanted to follow up on this issue
i am using the Latest Version of Danger swift 3.13.0 installed via SPM
i have tried both swift run -Xswiftc -target -Xswiftc x86_64-apple-macos12.0 danger-swift edit and swift run danger-swift edit
and according to this comment: https://github.com/danger/swift/issues/464#issuecomment-1006019283 this should have been resolved right ?
i am still getting this complier error.
My Package.swift file
/ swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "DesignComponentLibrary",
platforms: [.macOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(name: "DangerDeps", type: .dynamic, targets: ["DangerDependencies"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/danger/swift.git", from: "3.13.0"),
.package(url: "https://github.com/hebertialmeida/MarkdownSyntax", from: "1.0.0"),
.package(url: "https://github.com/Subito-it/CachiKit", branch: "master"),
],
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 this package depends on.,
.target(
name: "DangerDependencies",
dependencies: [
.product(name: "Danger", package: "swift"),
"CachiKit",
"MarkdownSyntax",
],
path: "Tools/",
sources: ["dummy.swift"]),
]
)
The Danger & Package.swift file is located in a sub directory root -> Scripts -> Danger i am running it with -cwd ../
As you can see i have explicitly mentioned the platforms as macOS 12 + so i am not sure why its still building for mac os 10.10
could someone please help me figure out what i am doing wrong ?
Any updates on this issue? 😞
This is an issue on Danger-JS (https://github.com/danger/danger-js/issues/1282). It is needed to build danger-js binary on arm64 architecture, but we don't know how to build it.
I don’t know if that helps you at all or not, but what @f-meloni wrote in https://github.com/danger/swift/issues/464#issuecomment-1006019283 is exactly how we use Danger-Swift on both Intel and Apple Silicon Macs and it works absolutely fine. We install Danger-JS (and SwiftLint) via Homebrew using brew install danger/tap/danger-js swiftlint
. This installs Intel variants of them even on Apple Silicon but everything works fine in our setup.
A couple more details:
Danger/
:
Danger/Danger/DummyForDanger.swift
is just this:
Danger/Package.swift
is as described above:
[FYI] Installing danger-js via Homebrew has been fully-compatible with arm64 since 11.2.1! ref: https://github.com/danger/danger-js/pull/1342
I updated danger-js to the latest version and tried running danger-swift with some PR. It works!
$ brew upgrade danger-js
$ danger-swift pr https://github.com/danger/swift/pull/565 --danger-js-path /opt/homebrew/bin/danger
Hello,
I'm trying to move the Danger step of our CI to a Mac Mini M1 for efficiency (pulling the docker image takes too much time for a short CI) and it doesn't work as expected:
I've got this issue on the Mac Mini but it's running without any issue on my Macbook (also M1) and I cannot find why. I already tried to re-install danger-js and danger-swift. I've cleaned the homebrew install and rebuild it. still the same.
Any idea? Thanks