How to update a single pod without touching other dependencies - cocoa

I understand that the following command will update a single pod: pod update <podname>. However this also updates the dependencies of other pods (pods that were not included in the update command) that you have previously installed. Is there a way to update a single pod and leave all other dependencies alone?

Make sure you have the latest version of CocoaPods installed.
$ pod update PODNAME was introduced recently.
See this issue thread for more information:
$ pod update
When you run pod update SomePodName, CocoaPods will try to find an updated version of the pod SomePodName, without taking into account the version listed in Podfile.lock. It will update the pod to the latest version possible (as long as it matches the version restrictions in your Podfile).
If you run pod update without any pod name, CocoaPods will update every pod listed in your Podfile to the latest version possible.

To install a single pod without updating existing ones-> Add that pod to your Podfile and use:
pod install --no-repo-update
To remove/update a specific pod use:
pod update POD_NAME
Tested!

It's 2015
So because pod update SomePod touches everything in the latest versions of cocoapods, I found a workaround.
Follow the next steps:
Remove SomePod from the Podfile
Run pod install
pods will now remove SomePod from our project and from the Podfile.lock file.
Put back SomePod into the Podfile
Run pod install again
This time the latest version of our pod will be installed and saved in the Podfile.lock.

just saying:
pod install - for installing new pods,
pod update - for updating existing pods,
pod update podName - for updating only specific pod without touching other pods,
pod update podName versionNum - for updating / DOWNGRADING specific pod without touching other pods

