Question: After I create a new swift package with dependencies I call `swift package generate-xcodeproj`. If my dependencies have a new version I call `swift package update`. The new version of my dependency gets downloaded and built but Xcode now has a bad reference to the old version of the dependency. I can call `swift package generate-xcodeproj` again but this will remove any custom targets I have setup.

How do I update my swift dependencies and my Xcode project without deleting my custom targets?

Answer: 
Many of the problems with packages not updating are because the swift package version rules limit the automatic package updates to the current major version only, i.e v3.3.1 of a package will update to v3.4.0, but will not update automatically to v4.0.1. Therefore using the update options in Xcode does not necessarily get the latest major version of a package.

To resolve, Open the project from the project panel, select the project (not the targets), then select the "Swift Packages" tab. Double click on the package you want to update and change the minimum version to the next major version.

[![enter image description here](https://i.stack.imgur.com/l6yBj.png)](https://i.stack.imgur.com/l6yBj.png)
- Update a single dependency using Xcode
========================================

This method will save a lot of resources and time. Because it won't force other packages to redownload.

Double click on the package in the tab you mentioned and change the version to anything else. It will then recheck the remote repo. The benefit of doing this is to only update the selected package. (Also, it's better to have the **current using version** be set in the package.)

---

- Update ALL dependencies using Xcode
=====================================

From File -> Swift Packages -> Update to Latest Package Versions

[![SS](https://i.stack.imgur.com/f2fKy.jpg)](https://i.stack.imgur.com/f2fKy.jpg)

---

###  Single package with GUI (Xcode 12 and above)

Right-click on the package from the left navigation pan and select Update Package

![Xcode 13](https://i.stack.imgur.com/g4z9O.png)

note that you will see Xcode saying update all packages but it will update only the selected one