Add Swift Package in Xcode

Hi,

Overview

I would like to add a Swift Package to my Xcode project.

Problem

  • In Xcode when I select Project > Package Dependencies and Press + button to add a dependency it keeps spinning and doesn't end

Points to note:

  • Xcode 26.5 (17F42)
  • macOS 26.5 (25F71)
  • This is a private GitHub repository
  • I am able to clone the Swift Package URL on the command line.
  • Xcode has the GitHub account
  • I am able to push and pull code on that GitHub account using Xcode

My failed attempt

rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/org.swift.swiftpm
plutil -remove IDESwiftPackageAdditionAssistantRecentlyUsedPackages ~/Library/Preferences/com.apple.dt.Xcode.plist
  • I have removed GitHub account in Xcode and added it again

I am confused if I am missing something very obvious, any help on this is much appreciated.

Questions

  • Is there any workaround or way to fix this issue?
  • Why does this take such a long time when I have a specific URL, either it needs to add it or return that the package is not found. Why is it searching?
Answered by newwbee in 889529022

Problem

  • The actual issue for me is Xcode when adding a new package and entering the URL in the search box where it keeps spinning (even over an hour) never ends.
  • This seems like an Xcode bug

Workaround

  1. Add one of the Apple Swift Packages which comes pre-loaded with Xcode like swift-algorithms
  2. Once added that screen gets dismissed and the swift-algorithms URL is added as a dependency
  3. Now click on the swift-algorithms and change it to your URL and also update the Dependency Rule

This will add the your swift package and pull the code.

DTS Engineer:

  • @DTS Engineer this seems like an Xcode bug.

Once the spinner begins, turning off the WiFi the spinner doesn't stop.

Is it really searching?

I am surprised no one else is facing this issue.

Accepted Answer

Problem

  • The actual issue for me is Xcode when adding a new package and entering the URL in the search box where it keeps spinning (even over an hour) never ends.
  • This seems like an Xcode bug

Workaround

  1. Add one of the Apple Swift Packages which comes pre-loaded with Xcode like swift-algorithms
  2. Once added that screen gets dismissed and the swift-algorithms URL is added as a dependency
  3. Now click on the swift-algorithms and change it to your URL and also update the Dependency Rule

This will add the your swift package and pull the code.

DTS Engineer:

  • @DTS Engineer this seems like an Xcode bug.
Add Swift Package in Xcode
 
 
Q