0

I'm learning by following this tutorial: https://www.raywenderlich.com/5823-how-to-create-a-cocoapod-in-swift

And I'm stuck in the place where it says: Using Your New CocoaPod

in the terminal I wrote:

cd ~/Documents/Libraries/RWPickFlavor 
pod repo add RWPodSpecs https://github.com/user/RWPodSpecs.git 
pod repo push RWPodSpecs RWPickFlavor.podspec

but I get a lot of errors:

[!] /usr/bin/git clone https://github.com/user/RWPodSpecs.git -- RWPodSpecs

fatal: destination path 'RWPodSpecs' already exists and is not an empty directory

and:

Validating spec
 -> RWPickFlavor (0.1.0)
    - NOTE  | url: The URL (https://github.com/user/RWPickFlavor) is not reachable.
    - ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/git clone https://github.com/user/RWPickFlavor.git /var/folders/bw/h527d_4x6yb7rv3tdrldty1c0000gn/T/d20220525-6530-de485a --template= --single-branch --depth 1 --branch 0.1.0

Cloning into '/var/folders/bw/h527d_4x6yb7rv3tdrldty1c0000gn/T/d20220525-6530-de485a'...
warning: Could not find remote branch 0.1.0 to clone.
fatal: Remote branch 0.1.0 not found in upstream origin
) during validation.

[!] The `RWPickFlavor.podspec` specification does not validate.

Any ideas?

5
  • I guess that it's not the real URL https://github.com/user/RWPodSpecs.git, that it's your own git repo, right? Also, did you put a tag 0.1.0 on your repo?
    – Larme
    May 25, 2022 at 9:23
  • In this post, I have only replaced my real user with the generic word user, for privacy reasons.
    – SwiftLove
    May 25, 2022 at 9:31
  • Yes my repository has the 0.1.0 tag
    – SwiftLove
    May 25, 2022 at 9:32
  • Is it a public repo? Because if it isn't then, CocoaPods won't be able to reach it, which could explaine the URL issue
    – Larme
    May 25, 2022 at 9:33
  • Yes they are public
    – SwiftLove
    May 25, 2022 at 9:47

1 Answer 1

1

I had this very issue and here is how I resolved it:

  1. Verify you are in the ~/Documents/Libraries/RWPickFlavor directory before performing any commands in Terminal.
  2. Verify that the contents of RWPickFlavor.podspec are correct. Mine was not and, if something is wrong, then it will not validate the Podspec.
  3. I went ahead and deleted the remote repository on GitHub and then ran rm -rf .git (again, make sure you are in ~/Documents/Libraries/RWPickFlavor). This step might be excessive, but I figured I had missed something when pushing to GitHub and, since this was just an initial commit, I did not feel like it really harmed anything. Yes, I am aware this is not best practice with regards to version control.
  4. I then went ahead and recreated the remote repository on GitHub.
  5. With the remote repository once again available, I did the following:
    • git init
    • git add .
    • git commit -m "Initial commit"
    • git tag 0.1.0
    • git branch -M main
    • git remote add origin https://github.com/user/RWPickFlavor.git
    • git push -u origin main --tags
    • pod repo push RWPodSpecs RWPickFlavor.podspec

Explanation: I think I/we might have forgotten the tag creation in the process and also forgot to include it in the push. Before I deleted the remote repo, I noticed that there was no tag and, even if I added a tag, the Podspec still would not validate.

Hope this is helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.