# Update for Projects w/ Swift Packages
## How did the errors happen?
I ran into this issue when I had imported Swift Packages into my project but later cleaned `DerivedData` to fix an unrelated app caching issue. My existing project was not a local Swift Package but an iOS app project.
Note that we can still encounter the same issue in local Swift Package projects.
## What is the reason for the errors?
Swift Packages are checked out into `DerivedData` and are not referenced from the `ModuleCache.noindex` subfolder. Thus, cleaning the app's folder in `DerivedData` or `DerivedData` itself breaks dependency resolution within Xcode for Swift Packages.
This is a misleading build error since there may be nothing wrong with the app code you've written or your dependency resolution graph. The only thing required is to refresh the dependencies.
## How can I resolve the build errors?
Xcode now has nice options within the IDE itself to resolve Swift Packages. These options trigger a new checkout into `DerivedData`:
[![enter image description here][1]][1]
We can use three options, as shown in the image above depending on our use case:
1. <kbd>Reset Package Caches</kbd>: Trigger a re-install of your existing Package dependencies w/ same versions.
2. <kbd>Resolve Package Versions</kbd>: Use this option for updating Package checkouts when fixing Package Versions for cross-compatibility (in Project Settings).
3. <kbd>Update to Latest Package Versions</kbd>: Use this to update all Swift Package dependencies to the latest versions. This option may be a local breaking change if the API changes.
**NOTE**: Apple's documentation [recommends][2] to use Xcode for dependency resolution when working with Xcode projects excluding CLTs.
## Other solutions
1. We can also fix the error by restarting Xcode, but I find this step breaks my workflow and is tedious.
2. If we are running from the command line (local Swift Package executable), we can stick with a `swift build` variant without jumping to Xcode at all ([Source][3]). `swift build` doesn't work as easily out of the box in other projects, however.
3. Use `xcodebuild`:
xcodebuild -resolvePackageDependencies
I prefer staying in Xcode for simplicity but YMMV.
[1]:
[2]:
[To see links please register here]
[3]:
[To see links please register here]