-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add conceptual documentation for dependency mirrors #9540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Viditgupta-official
wants to merge
14
commits into
swiftlang:main
Choose a base branch
from
Viditgupta-official:dependency-mirrors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+49
−0
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
38fd10e
Add conceptual documentation for dependency mirrors
Viditgupta-official 9d44049
DocC: curate Dependency mirrors under Adding Dependencies
Viditgupta-official 4b92e65
Refine Dependency Mirrors documentation and add usage guidance
Viditgupta-official f761e42
docs: align dependency mirror documentation with SwiftPM behavior
Viditgupta-official 3ee1c84
Update Sources/PackageManagerDocs/Documentation.docc/Package/Dependen…
Viditgupta-official 798f4ff
Update Sources/PackageManagerDocs/Documentation.docc/Package/Dependen…
Viditgupta-official 4ac3b85
Update Sources/PackageManagerDocs/Documentation.docc/Package/Dependen…
Viditgupta-official 56d7f1c
Update Sources/PackageManagerDocs/Documentation.docc/Package/Dependen…
Viditgupta-official 6f5bf25
Update Sources/PackageManagerDocs/Documentation.docc/Package/Dependen…
Viditgupta-official d74b722
Update Sources/PackageManagerDocs/Documentation.docc/Package/Dependen…
Viditgupta-official 0b5aabc
Update Sources/PackageManagerDocs/Documentation.docc/Package/Dependen…
Viditgupta-official cb8e1e6
Update Sources/PackageManagerDocs/Documentation.docc/Package/Dependen…
Viditgupta-official 8bdfc18
Update Sources/PackageManagerDocs/Documentation.docc/Package/Dependen…
Viditgupta-official 2748c7c
Update Sources/PackageManagerDocs/Documentation.docc/Package/Dependen…
Viditgupta-official File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
Sources/PackageManagerDocs/Documentation.docc/Package/DependencyMirrors.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Configuring Dependency Mirrors | ||
|
|
||
| Dependency mirrors let Swift Package Manager fetch dependencies from alternate locations without modifying the package manifest. | ||
|
|
||
| ## Overview | ||
| Dependency mirrors allow Swift Package Manager to fetch a package dependency from an alternate location without modifying the package manifest. This is useful in environments where dependencies must be fetched from internal mirrors, cached repositories, or alternate hosting locations. For more information about declaring dependencies, see <doc:AddingDependencies>. | ||
|
|
||
| You commonly use dependency mirrors when working in corporate or restricted network environments. They let you redirect dependencies to internal mirrors, or control where dependencies come from without modifying existing package manifests. | ||
|
|
||
| Dependency mirrors are configured locally and apply only to the top-level package being built. Mirror configuration is stored outside the package manifest and is not shared when a package is published or checked into version control. Dependency mirrors apply to all versions of a dependency identity and can’t be scoped to individual versions. | ||
|
|
||
| During dependency resolution, Swift Package Manager transparently rewrites dependency source locations based on the configured mirrors, without modifying the package manifest. | ||
| When you configure a mirror for a dependency, Swift Package Manager treats it as authoritative and doesn't fall back to the original source location. | ||
| Swift Package Manager resolves dependency versions according to the rules described in <doc:ResolvingPackageVersions>. | ||
|
|
||
|
|
||
| ### Configure dependency mirrors | ||
| You configure dependency mirrors using Swift Package Manager's local configuration commands. | ||
| These commands let you map a package dependency identity or source location to an alternate location without modifying the package manifest. | ||
| Commands such as <doc:SwiftBuild>, <doc:SwiftRun>, and <doc:PackageUpdate> trigger dependency resolution. | ||
|
|
||
|
|
||
| To configure a mirror, you register a mapping between the original dependency source and the mirror location. Once configured, Swift Package Manager automatically applies this mapping during dependency resolution. | ||
|
|
||
| For example, if a package depends on a repository hosted at a public Git URL, you can configure Swift Package Manager to fetch that dependency from an internal mirror instead. After setting the mirror, subsequent dependency resolution operations will use the mirrored location transparently, without requiring changes to the package’s dependency declarations. | ||
|
|
||
| Mirror configuration affects only the top-level package you're building. | ||
| Once you set a mirror, Swift Package Manager treats it as authoritative and doesn't fall back to the original source location. | ||
|
|
||
| ### Inspect a mirror configuration | ||
| Use `swift package config get-mirror` to look up the mirror for a specific | ||
| dependency identity or URL: | ||
|
|
||
| ```bash | ||
Viditgupta-official marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| swift package config set-mirror --original <original-url-or-identity> --mirror <mirror-url-or-identity> | ||
| swift package config get-mirror --original <original-url-or-identity> | ||
| swift package config unset-mirror --original <original-url-or-identity> | ||
| ``` | ||
|
|
||
| Swift Package Manager stores mirror configuration locally; it's not part of the package manifest. | ||
|
|
||
| ### Understand configuration scope | ||
|
|
||
| Swift Package Manager persists mirror configuration and may apply it from different configuration scopes (such as workspace-local or shared configuration). | ||
| It automatically determines the specific scope to use based on the command context and environment. | ||
|
|
||
| The mirror configuration commands do not provide explicit flags to select | ||
| a configuration scope. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(reworking to active voice)