You can never get 100% isolation. Because a pod may have some shared dependencies and if you attempt to update your single pod, then it would update the dependencies of other pods as well. If that is ok then:
tl;dr use:
pod update podName
Why? Read below.
pod update will NOT respect the podfile.lock. It will override it — pertaining to that single pod
pod install will respect the podfile.lock, but will try installing every pod mentioned in the podfile based on the versions its locked to (in the Podfile.lock).
This diagram helps better understand the differences:
The major problem comes from the ~> aka optimistic operator.
Using exact versions in the Podfile is not enough
Some might think that specifying exact versions of their pods in their Podfile, like pod 'A', '1.0.0', is enough to guarantee that every user will have the same version as other people on the team.
Then they might even use pod update, even when just adding a new pod, thinking it would never risk updating other pods because they are fixed to a specific version in the Podfile.
But in fact, that is not enough to guarantee that user1 and user2 in our above scenario will always get the exact same version of all their pods.
One typical example is if the pod A has a dependency on pod A2 — declared in A.podspec as dependency 'A2', '~> 3.0'. In such case, using pod 'A', '1.0.0' in your Podfile will indeed force user1 and user2 to both always use version 1.0.0 of the pod A, but:
user1 might end up with pod A2 in version 3.4 (because that was A2's latest version at that time)
while when user2 runs pod install when joining the project later, they might get pod A2 in version 3.5 (because the maintainer of A2 might have released a new version in the meantime).
That's why the only way to ensure every team member work with the same versions of all the pod on each's the computer is to use the Podfile.lock and properly use pod install vs. pod update.
The above excerpt was all derived from pod install vs. pod update
I also highly recommend watching what does a podfile.lock do

Just a small notice.
pod update POD_NAME
will work only if this pod was already installed. Otherwise you will have to update all of them with
pod update
command

I'm using cocoapods version 1.0.1 and using pod update name-of-pod works perfectly. No other pods are updated, just the specific one you enter.

This is a bit of an outlier and not likely to be what the OP was dealing with, but pod update <podname> will not work in all cases if you are using a local pod on your computer.
In this situation, the only thing that will trigger pod update to work is if there is a change in the podspec file. However, making a change will also allow for pod install to work as well.
In this situation, you can just modify something minor such as the description or summary by one letter, and then you can run the install or update command successfully.

pod update POD_NAME will update latest pod but not update Podfile.lock file.
So, you may update your Podfile with specific version of your pod e.g pod 'POD_NAME', '~> 2.9.0' and then use command pod install
Later, you can remove the specific version naming from your Podfile and can again use pod install. This will helps to keep Podfile.lock updated.

Related

Creating new Cocoapod `Unable to find a specification` on pod install

I've gone through the Cocoapod guide for making a new pod.
The repo exists here: https://github.com/kkendall33/QuickInstantiating.
The QuickInstantiation pod spec looks like this:
But when I go to a different project and add QuickInstantiating to the Podfile:
and run pod install. I get this:
I just tested pod install with a different pod and it worked fine. This leads me to believe I'm doing something wrong with mine.
The pod must be pushed before it can be referred to by version. For testing, you can use the same path syntax -
pod 'QuickInstantiating', :path => 'relative/path'
like you used at https://github.com/kkendall33/QuickInstantiating/blob/master/Example/Podfile#L4
Otherwise you can push the pod to a private Specs repo if you do want to test the git repo before pushing the pod to trunk. Instructions at https://guides.cocoapods.org/making/private-cocoapods.

Why pod library still can be used after i delete it from Podfile?

I added this into my Podfile:
pod 'RDVTabBarController'
Then I ran pod install. Then I added import RDVTabBarController on my view controller and all works well.
I removed pod 'RDVTabBarController from the Podfile, then ran pod install again. Why can I still use it on my ViewController? Is RDVTabBarController still installed as a reference on my computer?
If you run pod update it should remove it from your project. I would also run a Clean from within Xcode to ensure that all build stages are started over from scratch.

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

How do you reduce the time needed for `pod install` with Cocoapods for a project with many dependencies?

My project has about 60 dependencies, listed one after another...
platform :ios, '7.1'
inhibit_all_warnings! # This will disable all the warnings for all pods!
target 'MyProj' do
pod 'First'
pod 'Second'
... # 57 more pods
pod 'Last'
end
Every pod install takes about 3-4 minutes.
When trying to restructure the project in to smaller pods, it takes hours and hours to change extract the relevant dependencies into private pods and it is very expensive to iterate.
How can I work on Podfiles and splitting application modules up more effectively?
Depending on the bottleneck that is happening you can try running pod install and telling CocoaPods not to update the specs repo:
pod install --no-repo-update
Note that this will cause issue if you add a new version of a pod that has not been downloaded locally let in which case you'll want to run:
pod repo update

CocoaPods block dependency installation

I haven't found the answer to this within the Podfile docs, so I'm not sure if it's possible.
I want to install a CocoaPods project which has 3 dependencies. I add it to my Podfile:
pod 'IDMPhotoBrowser'
and run install:
$ pod install
Installing DACircularProgress (2.1.0)
…
Installing IDMPhotoBrowser (1.2)
…
Installing SVProgressHUD (0.9)
However, I have a hacked up version of SVProgressHUD in my project which contains code not in the current repo. Additionally, SVProgressHUD 0.9 is from January, and there are months of additional commits since then. I would like to use my manually added version instead.
Can I specify in my Podfile that SVProgressHUD should not be installed, so that my manually added version is used? Or do I just need to delete it by hand every time I run pod install?
Alternatives
I know I could upload my fork to github and do something like:
pod 'SVProgressHUD', :git => '<my git repo>', :commit => '<my sha>'
but I'm hoping to not need to upload code just to get Cocoapods to do what I want.
It's not so much about blocking the dependency as it is overriding it with your own. This means that CocoaPods needs to find your local copy of SVProgressHUD before it activates IDMPhotoBrowser and looks for SVProgressHUD in the master spec repo.
You can achieve the setup you want by declaring your version of SVProgressHUD first in your Podfile using a local podspec:
Your custom version needs to be in a subdirectory of your project, with a valid podspec at the root of that directory, e.g., External/SVProgressHUD/SVProgressHUD.podspec.
Update your Podfile like this:
pod 'SVProgressHUD', :path => 'External/SVProgressHUD' # this needs to be declared first
pod 'IDMPhotoBrowser' # your custom pod will be used as the dependency here
If you don't have a local podspec, you should be able to take a copy of the 0.9 version of SVProgressHUD (and if necessary modify it to compile any new code you've added).

Resources