374

I added an external framework via cocoapods into my iOS application. How can i remove that library from the project?

Lithu T.V
  • 19,955
  • 12
  • 56
  • 101

10 Answers10

488

Remove lib from Podfile, then pod install again.

Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121
fannheyward
  • 18,599
  • 12
  • 71
  • 109
  • 13
    When I do this, I'm left with dozens of warnings in XCode 5 complaining that the workspace can't find the removed files. I've tried to manually clean this up but have not been successful. How can you cleanly remove a pod? – Matt Mombrea Dec 19 '13 at 01:18
  • 8
    Find the pods file in Finder, then delete each of the individual pods (you'll notice they're missing the .h and .m files). Then `pod update`. That worked for me. – AMayes Jan 09 '14 at 22:32
  • 1
    Also remember if library A is referenced by library B, which is also in Podfile, library A won't be removed even if you remove its entry and run "pod install". Library A will only be removed if you also removed the entry for library B. – CodeBrew Mar 06 '15 at 05:20
  • 9
    You also get the warnings that @MattMombrea mentions if you successfully deleted the podfiles, but haven't committed the change. Make sure everything is committed to the code repository. – HughHughTeotl Oct 02 '15 at 11:10
  • 1
    The article that @vrunoa mentions is now a dead link. This article is helpful: http://stackoverflow.com/questions/16427421/how-to-remove-cocoapods-from-a-project – Lane Rettig Jan 14 '16 at 19:51
  • 2
    I want to delete a framework installed by pod without updating or installing podfile – Anand Prakash Nov 18 '16 at 11:03
  • Installing podfile only means that you use the dependencies currently there in the podfile, which is exactly what you want to do. If you don't do that, you will still depend on the deleted libraries, which would be bad. Update, however, is unnecessary. – Karolina Hagegård Aug 03 '22 at 07:26
421

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.

Nabeel Khan
  • 3,715
  • 2
  • 24
  • 37
Michal
  • 15,429
  • 10
  • 73
  • 104
  • 2
    This pod should be the accepted answer, because it is much more thorough. Although, before following this workflow, I would suggest to clear the contents of the project's Derived Data directory, and make sure to commit the project's changes to the existing code repository. Finally, after running `pod install`, I opened the Xcode xcworkspace file, performed a full clean on the build folder (alt+shift+command+K), and the warnings/linker errors were gone. Pods were now successfully uninstalled from the project. – Mark Barrasso Jan 30 '17 at 21:30
  • 1
    Note to @All: This command`cocoapods-clean` deletes the `Podfile` and `.xcworkspace` – Suhaib Jun 15 '17 at 11:02
  • 9
    Seems now `pod deintegrate` is official: http://guides.cocoapods.org/terminal/commands.html#pod_deintegrate No need for `sudo gem install cocoapods-deintegrate`. – Pang Aug 07 '17 at 04:54
  • I found that when I removed SwiftLint from my project, that I also had to manually remove a line referencing it from the run script. – Vince O'Sullivan Apr 05 '18 at 07:55
  • 5
    I second that from @ZinWinHtet, when I try `pod clean` I get: `$ pod clean [!] Unknown command: clean` – ScottyBlades Sep 21 '18 at 22:12
  • 3
    yes... , pod clean no longer exists anymore I think. – Zin Win Htet Sep 24 '18 at 07:38
  • @Outsider that is interesting. What is your situation? – Michal Feb 26 '19 at 10:01
  • I had a project where I incorrectly added a podfile. I then changed it by changing teh text and restarting teh project which is incorrect. Then I tried this and it did not work at that point –  Feb 26 '19 at 21:30
  • Fully completing all these steps did the trick. I still had to remove a few Pods-related files from the Finder and Xcode, but the Xcode project file built correctly after replacement of the pods with Swift Package Manager. – Womble Feb 10 '20 at 03:03
  • So if the command `pod clean` no longer exists, should I still run `sudo gem install cocoapods-clean`? – Karolina Hagegård Aug 03 '22 at 06:51
  • Hey..... There are no pod names in my `Podfile`! There's only the line: `flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))`!... In the `Podfile.lock` file, there's a list of pod names, but I'm not supposed to edit that one, am I?..... – Karolina Hagegård Aug 03 '22 at 07:22
  • I followed these steps but still ended up with many duplicates in the Pods folder. So I deleted the Pods folder before `pod install` and it worked. – Jose Santos Aug 28 '23 at 20:02
