15

I've searched Apple's documentation, open source projects, and Google, and I cannot seem to find any information about SwiftPM.SPMRepositoryError error 5. Heck, I can't even find information about SwiftPM.SPMRepositoryError.

Does anyone know of documentation for this error or the error codes?

jarrodparkes
  • 2,378
  • 2
  • 18
  • 26
  • 1
    I downgraded from Xcode 13.3 to Xcode 13.2 and was able to get things working again. I did have to work through an issue related to an old SSH key. For that, I followed through the advice in this post: https://stackoverflow.com/questions/71500791 and created a new SSH key with `ssh-keygen -t ecdsa -b 256 -m PEM`. I'm not sure it is related to `SwiftPM.SPMRepositoryError error 5` though... – jarrodparkes Mar 17 '22 at 03:37
  • https://stackoverflow.com/questions/71498990/cannot-resolve-swift-packages-after-15th-march-2022-in-xcode ? – Larme Mar 17 '22 at 08:07
  • 1
    I am also facing the same problem, downgrading from Xcode 13.3 to 13.2 worked for me – hima sai Mar 25 '22 at 06:05
  • You may post your comment as an answer. – AcK Apr 02 '22 at 21:09
  • 1
    This answer did help me: https://stackoverflow.com/a/71671235/2027279 – juanjo Apr 02 '22 at 23:05
  • I was on 13.3.1. When I switched to 14.0 the problem went away! – mfaani Nov 21 '22 at 22:45

6 Answers6

16

What worked for me was switching to ED25519 key.

I think this is happening now because of the effort to improve Git protocol security on GitHub. You can read more about it here: https://github.blog/2021-09-01-improving-git-protocol-security-github/

There you can see the timeline. The final step was put into motion on Mar 15, 2022 (coincidentally that was just two days before your question)

Changes made permanent.
We’ll permanently stop accepting DSA keys. RSA keys uploaded after the cut-off point above will work only with SHA-2 signatures (but again, RSA keys uploaded before this date will continue to work with SHA-1). The deprecated MACs, ciphers, and unencrypted Git protocol will be permanently disabled.

mfaani
  • 33,269
  • 19
  • 164
  • 293
Peter Lazarov
  • 321
  • 2
  • 8
  • to confirm, you received the same `SwiftPM.SPMRepositoryError error 5` and resolved it in Xcode 13.3 using the new `ED25519` key? – jarrodparkes Mar 17 '22 at 20:52
  • 1
    @jarrodparkes Yes, I'm on 13.3 and just got this error too and upgraded my key to ED25519 and SPM is working again for me. – bandejapaisa Mar 18 '22 at 15:39
  • 1
    This worked for me thank you. Preferences > Accounts > GitHub Account > SSH Key = id_ed25519 > (Upload if necessary). – Patrick Mar 19 '22 at 07:56
  • 1
    would anyone help me? I'm still having issues with this. even updating the SSH key – Surya Mar 24 '22 at 08:33
  • 4
    I'm still facing this issue when attempting to update all packages to their latest versions. I've tried switching to both `ECDSA` and `ED25519`, neither have solved the issue for me. – Vatsal Manot Mar 24 '22 at 15:48
  • @VatsalManot did you also try downgrading from Xcode 13.3 to 13.2? – jarrodparkes Mar 27 '22 at 02:11
  • I tried every ssh-keygen command there was and still facing the same issue. I'm almost sure the keys are not root the problem. – Pacu Mar 28 '22 at 21:31
  • @jarrodparkes Xcode 13.2 failed with an SSL error. – Vatsal Manot Apr 07 '22 at 20:06
  • @VatsalManot have any of the other methods suggested on this thread been helpful? I'm still anxiously awaiting more information about the error itself – jarrodparkes Apr 08 '22 at 12:53
  • This worked for me. Make sure after you create the new ssh key that you update Xcode > Preferences > Accounts > Source Control Accounts and select the new ssh key – Matt Apr 12 '22 at 16:49
  • I can confirm that switching to ED25519 works in Xcode 13.3 – Daniel Saidi Apr 23 '22 at 09:12
  • Do I have to remove RSA key in order for the ED25519 start to work? – ReDetection May 19 '22 at 16:42
12

This helped in my case:

  1. File -> Packages -> Reset Package Caches
  2. File -> Packages -> Update to Latest Package Versions
Ivo Stoyanov
  • 16,256
  • 8
  • 62
  • 65
2

This happened to me on Xcode 13.3 and 13.3.1 when my team added package dependencies that I didn't have Github access to. The error message is ambiguous and shows the same number of errors as the number of packages I have in my dependency tree. But, obtaining access to any repos that I didn't already have access to (which was a smaller number of repos than the error count) resolved the error for me.

I was able to track down the issue by attempting to add another package (anything public like swift-algorithms). Xcode gave me better error reporting in that process.

Justin Domnitz
  • 3,217
  • 27
  • 34
1

Updating swift-tools-version in Package.swift file worked for me. We've previously been using 5.3, and updating it to 5.5 or 5.6 resolved the problem.

One thing to keep in mind, Apple has deprecated the existing package declaration functions in Swift 5.6 [1], so using this version would result in a lot of new warnings.

Hopefully, this is just a temporary thing, and a proper fix is coming in the next Xcode version.

doroshenko
  • 11
  • 1
0

Just had the same issue.. (project based on a Package.swift file, not a regular .xcodeproj)

Doubted that it would have to do something with GitHub's policy as described above, since I've worked on other projects today without any issues.

Tried to clear the derived data folder, as well as the project's .swiftpm folder and even the swiftpm repo cache.. nothing helped.

Tried the same project on another MacBook and worked fine! Then made a fresh clone of the project in a different folder on the Mac with the issue and worked fine as well.

So finally I just deleted the local Package.resolved file, reopened the project in Xcode and everything was back to normal

ChiellieNL
  • 103
  • 1
  • 8
  • thank you for the updates here. im still hoping to find something, from Apple, that gives us more details on the error code itself. I removed the accepted answer mark for now until more information is made available – jarrodparkes Apr 02 '22 at 20:05
0

This seems to be the same issue as Error while fetching remote repositorygit@github.com:***/***.git: An unknown error occurred. reference 'refs/remotes/origin/master' not found (-1) in Xcode 14.

Here is a small script I made to work around it: https://stackoverflow.com/a/74130700/624854.

Srđan Rašić
  • 1,597
  • 15
  • 23