11

Updating pod version fails

I am using Xcode 8.2.1 and CocoaPods v1.1.1 and my code is Swift 3

My issue is with publishing new version of my pod or updating existing version, which fails on pod spec lint.

I've created a PlaybuzzSDK pod and I would like to update it's code. I commit and push the new code through GitHub client, but the changes are not reflected on the pod class, only on the Example project.

What did I do?

I've created new tag and tried to push it, but didn't pass validation:

git tag 0.1.1 (successful)
git push origin 0.1.1 (successful)
pod spec lint PlaybuzzSDK.podspec (unsuccessful with error below)
pod trunk push PlaybuzzSDK.podspec  (unsuccessful with error below) 

-> PlaybuzzSDK (0.1.1) - ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/git clone https://github.com/LudaFuxPlaybuzz/playbuzz-ios-sdk.git /var/folders/h0/knhpn8z16n3cz6tkny5rmtn00000gn/T/d20161228-47834-nli8c4 --template= --single-branch --depth 1 --branch v0.1.1

Cloning into '/var/folders/h0/knhpn8z16n3cz6tkny5rmtn00000gn/T/d20161228-47834-nli8c4'... warning: Could not find remote branch v0.1.0 to clone. fatal: Remote branch v0.1.0 not found in upstream origin ) during validation.

