Why this happens
A Swift package can return after you delete its entry from Package.resolved because you have changed the resolution record, not the dependency declaration. Xcode still knows that the project requires the package, so resolving or updating packages can put the entry back.
For an Xcode app project, package references belong to the project configuration. Package.resolved records the selected package versions or revisions so that dependency resolution can reproduce them. It is not the place to uninstall a dependency.
The other source of confusion is the menu location. In Xcode 11, the File > Swift Packages menu provides package-related commands, but removal is handled in the project editor. Later Xcode interfaces label the relevant project tab Package Dependencies rather than Swift Packages.
How to fix it
1. Remove the package from the project editor
Use the project’s dependency list rather than a package update command or a manually edited resolution file.
- Open the project or workspace in Xcode.
- In the Project navigator, select the blue project icon for the app project.
- In the project editor, select the project under PROJECT, not an app or test target under TARGETS.
- Open Package Dependencies. In Xcode 11, open Swift Packages instead.
- Select the package you no longer need.
- Click the minus button beneath the package list and confirm removal if prompted.
This is the essential fix: remove the dependency where Xcode declares it. You do not need to find a delete command under File > Swift Packages.
If you cannot see the package tab, first check what is selected. Selecting a Swift source file shows the code editor; selecting a target shows target settings. You need the project-level settings.
After removal, allow any package-resolution activity to finish. Check the dependency list again before making other changes. If the package is gone there, you have removed that project’s direct reference.
2. Remove code and target references that still need the package
Removing the dependency does not rewrite application code. Source files can still import its modules or call its APIs, which makes the next build fail.
Search the workspace for the package’s module names. A package’s repository name and its importable module names are not necessarily identical, and one package can supply several library products.
For example, if the package supplied a module named ExampleLibrary, remove or replace code such as:
import ExampleLibrary
Then update the code that used its types and functions. Deleting an import alone will not help if the rest of the file still depends on the module.
Also inspect the affected app, extension, and test targets:
- Under General, check Frameworks, Libraries, and Embedded Content for a remaining product from the removed package.
- Under Build Phases, check Link Binary With Libraries for a leftover reference if the build still reports a missing package product.
Remove only references belonging to the dependency you are retiring. Xcode may already have removed these when you deleted the package, so verify before changing anything.
Build the project after this cleanup. A missing-module failure at this stage usually means there is still code depending on the library, not that the package needs to be added back.
3. Check whether another project or package still requires it
A package can remain in the workspace’s dependency graph even after you remove one direct reference.
There are two important cases:
- Another project requires it. A workspace can contain multiple projects, each with its own package references. Removing a package from one project’s settings does not remove another project’s dependency.
- Another package requires it. The library may be a transitive dependency: a package you still use depends on it internally.
Inspect the package settings of the other projects in the workspace. If another project intentionally uses the library, its continued presence is expected.
For a transitive dependency, you cannot remove it independently while keeping a parent package that requires it. You would need to remove that parent package or use a version whose declared dependencies no longer include the library.
The practical distinction is between removing your app’s direct dependency and eliminating a package from the entire resolved graph. The first does not always accomplish the second.
4. If you are editing a Swift package, change Package.swift
The project-editor fix applies to dependencies added to an Xcode project. If the thing you opened is itself a Swift package, its dependency declarations live in Package.swift.
In that case, remove both the external package declaration and any target dependency that references its product. For example, a package that no longer needs external libraries might have this minimal manifest:
// swift-tools-version: 5.7
import PackageDescription
let package = Package(
name: "LocalUtilities",
products: [
.library(
name: "LocalUtilities",
targets: ["LocalUtilities"]
)
],
dependencies: [],
targets: [
.target(
name: "LocalUtilities",
dependencies: []
)
]
)
This is an illustration, not a replacement for your existing manifest. Preserve your package’s tools version, products, targets, platforms, and other dependencies. Remove only the unwanted declaration and its corresponding target references.
Then remove imports and API usage from the package’s source and tests, just as you would for an app target.
5. Review the project changes instead of clearing caches
Before committing, inspect the source-control diff. For an Xcode project, expect the removal to change the project configuration, commonly project.pbxproj. For a Swift package, expect changes to Package.swift.
Package.resolved may also change when Xcode updates the resolved dependency graph. Review that change alongside the actual dependency declaration rather than treating it as the removal itself.
Deleting Derived Data or resetting package caches is not the fix for a dependency that remains declared. Neither action tells the project to stop requiring the package. Start with the declaration and use the build result to identify any remaining source or target references.
How to prevent it
- Add and remove app-project dependencies through the project’s package settings.
- Treat
Package.resolvedas a version-resolution record, not an editable dependency list. - When removing a library, search app, extension, and test code for its modules and APIs.
- Review project or manifest changes before committing a dependency cleanup.
- Check for transitive dependencies before assuming a remaining package indicates a failed removal.
FAQ
Why does Update to Latest Package Versions bring the package back?
The project or a package in its dependency graph still requires it. Updating versions resolves those requirements again, so manually deleting its Package.resolved entry does not make the removal permanent.
Where is the remove button in Xcode 11?
Select the project in the Project navigator, select the project-level settings, and open Swift Packages. Select the dependency and use the minus button beneath the list; the removal control is not in the File > Swift Packages menu.
Can I remove a package from only one target?
Yes. Remove that target’s use of the package product and update its source code, while keeping the project-level package dependency for other targets that still need it. Remove the project-level dependency only when no target in that project needs its products.
Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.
