Package Manager Dependency Mirroring within the consuming App

I've been exploring the package manager dependency mirroring option as described here:

...but might need some help with clarifying expectations around this feature. When I've applied this to one of my own packages via swift package config set-mirror, I've confirmed that the mirroring works as expected, I see my dependencies being fetched from the mirrored locations that are specified in the .swiftpm/config file for that package.

However, I was also hoping this mirroring feature could also apply to the app that's consuming my package. When I add my package to an app as a dependency, none of the mirroring seems to be applied anymore, the additional dependencies that my package brings into the consuming app are still being fetched from the original public GitHub location.

Is it expected that the dependency mirroring would only apply to a project with it's own Package.swift file, and shouldn't be expected to apply to the consuming app that's added the package via Xcode?

Yah, it's expected that the mirror file is only used by the root package or a top level project or workspace in Xcode, but any mirror configurations are not considered if that package is used as a dependency.

This could have been spelled out better in the proposal, but basically the purpose is that dependencies can't "mess with" any dependencies elsewhere in the graph.

Thanks for clarifying, and I can appreciate how it would open the door to different dependencies bringing in conflicting mirrors for the same package, which would make it difficult for the top-level project to decide where to fetch from.

One thing I am hoping you can expand on a bit more... when you say " or a top level project or workspace in Xcode" ... if my consuming app doesn't actually have it's own Package.swift file, and only has a Package.resolved file in the xcworkspace (i.e. just a regular app consuming other packages) ... is there still a way to apply mirroring to that "top level project", even if it's not itself a package?

I'm trying to achieve the same thing, and I'm also confused of what does "top level project or workspace in Xcode" mean, since Xcode doesn't provide such capabilities in the project / workspace level.

Curious if you have figured out any workaround..?

Xcode projects can have sub-projects which can have sub-projects, ad infinitum. Xcode workspaces are based on having multiple projects already, which can have sub-projects, etc.. Workspaces can also have sub-workspaces, which have projects themselves.

You can drag 'n drop an existing project/workspace into another project/workspace just like a file. You can use the Add File menu command to add a pre-existing .xcproject or .xcworkspace file into another project/workspace. If you create a new project or workspace, the panel where you specify the location of the project/workspace also allows you to associate the new object with a pre-existing project/workspace. See the two drop down boxes at the bottom of the dialog panel.

I fixed it, when I added the folder configuration contains info about mirroring, to xcodeproj.
For example:
Package folder /MyPackage/.swiftpm/configuration, I copy to /MyApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/configuration

1 Like

This looked like exactly what I was looking for! But unfortunately it didn't work for me in Xcode 13.3...