swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
755 stars 54 forks source link

Extension doesn't automatically create launch.json or task.json upon opening SPM Package. #140

Closed kneekey23 closed 2 years ago

kneekey23 commented 2 years ago

I opened this package: https://github.com/awslabs/aws-sdk-swift/tree/main/TestLambdaSdk in VS Code and it did not automatically create the json files for me to launch a debugging session. I had to manually create them in order to debug this package. I did try restarting VS Code as well as disabling the extension and re-enabling it, however I did not try reloading window using the command palette. The package I opened loads a locally generated dependency.

adam-fowler commented 2 years ago

I can't replicate this because it is looking for a local package ~/Projects/Amplify/SwiftSDK/aws-sdk-swift/codegen/sdk-codegen/build/smithyprojections/sdk-codegen/s3.2006-03-01/swift-codegen which I don't have

If you view the Terminal you should see the results of a swift package resolve. Does that return any errors?

kneekey23 commented 2 years ago

No errors from running that command.

In order to locally generate that package, you can add a local.properties file to the root of the repo with the following:

onlyIncludeModels=s3.2006-03-01

and then run ./gradlew build -p codegen/sdk-codegen if you have gradle installed. You will also need this repo cloned as well: https://github.com/awslabs/smithy-swift and then you can include a path to it in the above local.properties file with this key:

compositeProjects=~/path/to/smithy-swift
adam-fowler commented 2 years ago

@kneekey23 can you see if you can build a repo that has the same issue, which doesn't require me to install gradle and generate a load of code

kneekey23 commented 2 years ago

yes will try to see if can resolve the dependency from a tag and experience the same issue. @adam-fowler

kneekey23 commented 2 years ago

changing the Pacakge.swift to use a tagged version of the sdk didn't fix the issue for me either.

import PackageDescription

let package = Package(
    name: "TestSdk",
    platforms: [.macOS(.v10_15)],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        //FIXME change this path to be non-localized
//        .package(name: "AWSS3", path: "~/Projects/Amplify/SwiftSDK/aws-sdk-swift/codegen/sdk-codegen/build/smithyprojections/sdk-codegen/s3.2006-03-01/swift-codegen"),
        .package(name: "AWSSwiftSDK", url: "https://github.com/awslabs/aws-sdk-swift", from: "0.2.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 this package depends on.
        .executableTarget(
            name: "TestSdk",
            dependencies: [
                .product(name: "AWSS3", package: "AWSSwiftSDK")
            ],
            path: "Sources/TestSdk",
            resources: [.copy("Resources")]),
        .testTarget(
            name: "TestSdkTests",
            dependencies: ["TestSdk"]),
    ]
)

I removed the .vscode folder that I manually created. and then tried to open this in vs code to see if the extension would create the files, it did not sadly :(

adam-fowler commented 2 years ago

Hey @kneekey23 I can't replicate this. I get launch configs generated. What version of swift are you using? Also which version of the extension do you have?

kneekey23 commented 2 years ago
 $ swift --version
swift-driver version: 1.26.21 Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
Target: x86_64-apple-macosx11.0

and version 0.2.0 of the extension. hm I wonder where I am going wrong. I do have other swift extensions installed, could they be conflicting? Should I try un-installing extensions to see if I can get it to work?

adam-fowler commented 2 years ago

Yes I’d remove the other swift extension. It might be disabling the SSWG version. I haven’t really looked into how the two extension work together.

On Thu, 17 Feb 2022 at 20:28, Nicki Stone @.***> wrote:

$ swift --version swift-driver version: 1.26.21 Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30) Target: x86_64-apple-macosx11.0

and version 0.2.0 of the extension. hm I wonder where I am going wrong. I do have other swift extensions installed, could they be conflicting? Should I try un-installing extensions to see if I can get it to work?

— Reply to this email directly, view it on GitHub https://github.com/swift-server/vscode-swift/issues/140#issuecomment-1043396917, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHSVJZ5QFNE4TXBU6IYGH3U3VLALANCNFSM5OVGEOBQ . You are receiving this because you were mentioned.Message ID: @.***>

adam-fowler commented 2 years ago

@kneekey23 are you still having issues with this Package? If so, I've a couple of questions

kneekey23 commented 2 years ago

yes I am. I tried removing all my other extensions and reloading it and it still didnt create the Tasks for me so I put them back.

I am guessing tho since you can't reproduce it's specific to my environment and I just need to figure out what about it is causing the issue.

adam-fowler commented 2 years ago

So your swift package describe output loads fine.

kneekey23 commented 2 years ago
Screen Shot 2022-03-01 at 11 09 17 AM

don't even see that? ran the command

kneekey23 commented 2 years ago
Screen Shot 2022-03-01 at 11 10 12 AM

Extension is installed

adam-fowler commented 2 years ago

@kneekey23 don't know if you have anytime to look at this, or if you have access to the project but I've added some extra error messaging to v0.5.0 when projects fail to load, which might give us an idea what is happening here

Jeffrey-de-Bruijn commented 2 years ago

I am experiencing the same problem.

0xTim commented 2 years ago

@Jeffrey-de-Bruijn is it a SwiftPM package? What version of Swift, VSCode, the extension, OS etc are you seeing it in? And can you provide the outlet from the extension as described https://github.com/swift-server/vscode-swift/issues/140#issuecomment-1054404467

adam-fowler commented 2 years ago

@Jeffrey-de-Bruijn is it a SwiftPM package? What version of Swift, VSCode, the extension, OS etc are you seeing it in? And can you provide the outlet from the extension as described #140 (comment)

Also does it have an executable. launch.json configs are only generated for executables? The extension does not create a tasks.json file

Jeffrey-de-Bruijn commented 2 years ago

I retract my comment, the problem turned out to be different.

adam-fowler commented 2 years ago

Closing this as it has never been reported since.