skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    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

  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search