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

Error- no such module 'DangerSwiftCoverage' #19

Closed
doronkatz opened this issue Nov 26, 2019 · 11 comments
Closed

Error- no such module 'DangerSwiftCoverage' #19

doronkatz opened this issue Nov 26, 2019 · 11 comments

Comments

@doronkatz
Copy link

So i have an SPM project, in Swift 5.1. My Dangerfile.swift file has:

import Danger
import DangerSwiftCoverage

let danger = Danger()
Coverage.spmCoverage(minimumCoverage: 50)

I imported in my Package.swift as per instructions.

When I run the following, I get an error:

$ swift run danger-swift local
/var/folders/68/946ywfgx3jq3bwhy02std9tc0000gn/T/_tmp_dangerfile.swift:9:8: error: no such module 'DangerSwiftCoverage'
import DangerSwiftCoverage
       ^

ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/68/946ywfgx3jq3bwhy02std9tc0000gn/T/danger-response.json

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


```sh
/var/folders/68/946ywfgx3jq3bwhy02std9tc0000gn/T/_tmp_dangerfile.swift:9:8: error: no such module 'DangerSwiftCoverage'
import DangerSwiftCoverage
       ^
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/68/946ywfgx3jq3bwhy02std9tc0000gn/T/danger-response.json

@doronkatz
Copy link
Author

I also have a DangerDependencies in Sources, with Fake.swift.

@f-meloni
Copy link
Owner

Can you please show me your Package.swift?

@doronkatz
Copy link
Author

doronkatz commented Nov 26, 2019 via email

@doronkatz
Copy link
Author

doronkatz commented Nov 26, 2019 via email

@f-meloni
Copy link
Owner

If you change it like this it should work

Package(
    name: "SwiftRecommendations",
    platforms: [
        .iOS(.v13),
        .macOS(.v10_13),
        .tvOS(.v13)
    ],
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "SwiftRecommendations",
            targets: ["SwiftRecommendations"]),
        .library(name: "DangerDeps", type: .dynamic, targets: ["DangerDependencies"])
    ],
    dependencies: [
        .package(url: "https://github.com/apple/swift-log.git",
                 from: "1.0.0"),
        .package(url: "https://github.com/f-meloni/danger-swift-coverage",
                 from: "0.1.0")
    ],
    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 which this package depends on.
        .target(
            name: "SwiftRecommendations",
            dependencies: ["Logging"]),
        .testTarget(
            name: "SwiftRecommendationsTests",
            dependencies: ["SwiftRecommendations", "Logging"]),
        .target(name: "DangerDependencies", dependencies: ["DangerSwiftCoverage"])
    ]
)

@doronkatz
Copy link
Author

Thanks,

So then I get:

swift run danger-swift local     12:42:17 


Danger: ⅹ Failing the build, there is 1 fail.
## Failures
Failed to get the coverage - Error: The folder “codecov” doesn’t exist.

Am i meant to create a codecov folder as well?

@f-meloni
Copy link
Owner

are you using Xcode 11.2.1? in that case this plugin doesn't work with it yet #18

@doronkatz
Copy link
Author

Oh yes I am.. I see... Thanks ill hold off for that ticket to be resolved. Thanks !

@f-meloni
Copy link
Owner

Looking at your initial message you are using SPM, then #18 shouldn't affect you.
You should simply be able to run swift test --enable-code-coverage=true and then swift run danger-swift local should just work, unless there was a change on the SPM format as well

@doronkatz
Copy link
Author

doronkatz commented Nov 26, 2019 via email

@f-meloni
Copy link
Owner

No problem! closing, given is solved :)

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

No branches or pull requests

2 participants