Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Package Manager tools version for development snapshots

Tags:

I try to experiment with some of the new features of SPM that are recently implemented in swift 5.3. Like new binary dependencies and resources support. To test these new feature I went to swift.org and downloaded latest swift 5.3 development snapshot which is currently April 21, 2020. I installed it and selected as default toolchain in xcode preferences. However when I create new package with xcode it says swift-tools-version is 5.2. I tried to set it 5.3 like this // swift-tools-version:5.3. But xcode says

package at ... is using Swift tools version 5.3.0 but the installed version is 5.2.0

So my question is how can i test latest developments for spm from development snapshots?

like image 365
mustafa Avatar asked Apr 27 '20 10:04

mustafa


People also ask

What is Swift Tools version?

The Swift tools version declares the version of the PackageDescription library, the minimum version of the Swift tools and Swift language compatibility version to process the manifest, and the required minimum version of the Swift tools to use the Swift package.

How do I change the version of Swift tool?

Switching Swift Toolchain It can be done using Xcode, Go to Xcode->Preferences->Components-> Toolchains section and Select the Swift. 3.1. 1 snapshot, this will set the new Swift version for the local Xcode.

Does Swift have a package manager?

The Swift Package Manager is a tool for managing the distribution of Swift code. It's integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. The Package Manager is included in Swift 3.0 and above.

What is SPM in Swift?

Also known as SwiftPM or SPM, it's been included in Swift since version 3.0. From the official repository: The Swift Package Manager is a tool for managing distribution of source code, aimed at making it easy to share your code and reuse others' code.


Video Answer


2 Answers

In Package.swift

// swift-tools-version:5.3 

Although it's a comment and it should be ignored, it's not! change it to :

// swift-tools-version:5.2 

Sometimes you need to delete .build and .swiftpm directories (that are hiddent by default) too.

Note

Don't forget to close and reopen the project after the changes.

like image 160
Mojtaba Hosseini Avatar answered Sep 20 '22 20:09

Mojtaba Hosseini


To use the new toolchain from the command line, you first need to export it: $ export TOOLCHAINS=swift.

Then you can check which version you use with: $ swift --version

See apple documentation on managing multiple swift environment and choosing a swift version here.

like image 28
user3546621 Avatar answered Sep 19 '22 20:09

user3546621