How to use Swift Packages in Visual Studio Code?

Viewed 239

I'm new with Swift and all this tools. I've tried to look for guides but they didn't help me. I wanna try to work with packages in VS code.So I decided to add a SwiftyJSON package. This is my Package.swift file:

import PackageDescription

let package = Package(
    name: "SwiftyJSON",
    dependencies: [
        .package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "4.0.0"),
    ]
)

And I got an error error: no such module 'PackageDescription' import PackageDescription For VS Code I use an extension Swift and package dependencies. It automatically detects a package but when I save my Package.swift file terminal gives me an error:

> Executing task: swift package resolve <

'swiftpackages': error: the manifest is missing a Swift tools version specification; 

consider prepending to the manifest '// swift-tools-version: 5.6' to 
specify the current Swift toolchain version as the lowest Swift version
supported by the project; 

if such a specification already exists, consider moving it to the top
of the manifest, or prepending it with '//' to help Swift Package
Manager find it

The terminal process "/opt/homebrew/bin/zsh '-c', 'swift package
resolve'" failed to launch (exit code: 1).

How I can add packages in VS code?

0 Answers
Related