Transfer swift packages to another project

I have a project which contains ~10 swift packages.

Now I want to create another project with the same packages set. Copying manually is not convenient because there are a lot of packages and xcode doesn’t allow to copy their urls in UI.

There is a Package.resolved file but it contains a flat array where swift packages are mixed with their dependencies.

There is also section /* Begin XCRemoteSwiftPackageReference section */ inside project.pbxproj which contains exactly all the necessary packages but you can’t just take them and move to another project.

Are there more convenient ways to do that? For example if you use cocoapods you just copy contents of podfile.

  • “For example if you use cocoapods you just copy contents of podfile.” How about copying Package.swift. That’s the counterpart of the Podfile in SPM.

    – 

  • packages as in local packages?

    – 

  • “which contains exactly all the necessary packages but you can’t just take them and move to another project” I think you can. It’s just really cumbersome to do, because the sections you need to copy are scattered in several places.

    – 

  • You can also try out tools like mod-pbxproj to write a script that copies packages from one project to another.

    – 

  • 1

    If you plan on reusing the same setup over several packages why not create your own package with all the packages? Then you can have a local or published package with all you need.

    – 

Leave a Comment