Xcode 13.2.1 unable to resolve Swift Package Manager
Asked Answered
D

8

14

In my app I use several of SPM, I inserted them to my project. Yesterday I updated my Xcode to the last version (13.2.1), but I'm having lot of issues with SPM. Usually when I switch a branch or change a version of Xcode I clean all by using command+shift+k. I did the same with the new release of Xcode, but I'm having lots of issue by resolving SPM, as you can see in this image

enter image description here

all of my package are fetched but not resolved. This is a very big problem because in this condition I can't compile my app. There's a way to fix this issue? There's someone who has the same problem like me? I'm getting crazy about this. Thank you

Disallow answered 4/1, 2022 at 15:20 Comment(6)
Yeah, I think it's an Xcode bug. You clean-all is good but sometimes it's just not enough. I find I often have to (1) quit Xcode, (2) clean Derived Data, (3) launch Xcode and build the project and fail, (4) remove the problematic packages, (5) add them again, and (6) build again. It's a pain in the butt but it consistently works for me.Really
Thank you for answer, but it's possible that Apple has this problem a month ago and the problem is still not resolved. It's a big bug and your work around very often not work and for me it's impossible to remove and re-add the package every time I switch between branches...Disallow
I feel your pain. It's not "impossible" to do this when switching branches, as I often have to do that. Anyway I've given you the best wisdom I've got on this topic. File a bug report with Apple. This is not a Stack Overflow matter.Really
Your is for sure a solution, but it should be resolved by Apple. Thank you btw.Disallow
I totally agree. That is why this is not a Stack Overflow question.Really
This is my first experience, my first time ever delving into swift, and I'm running up against this brick wall. A simple little command line app, using the swift command line, and this will NOT go away. I'm actually really surprised this barrier exists and I have no idea how to get past it.Muncey
M
24

I just spent two days on this same issue, and finally got my rather long list of packages to resolve and build. I just can't believe Apple can't fix this. If we could just update one package at a time we could slowly get everything to work. In any case, I just made notes to my team of what I did to finally get all packages to resolve:


If Xcode struggles to resolve them, the solution is complicated and must often be done multiple times (Xcode 13.2.1):

  • close the project
  • quit Xcode
  • delete every folder in the Derived folders, then in Finder delete Trash
  • cd to the folder containing the MyProject.xcodeproj and run: xcodebuild -resolvePackageDependencies -project MyProject.xcodeproj -scheme MyScheme -platform="iOS, name:'Any iOS Device'"
  • open Xcode
  • open the project

Some projects may not resolve or have errors (little red "x"s on the right side). Not good but may be solvable:

  • use Xcode "File" -> "Packages" -> "Resolve Packages"
  • alternately, close the project, then reopen it.

You will probably get some warnings when running xcode build, I get:

--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:xxx-xxx }
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
...

Once you get to a stable position, with no errors and all packages showing version numbers, you should be good for the long haul.

IMPORTANT: occasionally you need to update the minimum version shown in the Project -> Package Dependencies, to reflect the existing Package release (which you may see from the left Xcode panel, or by visiting the Packages github site. If they are too old you may have problems resolving after you wipe the Derived Folder (for some other reason, maybe Package Format changed?)

Marika answered 3/3, 2022 at 14:53 Comment(2)
Thank you! It works for me, and this: developer.apple.com/forums/thread/694433Standley
Thank you! it also works for resolving the PackageIndex.findPackages failed: featureDisabled warning in Xcode 14 as well. https://mcmap.net/q/529138/-xcode-14-0-a-packageindex-findpackages-failed-featuredisabled-warningCankered
C
3

What worked for me was following these steps in Xcode

  1. File > Packages > Reset Package Caches
  2. File > Packages > Resolve Package Versions
Corvette answered 24/11, 2022 at 3:53 Comment(1)
DEC 2023 This should be the accepted answer. One click fix. Thank youGynoecium
C
2

These Steps work for me on XCode 13:

  1. Clear derived data
  2. Quit XCode
  3. Open XCode Again
  4. Wait for Indexing | Processing files
  5. Build (This will fail most probably)
  6. Wait for packages to resolve
  7. Clean Project
  8. Build.

Also if you have errors on local packages, then just try to build them individually.

Hopefully it will help

Connive answered 23/2, 2022 at 10:57 Comment(2)
Basically the same as my first comment.Really
I didn't removed the package in my caseConnive
R
0

For me,

  1. hit Cmd + q to totally quit Xcode
  2. Wait several seconds to make sure Xcode is completely closed.
  3. Re-Open Xcode.
Rihana answered 30/5, 2022 at 10:32 Comment(0)
A
0

For me I added the package anyway and then clicked on File > packages > Reset package caches

Aluminiferous answered 28/12, 2022 at 9:13 Comment(0)
U
0

Using Xcode 14.2, I:

  • cleaned the build folder
  • closed the project
  • created a workspace in the same project base folder
  • dragged the .xcodeproj file into the workspace
  • waited until it loaded all the packages and finished creating the indexes built the project

all warnings went away.

Ube answered 2/2, 2023 at 18:35 Comment(0)
V
0

Was facing the similar issue with our custom frameworks.

Updating the swift tool version from // swift-tools-version:5.2 to // swift-tools-version:5.3 in the package.swift fixed the issue for me.

Vasta answered 8/4 at 13:35 Comment(0)
E
0

For me, the issue was that I had no longer a GitHub account under Settings > Accounts.

Eldoree answered 12/4 at 13:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.