[!] The spec did not pass validation, due to 1 error. [!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a .swift-version file to set the version for your Pod. For example to use Swift 2.3, run: echo "2.3" > .swift-version.

Additional things I've tried:

  • I removed the project from my comp and cloned it again
  • I've cleaned cache of CocoaPods rm -rf ~/Library/Caches/Cocoapods rm -rf ~/.cocoapods/repos
  • I've tried to create a new branch and tried to pod lint the branch.

But I get this error every time.

What did I expect to happen

I expected that from now on, if somebody adds

pod 'PlaybuzzSDK' 

and will update their pods, they'll get the new version

New version means that reloadItem will have the following signature:

public func reloadItem(_ itemAlias:String,
                         companyDomain: String,
                         showItemInfo:Bool)

What happened instead

I can't get through the pod lint. And when I update pod from example project, the function reloadItem gets back to

public func reloadItem(_ userID: String,
                    itemAlias:String,
                    showRecommendations: Bool,
                    showShareButton: Bool,
                    showFacebookComments: Bool,
                    showItemInfo: Bool,
                    companyDomain: String)

Project that demonstrates the issue

https://github.com/LudaFuxPlaybuzz/playbuzz-ios-sdk

Luda
  • 7,282
  • 12
  • 79
  • 139
  • You should update your version and point the source to correct git with correct tag, maybe version and tag 0.1.3? Also, do a `pod spec lint` first before try to push it – Tj3n Dec 28 '16 at 11:47
  • I want the update to be on the master. Not new branches and tags.. – Luda Dec 28 '16 at 11:48
  • The pod will use tag to update its code, not branch, it show in your podspec, you are pointing it to the git with tag 0.1.0 – Tj3n Dec 28 '16 at 11:49
  • So what should I do exactly? – Luda Dec 28 '16 at 12:02
  • just follow the update tutorial and do the above stuff i said, point the thing in podspec to the right tag, pod managing by tag, only when install then you can use branch – Tj3n Dec 29 '16 at 03:27
  • @Tj3n Do you have a reference to an update tutorial? – Luda Dec 29 '16 at 08:35
  • It's very easy only, just modify your podspec with new version, source pointing to the right tag (not yet created), then push your project to your git and create a tag with that version, then do `pod trunk push` – Tj3n Dec 29 '16 at 08:46
  • @Tj3n, I did that: git tag 0.1.4 , git push origin 0.1.4. Till far, all good. But this line: pod trunk push PlaybuzzSDK.podspec, gives me the following error: PlaybuzzSDK (0.1.4) - ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/git clone https://github.com/LudaFuxPlaybuzz/playbuzz-ios-sdk.git /var/folders/h0/.. --template= --single-branch --depth 1 --branch v0.1.4 Cloning into '/var/folders/... warning: Could not find remote branch v0.1.4 to clone. fatal: Remote branch v0.1.4 not found in upstream origin ) during validation. – Luda Dec 29 '16 at 09:48
  • your version and tag in the git is 0.1.1, it have to be similar...You have to push everything to the master first before create tag – Tj3n Dec 29 '16 at 10:14
  • @Tj3n Where do you see 0.1.1? If I run: pod trunk info PlaybuzzSDK, I get: PlaybuzzSDK - Versions: - 0.1.0 (2016-12-07 14:59:36 UTC) - Owners: - Luda Fux – Luda Dec 29 '16 at 10:36
  • @Tj3n And podspec specifies 0.1.4 – Luda Dec 29 '16 at 10:37
  • The podspec in your tag 0.1.4 show your version and tag is 0.1.1, your master branch is correct but the file in your tag is not, go tag 0.1.4 in your git and see for yourself – Tj3n Dec 29 '16 at 10:39
  • @Tj3n I see now. I don't understand why is this happening. My local podfile has version 0.1.4. I committed and synced all the changes in to GtHub. Xcode seems to be synced. So why isn't the code updates on git? By the way- you are super duper great!!!! – Luda Dec 29 '16 at 10:56
  • make sure to commit/push everything first before creating tag and push it, you might missed some step, you can also delete tag and recreate it – Tj3n Dec 29 '16 at 11:05
  • @Tj3n I am committing and pushing my code through the GitHub Mac client and through Xcode (just to be sure). Maybe I should commit and push through the terminal? – Luda Dec 29 '16 at 13:00
  • @Tj3n BTW, I removed all the version from git. But it appears I can't create new tags with the same name. For example: git tag 0.1.1 fatal: tag '0.1.1' already exists – Luda Dec 29 '16 at 13:36
  • You need to remove it from your system as well i think, your system also record your tags, i do everything through terminal just to make sure i did all the step, can get confuse sometimes – Tj3n Dec 30 '16 at 02:53
  • @Tj3n, we have a progress. I've removed the project from my comp. And now could create 0.1.1 tag again. Moreover now the tag https://github.com/LudaFuxPlaybuzz/playbuzz-ios-sdk/tags contain the updated code. Which is awesome. But the project still doesn't pass validation with the same error that was mentioned in the question. And how do I download the correct tag in separated project? When I write "pod Playbuzz" it downloads the first tag (0.1.0) with the old code – Luda Jan 01 '17 at 11:58
  • @Tj3n, the problem was solved! Looking at the podspec s.source is set to the tag v0.1.0 but the pushed tag is 0.1.0. Try changing the podspec and updating the tag to reference the new commit. But I would like to repay you for all your help. Please put this as an answer and I will check it and give you bounty – Luda Jan 02 '17 at 11:47
  • Alright, placed a summary as the answer :D glads to help you – Tj3n Jan 03 '17 at 03:26

2 Answers2

36

Summary, to update a pod:

  1. Update the version and the tag in podspec beforehand
  2. Commit, push code to git
  3. Create new tag with the current code, make sure it's the same tag as the one in podspec

    git tag 0.1.1

    git push origin 0.1.1

  4. Call pod spec lint to check and pod trunk push to update it on repo master list

    pod lib lint YourSDK.podspec

    pod trunk push YourSDK.podspec

It appears that your podfile is using the tag v0.1.1, however the tag in your repository is 0.1.1 without the v. This would also cause linting to fail.

Tj3n
  • 9,837
  • 2
  • 24
  • 35
  • `pod push trunk` should be `pod trunk push`. – swordray Feb 12 '18 at 09:48
  • 3
    I'm using a private source pod repo, so things might be different. But I used `pod repo push myprivatesourcepodrepo YourSDK.podspec` in place of `pod trunk push YourSDK.podspec`. – Jonny Jun 15 '18 at 05:56
  • Also it seems that you advice on using `pod spec lint` but then in the example uses `pod lib lint`. Is this intended? The two seem to have different use cases. – Jonny Jun 15 '18 at 05:58
  • 1
    `pod lib lint` can help you figure out the problem on local spec file before pushing, after making sure it works, then you can push and use `pod spec lint` to check if your pod can clone and work from git, `pod trunk push` also do spec lint so it's not required here, your choice to use – Tj3n Jun 15 '18 at 06:06
  • Thanks for the clarification but are you sure it's not the other way around? `pod spec lint` sounds like it would check on the podspec, and `pod lib lint` checks the lib... – Jonny Jun 15 '18 at 06:15
  • You can check the different [here](https://stackoverflow.com/questions/32304421/whats-the-difference-between-pod-spec-lint-and-pod-lib-lint) – Tj3n Jun 15 '18 at 08:16
  • thanks, it was very helpful, just wanted to add that for the private repos the last command should be ```pod repo push YourSDK``` instead of ```pod trunk push YourSDK.podspec``` – Yash Vardhan Mar 07 '22 at 07:22
1

You need to add a file called .swift-version to the top level of your repository in order to have your users projects configured correctly when the pod is installed.

In the top level of your project, run this command:

echo "3.0" > .swift-version

Then commit that and update your tag to that commit.

It also appears that your podfile is using the tag v0.1.1, however the tag in your repository is 0.1.1 without the v. This would also cause linting to fail.

Dave Lyon
  • 613
  • 5
  • 8
  • Dave, using pod 1.4 we don't need to create a .swift-version file anymore. On this version we are able to declare something like: s.swift_version = "3.0" – Igor De Oliveira Sá Mar 02 '18 at 20:22