'Xcode: Own Swift packages missing in Schema selector

I have some SPM swift packages as part of my swift project.

After some Xcode crashes, those packages don't appear in the Schema selector (black arrow in image) any more.

So I can't select and build the swift packages any more separately.

What can I do to fix this?

enter image description here



Solution 1:[1]

For me it was solved by deleting .swiftpm/ folder

(Although, maybe just removing xcshareddata would've been enough)

Steps:

  • Removing dependency + reference from the main project
  • Delete .swiftpm/ of "problematic" local package
  • Add the package dependency back to the project

At least it worked.. Hoping there's a better way to solve this as well.

Solution 2:[2]

There must be a better way to resolve this, but at least it works:

Usual housekeeping:

  • Clear derived data
  • File -> Packages -> Reset Package Caches
  • restart Xcode

For each package that Xcode doesn't find / build:

  1. Klick on package -> show in Finder
  2. in finder, move the whole package into a temporary folder (package in Xcode gets red)
  3. delete red package in Xcode
  4. Create package again in Xcode with the same name (File -> New -> Package...), add package to appropriate targets again
  5. remove the newly generated swift files in XCode, including Package.swift
  6. drag the files in your copied folder into the corresponding place in the Xcode package
  7. File -> Packages -> Reset Package Caches (for some reason Xcode loses external packages each iteration)
  8. Build -> should be one less missing package in the error messages

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Glaphi
Solution 2 Gerd Castan