In my Xcode settings, I'm logged into my GitHub account (where 2fa is turned on) as a Source Control Account. I currently have it set up to use SSH and my SSH key. I've created an access token and securely saved that string on my machine. I can successfully add the package when I use an SSH URL (which makes sense, such as [email protected]:{username}/{repo_name}.git
.
I can't get adding via HTTPS to work for some reason. It always results in the following error:
Error while fetching remote repository: https://github.com/{username}/{repo_name}.git
Authentication failed because no credentials were provided.
Is this a known Xcode error? I haven't found an answer here on SO. Is it because I'm using 2FA? All the packages have the same instruction which is essentially "Just copy and paste this URL into SPM to add" but that's never worked for me.
Would love some insight here. Thanks!
To add the URL to your project: Tap or click the Add Document button (+) in the toolbar above the project navigator. Tap or click the menu and choose Swift Package. Enter the URL for your Swift package in the text field that appears, then tap or click Return.
To create a new Swift package, open Xcode and select File > New > Swift Package. Choose a name and select a file location. Select “Create Git repository on my Mac” to put your package under version control. On completion, the Swift package opens in Xcode and looks similar to a standard Xcode project.
The Swift Package Manager can be used to add external libraries in Xcode projects. This makes the tool a good alternative to Cocoapods and Carthage for managing the dependencies of an iOS project.
Swift packages are reusable components of Swift, Objective-C, Objective-C++, C, or C++ code that developers can use in their projects. They bundle source files, binaries, and resources in a way that's easy to use in your app's project. Each Swift package requires a Package.
We solved this by removing a problematic setting in $HOME/.gitconfig
:
Deleting:
[url "[email protected]:"]
insteadOf = https://github.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With