How to Clear or Clean Specific Pod from the Local Cocoapods Cache

How to clear or clean specific pod from the local cocoapods cache

Clearing a specific pod

pod cache clean --all # will clean all pods
pod cache clean 'FortifySec' --all # will remove all installed 'FortifySec' pods

Sample output of pod cache clean 'FortifySec', for pods not using semantic versioning, this could result in many copies of same pod in cache:

pod cache clean 'FortifySec'
1: FortifySec v2.2 (External)
2: FortifySec v2.2 (External)
...
...
18: FortifySec v2.2 (External)
19: FortifySec v2.2 (External)

Which pod cache do you want to remove?

Complete cleanup (pod reset)

rm -rf ~/Library/Caches/CocoaPods
rm -rf Pods
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod deintegrate
pod setup
pod install

Example of pod cache list prior to clean

pod cache list

FortifySec:
- Version: 2.2.1
Type: External
Spec: /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/External/FortifySec/ui99sd....podspec.json
Pod: /Users/j.d/Library/Caches/CocoaPods/Pods/External/FortifySec/yi23sd...-sdjc3
- Version: 2.2.1
Type: External
Spec: /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/External/FortifySec/dsfs-df23
Pod: /Users/j.d/Library/Caches/CocoaPods/Pods/External/FortifySec/dfs0d-2dfs
- Version: 2.2
Type: External
Spec: /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/External/FortifySec/u78hyt....podspec.json
Pod: /Users/j.d/Library/Caches/CocoaPods/Pods/External/FortifySec/e000sd
- Version: 2.2.2
Type: External
Spec: /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/External/FortifySec/s2d-df.podspec.json
Pod: /Users/j.d/Library/Caches/CocoaPods/Pods/External/FortifySec/ds34sd....
- Version: 2.2.1
Type: External
Spec: /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/External/FortifySec/sdfsdfdsf....podspec.json
Pod: /Users/j.d/Library/Caches/CocoaPods/Pods/External/FortifySec/edfs5d7...
AFNetworking:
- Version: 2.5.3
Type: Release
Spec: /Users/j.d/Library/Caches/CocoaPods/Pods/Specs/Release/AFNetworking/2.6.podspec.json
Pod: /Users/j.d/Library/Caches/CocoaPods/Pods/Release/AFNetworking/2.6.3-4e7e2

Notice the multiple pod cache for - Version: 2.2.1. It's a good idea to do so to get rid of unnecessary disk space used by pod cache.

How do I remove Cocoapod pods from a Flutter project?

Turns out the correct way to install and remove pods from a Flutter project is just to edit the pubspec.yaml file in the root directory!

Cocoapods needs to be installed, but it will automatically read the pubspec.yaml file and do the work from there! No need to run pod commands from terminal or otherwise.

How to remove CocoaPods from a project?

Removing CocoaPods from a project is possible, but not currently automated by the CLI. First thing, if the only issue you have is not being able to use an xcworkspace you can use CocoaPods with just xcodeprojs by using the --no-integrate flag which will produce the Pods.xcodeproj but not a workspace. Then you can add this xcodeproj as a subproject to your main xcodeproj.

If you really want to remove all CocoaPods integration you need to do a few things:

NOTE editing some of these things if done incorrectly could break your main project. I strongly encourage you to check your projects into source control just in case. Also these instructions are for CocoaPods version 0.39.0, they could change with new versions.

  1. Delete the standalone files (Podfile Podfile.lock and your Pods directory)
  2. Delete the generated xcworkspace
  3. Open your xcodeproj file, delete the references to Pods.xcconfig and libPods.a (in the Frameworks group)
  4. Under your Build Phases delete the Copy Pods Resources, Embed Pods Frameworks and Check Pods Manifest.lock phases.
  5. This may seem obvious but you'll need to integrate the 3rd party libraries some other way or remove references to them from your code.

After those steps you should be set with a single xcodeproj that existed before you integrated CocoaPods. If I missed anything let me know and I will edit this.

Also we're always looking for suggestions for how to improve CocoaPods so if you have an issues please submit them in our issue tracker so we can come up with a way to fix them!

EDIT

As shown by Jack Wu in the comments there is a third party CocoaPods plugin that can automate these steps for you. It can be found here. Note that it is a third party plugin and might not always be updated when CocoaPods is. Also note that it is made by a CocoaPods core team member so that problem won't be a problem.

Remove or uninstall library previously added : cocoapods

The unwanted side effects of simple folder delete or installing over existing installation have been removed by a script written by Kyle Fuller - deintegrate and here is the proper workflow:

  1. Install clean:

    sudo gem install cocoapods-clean
  2. Run deintegrate in the folder of the project:

    pod deintegrate
  3. Clean (this tool is no longer available):

    pod clean
  4. Modify your podfile (delete the lines with the pods you don't want to use anymore) and run:

    pod install

Done.



Related Topics



Leave a reply



Submit