Search code examples
githubversionxcode11swift-package-manager

How to import a swift package that is using an older version of Swift tools?


I was trying to open a package, namely trying to import and run the swift folder under this repository.

When I Open->Package.swift file in XCode 11, it actually opened all the files under that directory. So, I thought I am one step close to running it.

But now I’m getting an error when I try to build it:

package at RepositoryName/swift’ is using Swift tools version 3.1.0 which is no longer supported; consider using ‘// swift-tools-version:5.1’ to specify the current tools version

So, I was wondering if there is a way to import and use this swift package that uses the older swift tools version?

Thanks


Solution

  • I solved this problem by recreating the package on XCode 11 with the same name and putting all files in the new package.

    XCode provided already the Package.swift file so I didn't touch it. The first line describes the Swift tools version.

    While adding it as a new package from File -> New -> Swift Package: I did set the "Add to" and "Group" to project name. And also I created the package inside this project folder.

    enter image description here

    I also added the package to target, selecting Target name -> General tab -> Frameworks, Libraries and Embedded Content -> + button to select it from the list. enter image description here

    Then within my project viewController I added

    import [PackageNameHere]
    

    Later on, I decided not to use it as a package, but in case anyone wants to do that this is how I did it.