Pod trunk delete in Cocoapods and version number re-use - cocoapods

Cocoapods has the pod trunk delete command. I haven't used Cocoapods before so I want to use this command to push a prototype of our pod spec and then delete it. Our hosting isn't finalized so the spec won't be pointing to the final hosting location of our library. But I wasn't sure exactly the scope of this:
Deletes the specified pod version from trunk and the master specs
repo. Once deleted, this version can never be pushed again.
If I delete something like 1.0-beta1, does just beta1 become ineligible for another push? Or does the entire 1.0 release become ineligible?

Related

Cocoapods: force latest version download

There is a library I'm using in a project whose podspec is very outdated. As a result, my project seems to be pulling in older files. The library in question is Classy: https://github.com/ClassyKit/Classy
The podspec, which mentions version 0.2.4, has not been updated since 2014. The actual version, however, has some necessary fixes (such as https://github.com/ClassyKit/Classy/pull/97/commits) that come after the podspec update. Rather than moving things around manually, I'd prefer to have cocoapods handle it to make sure the files are in-sync. Problem is that whenever I run "pod update" it claims that the repo is up-to-date.
Simple solutions
You can automatically target latest commit for a specific branch:
pod 'Classy', git: 'https://github.com/cloudkite/Classy.git', branch: 'master'
You can automatically target latest commit with a head specifier (credit to Stalin Kay):
pod 'Classy', git: 'https://github.com/cloudkite/Classy.git', commit: 'HEAD'
You can manually target today's latest commit, in order to freeze your integration to a specific commit:
pod 'Classy', git: 'https://github.com/cloudkite/Classy.git', commit: 'c319908f8bded62e268dfd48ee5d65329b819129'
Cloning alternatives
You can clone the repo, update the .podspec (simply remove reference to tag and set version to '0.0.1'), and target your own repo in Podfile:
pod 'Classy', git: 'https://github.com/atsepkov/Classy.git'
or same thing and target your own .podspec:
pod 'Classy', podspec: 'https://github.com/atsepkov/Classy/blob/master/JSONKit.podspec'
To give you an example, this is exactly what I did here: https://github.com/Coeur/Classy/blob/master/Classy.podspec.
You can also create your own source of your .podspec files, and add the source of it:
source 'https://github.com/atsepkov/Specs.git'
pod 'Classy'
Or you can push your .podspec to CocoaPods trunk under a new name:
pod trunk push ClassyByAlexanderTsepkov.podspec
Old CocoaPods
If you are using CocoaPods 0.39.0 (but it will not work for 1.0.0+ anymore), you can directly use the head command:
pod 'Classy', :head
What will not work
If you target the repo directly, you will be using the latest .podspec of that repo (but that's not enough for your case):
pod 'Classy', git: 'https://github.com/cloudkite/Classy.git'
Contact author
Finally, consider contacting the podspec owner https://twitter.com/cloudkite

Removing Versions from CocoaPods Specs Repo

I've just published a Beta version of a Pod in the Specs Repo, using pod trunk push. I would like to know if is there any way of removing this version Spec from the Spec Repo. I didn't find any way of doing this via the pod command.
CocoaPods now provides a CLI for deleting pods, it can be done with:
pod trunk delete PODNAME VERSION
Original answer:
Removing specs is highly discouraged. If you push a spec intending to remove it later you shouldn't push it in the first place. This is because if any users are using your spec as soon as you remove it their project will break. If this was an accident you can submit a pull request to the specs repo removing your version. Also worth noting after removing this version you can never again push a spec with the same version number.
You can now delete specific versions of a Pod to correct an accidental push.
pod trunk delete PODNAME VERSION
You can also deprecate an entire Pod and all versions
pod trunk deprecate PODNAME
Reference: https://github.com/CocoaPods/cocoapods-trunk/blob/master/CHANGELOG.md#100beta1-2015-12-30
Note that you need to be using pod version 1.0.0.beta.2 or greater. Run pod --version to check. To install the beta, run sudo gem install pod -v 1.0.0.beta.3 (get the latest version from the ChangeLog)
This is what worked for me:
On GitHub, navigate to the main page of the repository.
Under your repository name, click Releases.
On the Releases page, to the right of the release you want to delete, click Edit.
Delete
source

Use private podspec repo only with Cocoapods

I host a private podspec repo internally, and I would like to use Cocoapods without depending on the public master spec repo. Is there a way to remove dependency on the master spec repo entirely?
The issue is that my company is frozen at cocoapods 0.34.1, and cannot update in time. However, recent changes to the master repo require a min version of 0.35.0. Any time I try to run any pod command, I get the following message.
[!] The "master" repo requires CocoaPods 0.35.0 - (currently using 0.34.1)
I understand what that means, and would like to remove the master repo as a dependency altogether, but it seems like that isn't an option. Any insights?
This created quite the fire drill for us today. We ended up changing our build scripts to run a custom pod install alias, which rolls back the min version in the CocoaPods-version.yml.
alias myPodInstall="sed -i -e 's/min: 0.35.0/min: 0.34.0/' ~/.cocoapods/repos/master/CocoaPods-version.yml; pod install"
Definitely a hack, but it unblocked us as we push for our release. Perhaps this helps others out there in a similar situation.

How to submit an updated podspec to trunk when you're not the owner?

I have updated a podspec file from CocoaPods Master Repo to use a more recent version of a library, updating some broken paths along the way.
I can pod spec lint and use it locally using:
pod 'LibraryX', :podspec => 'LibraryX.podspec.json'
However, since I'm not the owner of that Pod, I can not pod trunk push back my contribution.
What's the best way to propose a new podspec version for the trunk in that case?
This is the purpose of the ownership model with trunk. To update a spec like this you should get in contact with the current maintainer. You could also submit a pull request with your change but before it is merged the current maintainer will have to ok it.

How to do `pod trunk push` to replace an existing version of podspec

I already did a pod trunk push for a podspec version. Can I push it again and overwrite the existing one?
I tried it but it gives me this error.
$ pod trunk push Parse-iOS-SDK.podspec
Validating podspec
-> Parse-iOS-SDK (1.2.21)
[!] Unable to accept duplicate entry for: Parse-iOS-SDK (1.2.21)
Is there a similar command like git push -f force push it?
Ref:
http://guides.cocoapods.org/making/getting-setup-with-trunk
It is now possible to do this by first deleting the pod, and then re-pushing it:
pod trunk delete NAME VERSION
Then
pod trunk push PODSPEC
There should be a really good reason to do so, however, and the best practice is to never delete versions but instead push new ones (what Keith said).
2017 Edit: You can now delete pods on trunk, see this answer
Previous answer:
You cannot overwrite a spec using trunk. You should just push a new version with your changes. You can also submit a pull request to the specs repo but we recommend just pushing a new version.

Resources