danger / danger/swift

[Question] How to use Danger-Swift with plugins in a SwiftPM-based project?

Open
#358 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
1.1k
Forks
152
Avg merge
9h 54m
Merged PRs (30d)
2

Description

I'm working on a SwiftPM-based project, which means it already has a Package.swift file, and on the other hand, has no .xcodeproj or .xcworkspace file.

First, I tried to directly install Danger-Swift from brew, and it works well if there's no plugins. I just run `danger-swift edit`, and it creates a template Dangerfile.swift for me to work on, it's brilliant.

But then I tried to add some plugins like [Danger-Swift XcodeSummary](https://github.com/f-meloni/danger-swift-xcodesummary), and things started to be complicated.

I tried to directly add the plugin dependency in the xcode project which `danger-swift edit` created, and as you may expect, it doesn't work. I simply can't import the plugin.

Then I tried to install danger-swift as well as the plugins directly from the project's Package.swift file, but `swift run danger-swift edit` still can't work out the plugin's dependencies, I still can't import the plugin.

Lastly I tried to specify the source file directly from the `.target` instance in Package.swift file and open the Dangerfile.swift directly from the project Xcode. This time, Xcode tells me that I can import the plugin, but since the file name is Dangerfile.swift, not main.swift, I'm not allowed to directly write `message("something")` since it's not at the top level. And when I tried to run it with `swift run danger-swift local`, it still tells me that it can't import the plugin.

What should I do next?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.