31
  1. Remove the library from your Podfile

  2. Run pod install on the terminal

aristotll
  • 8,694
  • 6
  • 33
  • 53
user5807443
  • 311
  • 3
  • 3
  • If I'm using Flutter, can I run `flutter clean` - `flutter pub get` instead of `pod install`? Just wondering... – Karolina Hagegård Aug 03 '22 at 06:54
  • Hey..... There are no pod names in my `Podfile`! There's only the line: `flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))`!... In the `Podfile.lock` file, there's a list of pod names, but I'm not supposed to edit that one, am I?..... – Karolina Hagegård Aug 03 '22 at 07:21
8

None of these worked for me. I have pod version 1.5.3 and the correct method was to remove the pods that were not longer needed from the Podfile and then run:

pod update

This updates your Podfile.lock file from your Podfile, removes libraries that have been removed and updates all of your libraries.

src
  • 117
  • 1
  • 4
  • 3
    You don't need to update all the libraries in your project (something that can be very dangerous) just to remove a library. There are much better ways in this thread including removing the pod from your podfile and then running `pod install` – Braden Holt May 26 '20 at 20:20
  • 1
    This updates all versions of your libraries and naturally removes the one that is not present anymore in the Podfile, but do you really want to update the libraries ? Removing the pod and `pod install` is the correct way. – Karim Mortabit Jun 02 '20 at 23:25
  • Hey..... There are no pod names in my `Podfile`! There's only the line: `flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))`!... In the `Podfile.lock` file, there's a list of pod names, but I'm not supposed to edit that one, am I?..... – Karolina Hagegård Aug 03 '22 at 07:21
3

To completely remove Pod or Cocoapods Framework from your Project repository !

sudo gem install cocoapods-clean
pod deintegrate
pod clean

Then Try to remove the File

Pods

Podfile

Podfile.lock

yourProjectName.xcworkspace

Chithian
  • 253
  • 3
  • 8
2

First, determine which versions of Cocoapods are installed :

gem list --local | grep cocoapods

You get output as this:

cocoapods (1.11.2)
cocoapods-clean (0.0.1)
cocoapods-core (1.11.2, 1.10.2, 1.10.1)
cocoapods-deintegrate (1.0.4)

To completely remove, issue the following commands:

gem uninstall cocoapods
gem uninstall cocoapods-clean
gem uninstall cocoapods-core
gem uninstall cocoapods-deintegrate

Running again to confirm that Cocoapods has been removed:

gem list --local | grep cocoapods

You may have residual artefacts in a hidden folder in your directory. Remove these with:

rm -rf ~/.cocoapods
1
  1. Remove pod name(which to remove) from Podfile and then
  2. Open Terminal, set project folder path
  3. Run pod install --no-integrate
K.D
  • 516
  • 3
  • 14
  • 1
    I'm getting this error: `[!] Unknown option: '--no-integrate'` – neoneye Nov 23 '18 at 12:00
  • Hey..... There are no pod names in my `Podfile`! There's only the line: `flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))`!... In the `Podfile.lock` file, there's a list of pod names, but I'm not supposed to edit that one, am I?..... – Karolina Hagegård Aug 03 '22 at 07:26
0

Remove pod name from Podfile then Open Terminal, set project folder path and Run pod update command.

NOTE: pod update will update all the libraries to the latest version and will also remove those libraries whose name have been removed from podfile.

Roohul
  • 1,009
  • 1
  • 15
  • 26
  • Hey..... There are no pod names in my `Podfile`! There's only the line: `flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))`!... In the `Podfile.lock` file, there's a list of pod names, but I'm not supposed to edit that one, am I?..... – Karolina Hagegård Aug 03 '22 at 07:21
0

Got this trying to install google_sign_in with flutter. Just had to remove the AppAuth library stuff from cocoapods, then 'pod install' in ios directory. Then I had to remove the flutter plugin, then I had to reinstall flutter plugin, then redo pod install. Then it worked. So I guess weird caching.

HangarRash
  • 7,314
  • 5
  • 5
  • 32
user3413723
  • 11,147
  • 6
  • 55
  • 64
0

Remove the Pod without hurting other Pods or their versions.

remove the pod that is no longer needed from the PodFile and run

pod install --no-repo-update
Muhammad Ali
  • 587
  • 5
  • 9