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

protocol type 'PackageConfig' cannot be instantiated #30

Closed
piterwilson opened this issue Apr 16, 2020 · 4 comments
Closed

protocol type 'PackageConfig' cannot be instantiated #30

piterwilson opened this issue Apr 16, 2020 · 4 comments

Comments

@piterwilson
Copy link

Hello,

I'm having trouble getting the basic setup sample to work. I used the instructions here: https://github.com/shibapm/Komondor/blob/master/Documentation/with_swiftpm.md

// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "xxx",
    platforms: [
        .iOS(.v11),
        .macOS(.v10_13),
        .tvOS(.v11)
    ],
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "xxx",
            targets: ["xxx"])
    ],
    dependencies: [
        .package(url: "https://github.com/shibapm/Komondor.git", from: "1.0.0"),
        .package(url: "https://github.com/Realm/SwiftLint", from: "0.35.8")
    ],
    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: "xxx",
            dependencies: []),
        .testTarget(
            name: "xxxTests",
            dependencies: ["xxx"])
    ]
)

// The settings for the git hooks for our repo
#if canImport(PackageConfig)
    import PackageConfig

    let config = PackageConfig([
        "komondor": [
            "pre-commit": [
                "swift run swiftlint --path Sources --config .swiftlint.yml"
            ]
        ]
    ])
#endif

Which results in this error

Package.swift:39:18: error: protocol type 'PackageConfig' cannot be instantiated
    let config = PackageConfig([
                 ^~~~~~~~~~~~~
Package.swift:39:32: error: missing argument label 'from:' in call
    let config = PackageConfig([
                               ^
                               from: 
Package.swift:39:32: error: argument type '[String : [String : [String]]]' does not conform to expected type 'Decoder'
    let config = PackageConfig([
                               ^
Fatal error: Error raised at top level: PackageConfig.Error(reason: "Could not find a file at /var/folders/mf/jv01kf3d3nxdjtyp9dgnx9y80000gn/T/package-config - something went wrong with compilation step probably"): file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1100.8.280/swift/stdlib/public/core/ErrorType.swift, line 200
.git/hooks/pre-commit: line 21: 21516 Illegal instruction: 4  $komondor run pre-commit

May i ask what i could be doing wrong? or is this an issue with Komondor?

Thank you!

@piterwilson
Copy link
Author

Adding some extra information:

swift --version
Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)
Target: x86_64-apple-darwin19.3.0

@orta
Copy link
Member

orta commented Apr 16, 2020

think your timing was just off a little re: #29 which would have fixed the docs

@orta
Copy link
Member

orta commented Apr 16, 2020

or not, we just have more docs to update actually

@piterwilson
Copy link
Author

@orta thank you for the link to the issue. I can confirm that changing the configuration to the following does work:

// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "xxx",
    platforms: [
        .iOS(.v11),
        .macOS(.v10_13),
        .tvOS(.v11)
    ],
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "xxx",
            targets: ["xxx"])
    ],
    dependencies: [
        .package(url: "https://github.com/shibapm/Komondor.git", from: "1.0.0"),
        .package(url: "https://github.com/Realm/SwiftLint", from: "0.35.8")
    ],
    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: "xxx",
            dependencies: []),
        .testTarget(
            name: "xxxTests",
            dependencies: ["xxx"])
    ]
)

// The settings for the git hooks for our repo
#if canImport(PackageConfig)
    import PackageConfig

    let config = PackageConfiguration([
        "komondor": [
            "pre-commit": [
                "swift run swiftlint --path Sources --config .swiftlint.yml"
            ]
        ]
    ])

I can see that the import being called PackageConfig was probably the source of the confusion.

Thanks for the work you put into this package!

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