587

What's the right way of removing CocoaPods from a project? I want to remove the whole CocoaPod. Due to some limitations imposed by my client I can't use it. I need to have just one xcodeproj instead of an xcworkspace.

jscs
  • 63,694
  • 13
  • 151
  • 195
Andres
  • 11,439
  • 12
  • 48
  • 87

23 Answers23

1103

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.

Keith Smiley
  • 61,481
  • 12
  • 97
  • 110
  • Thank God for this post. I got screwed by this nightmare... http://stackoverflow.com/questions/9863836/library-not-found-for-lpods and I've had to remove CP for now. Thanks – Fattie Mar 13 '14 at 22:32
  • 1
    (In my case - March 2014 - it related to the whole "Parse / Facebook liraries / architecture settings" madness. Might help someone reading. Again thanks.) – Fattie Mar 14 '14 at 07:44
  • I'm about to do this and the reason is that it regularly needs to recompile all of the Pod projects even though none of them have been touched, so it has slowed my build times considerably. – theLastNightTrain Apr 30 '14 at 22:06
  • Also the "update" flow seems if anything simpler with a static binary, so I'm not seeing the advantage to a pod approach on this particular project. – theLastNightTrain Apr 30 '14 at 22:07
  • In my case I needed to reset all the build configurations. This should be added to your excellent answer. – Johan Karlsson Oct 28 '14 at 15:18
  • What do you mean reset your build configurations? – Keith Smiley Oct 28 '14 at 16:18
  • 32
    Going to leave this here because it worked great for me: https://github.com/kylef/cocoapods-deintegrate – Jack Nov 18 '14 at 00:24
  • In addition to the above, I had to delete DerivedData and DerivedData/ModuleCache to get rid of the warnings. – Matthew Korporaal Aug 12 '15 at 14:10
  • 1
    If anyone is wondering why a million warnings are popping up in Xcode, it's because you need to commit your changes on git/svn – Achintya Ashok Mar 15 '17 at 01:42
  • Works like a charm! – Zhou Haibo Feb 16 '20 at 07:56
  • One more step that threw me for a bit. When you open the Project you'll still see a Pods Folder in Project Navigator. Delete it. – mswlogo Mar 21 '20 at 21:57
508

pod deintegrate and pod clean are two designated commands to remove CocoaPod from your project/repo.

Here is the complete set of commands:

$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod cache clean --all
$ rm Podfile

The original solution was found here: https://medium.com/@icanhazedit/remove-uninstall-deintegrate-cocoapods-from-your-xcode-ios-project-c4621cee5e42#.wd00fj2e5

CocoaPod documentation on pod deintegrate: https://guides.cocoapods.org/terminal/commands.html#pod_deintegrate

BadPirate
  • 25,802
  • 10
  • 92
  • 123
DevGansta
  • 5,564
  • 2
  • 16
  • 16
  • 4
    thanks, works (nearly) for me. After these commands i got a linker error during compilation. Solution was to remove the "Pods framework" from Targets->Build Phases->Link Binary With Libraries – uldo Jan 27 '16 at 16:17
  • Since version 1.0.0beta8 Cocoapods create strange Build Phases with such names: Check Pods Manifest.lock. Check if they are removed after deintegrate. – Timur Bernikovich Apr 21 '16 at 14:10
  • 1
    Please note that if you are on a machine that has not had cocoapods installed, you'll need to do gem install cocoapods before the pod command will work. This can happen if you restore or copy a project onto a new system. – NoelHunter Jan 09 '17 at 21:45
  • 3
    I more, `rm Podfile.lock` – Lal Krishna Oct 09 '20 at 12:04
  • 4
    Also need to remove the ".xcworkspace" file since it is no longer needed. Just use XCode to open the ".xcodeproj" file. – Ken Roy Jan 23 '22 at 21:57
77

To remove pods from a project completely you need to install two thing first...those are follows(Assuming you have already cocoa-pods installed in your system.)...

  1. Cocoapods-Deintegrate Plugin
  2. Cocoapods-Clean Plugin

Installation

  1. Cocoapods-Deintegrate Plugin

    Use this following command on your terminal to install it.

    sudo gem install cocoapods-deintegrate
    
  2. Cocoapods-Clean Plugin

    Use this following command on your terminal to install it.

    sudo gem install cocoapods-clean
    

Usage

First of all goto your project folder by using the as usual command like..

cd (path of the project) //Remove the braces after cd

Now use those two plugins to remove it completely as follows..

  1. Cocoapods-Deintegrate Plugin

    Use this following command on your terminal to deintegrate the pods from your project first.

     pod deintegrate
    

Deintegrating Pods

  1. Cocoapods-Clean Plugin

    After deintegration of pod from your project use this following command on your terminal to clean it completely.

     pod clean
    

    After completing the above tasks there should be the Podfile still remaining on your project directory..Just delete that manually or use this following command on the terminal..

     rm Podfile
    

Thats it...Now you have your project free from pods...Cleaned.

Removing Cocoapods from the system.

Any way try to use the following command on your terminal to uninstall/remove the coca-pods from your system.

sudo gem uninstall cocoapods

It will remove the coca-pods automatically.

Thanks. Hope this helped.

onCompletion
  • 6,500
  • 4
  • 28
  • 37
  • 8
    Whoa! `pod clean` *deletes your workspace*, even if you have other projects in it! Be careful! –  Jan 19 '16 at 23:00
  • 1
    @charl In case of cleaning pods from your single project you have to clear the workspace...but the method obviously not applicable for multiple projects associated with the single workspace....:( – onCompletion Jan 20 '16 at 06:25
  • 1
    This was the best and clean solution among all. Thnx Mate! – Syed Faizan Ahmed Jul 09 '20 at 13:56
55
pod deintegrate

After this cmd, no traces of Cocoapods left in your project.

But your workspace referencing the Pods project still remains, you need to should remove below 3 files manually:

xx.xcworkspace
Podfile
Podfile.lock

Then you can use your project again.

Have fun!

Test CocoaPod version = 1.2.0

beetstra
  • 7,942
  • 5
  • 40
  • 44
mistdon
  • 1,773
  • 16
  • 14
54

I think there's a more easy way to do that.

As edited by the accepted answer, now you can use a third party plugin cocoapods-deintegrate, it's reliable because its made by a CocoaPods core team member.

But,there're still some files remain:

Podfile
Podfile.lock
Workspace

You could remove them from your project manually,but there's also another tool for helping you to clean them, thanks cocoapods-clean.

Finally, the uninstallation work is still not completed, cocoapods-clean don't clean the Podfile, just run:

rm Podfile

Cheers!

Before removing you should ensure you have a backup of your project!

Crashalot
  • 33,605
  • 61
  • 269
  • 439
Allen
  • 6,745
  • 5
  • 41
  • 59
  • 1
    fwiw the problem with deintegrate is that it relies on gems and ruby, just like cocoapods. Currently I'm looking to remove pods because of difficulties with El Capitan and gems. Uninstallers ought to be available as stand-alone binaries. – nheagy Jul 16 '15 at 02:04
  • Thanks and more details [here](https://github.com/CocoaPods/cocoapods-deintegrate/issues/6) if you run into issues after a successful deintegrate. – Adam Johns Nov 05 '15 at 15:10
  • Thanks that was smooth using 'cocoapods-deintegrate' – shaikh May 30 '16 at 20:01
  • Thanks, it works on macOS Monterey, because you currently can't install cocoapods (great, right?) more details (but not the solution) https://groups.google.com/g/cocoapods/c/Egpg8Yp6qsY – WINSergey Nov 03 '21 at 17:33
23

I tried all these answers but it still wouldn't build, eventually I tried:

pod deintegrate
pod install

which actually worked!

It's like it needs to remove all the pod scripts from your build phases and re-add them back in for it to work, at least in my case.

David Rees
  • 6,792
  • 3
  • 31
  • 39
23

From terminal cd to move to the project folder. The below steps help to de-integrate the pod from the project

$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
$ rm Podfile

Then just open the project file and remove the Pod folder if it is still on the Project Explorer with red color. Build the project... It's ready to go!!!

Neha Vipin
  • 688
  • 6
  • 17
13

Keith's answer is great - I just want to point out that because Cocoapods 0.36 is starting to support Dynamic Frameworks, if you are using 'use_frameworks!' in your 'Podfile' and you wish to remove the Cocoapods, you must do this:

  • Under Build Phases delete Embed Pods Frameworks phase.
Serlite
  • 12,130
  • 5
  • 38
  • 49
Chao Ruan
  • 1,409
  • 2
  • 14
  • 13
9

There can be two aspects developer may face.

  • Either he wants to remove pods completely from project
  • developer wants to uninstall particular framework from project from pods.

In first case you have to use 'pod deintegrate' and follow several steps which are mentioned in the answers above.

For second case that is if you want to uninstall any particular framework which is installed there very simple way available in your pod file just comment the framework which you want to uninstall and run pod install command.

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'ProjectName' do
  # Uncomment this line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

    pod 'iCarousel', '~> 1.8'
#    pod 'Facebook-iOS-SDK', '~> 4.1'
#    pod 'ParseFacebookUtilsV4', '~> 1.11'
#    pod 'Parse', '~> 1.14'


end

Here I want to uninstall facebook and parse frameworks (which were installed using pods) and not iCarousel that is why I have updated my pod file like above.

Now if I run pod install it will keep iCarousel as it is in my project and will remove facebook and parse.

Aditya
  • 333
  • 3
  • 9
5
  1. The first thing that you will need to do is remove the Podfile, Podfile.lock, the Pods folder, and the generated workspace.
  2. Next, in the .xcodeproj, remove the references to the Pods.xcconfig files and the libPods.a file.
  3. Within the Build Phases project tab, delete the Check Pods Manifest.lock section (open), Copy Pods Resources section (bottom) and Embed Pod Resources(bottom).
  4. Remove Pods.framework.

The only thing you may want to do is include some of the libraries that you were using before. You can do this by simply draging whatever folders where in the pods folders into your project (I prefer to put them into my Supporting Files folder).

It worked for me.

sudo make install
  • 5,629
  • 3
  • 36
  • 48
Alvin George
  • 14,148
  • 92
  • 64
5
$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
$ rm Podfile
double-beep
  • 5,031
  • 17
  • 33
  • 41
5

How to remove the pod from your project Xcode

Open the directory of your project then run the scripts

$ pod deintegrate
$ pod clean
$ rm Podfile

Then you have to remove the .xcworkspace extension file manually

"ProjectName.xcworkspace"

or remove by script

$ rm projectname.xcworkspace
Chithian
  • 253
  • 3
  • 8
3

If not work, try
1. clean the project.
2. deleted derived data.

if you don't know how to delete derived data go here

How to "Delete derived data" in Xcode6?

Community
  • 1
  • 1
Ego Slayer
  • 1,987
  • 2
  • 22
  • 17
3

All the answers provided are valid and correct. However, when you run pod install and modify any of the fields containing any cocoapods configuration, clean and deintegrate stop working as expected.

In my case, I had, among others FRAMEWORK_SEARCH_PATHS overwritten on the Build Settings and it gets tedious when dealing with 40 targets...

enter image description here

enter image description here

The following ruby file intends to run the cocoapods commands to "fully" clean the project and it performs some extra clean up such as Build settings and removes the "Pod" folder from the project among others. The script might also contain actions performed by "clean" or "deintegrate"

require 'xcodeproj'

### HELPERS ###
# Array extension for non-Ruby rail
class Array
    # Wraps and object into an array
    #
    # @param object [Any] The object to be wrapped
    # @return [Any] The array with the value wrapped. If the object is nil, then returns empty array
    def self.wrap(object)
        if object.nil?
            []
        elsif object.respond_to?(:to_ary)
            object.to_ary || [object]
        else
            [object]
      end
    end
end

# Performs the cocoapods clean up actions. It will install the dependencies needed.
def cocoapod_clean_actions
    ## DEINTEGRATE
    puts "** Installing Cocoapods 'DEINTEGRATE' **"
    system("sudo gem install cocoapods-deintegrate")
    
    puts "** Performing Cocoapods 'DEINTEGRATE' **"
    system("pod deintegrate")
    
    ## CLEAN
    puts "** Installing Cocoapods 'CLEAN' **"
    system("sudo gem install cocoapods-deintegrate")
    
    puts "** Performing Cocoapods 'CLEAN' **"
    system("pod clean")
end

# Performs a clean up on the build settings removing all the identified pods leftovers
#
# @param project [Xcodeproj] Xcode project where to permorm the actions
def clean_build_settings(project)
    puts "** Removing Cocoapods references from 'BUILD SETTING' **"
    podsOcurrence = "PODS"

    project.targets.each { |target| 
        target.build_configurations.each { |build_configuration|
            puts "Inspecting BUILD_SETTINGS for TARGET => #{target.name} & CONFIGURATION => #{build_configuration.name}"
            build_settings = build_configuration.build_settings
            build_settings.each { |key, value|
                if key.include?(podsOcurrence)
                    build_settings.delete(key)
                else
                    clean(build_settings, key, podsOcurrence)
                end
            }
        }
    }
    project.save()
end

# Performs a clean-up on a specific key of the build settings by removing the occurrences given. It also cleans the value if empty.
#
# @param build_settings [Hash] Build Settings for a specific target and configuration
# @param flag [String] Key to find in the build_settings
# @param occurence [String] The occurence to be removed from the value of build settings key
def clean(build_settings, flag, occurence)
    puts "CLEAN => flag = #{flag}, ocurrence = #{occurence}"
    indexes = Array.new()
    build_settings_flag = Array.wrap(build_settings[flag])
    build_settings_flag.each_with_index { |value, index|
    if value.include?(occurence)
        previous_index = index - 1
            if previous_index >= 0 && build_settings_flag[previous_index].to_s&.start_with?("-")
                indexes.append(previous_index)
            end
            indexes.append(index)
        end
    }

    if indexes.count > 0
        build_settings_flag.delete_if.with_index { |_, index| 
            indexes.include? index
        }

        # Replace the value for the build setting
        if build_settings_flag.empty?
            puts "Removing empty array #{flag}"
            build_settings.delete(flag)
        else 
            puts "Reassining array #{flag}"
            build_settings[flag] = build_settings_flag
        end
    end
end

# Performs a clean up on the build settings removing all the identified pods leftovers
#
# @param project [Xcodeproj] Xcode project where to permorm the actions
def clean_build_phases(project)
    puts "** Removing Cocoapods references from 'BUILD_PHASES' **"
    project.targets.each { |target|
        #if target.name == "WhiteLabel" #TESTING
            puts "Inspecting BUILD_PHASES for TARGET => #{target.name}"
            target.shell_script_build_phases.each { |shell_script| 
                if shell_script.name.include?("[CP]")
                    puts "Removing '#{shell_script.name}' shell script"
                    shell_script.remove_from_project() 
                elsif shell_script.name == "Crashlytics Run Script"
                    puts "Deleting '#{shell_script.name}'"
                    # Add extra build phases such as the Crashlytics
                    #shell_script.remove_from_project()
                end
            }
            #break #TESTING
        #end #TESTING
    }
    project.save()
end

# Removes all the unwanted cocoapods files and folders from the project
#
# @param project [Xcodeproj] Xcode project where to permorm the actions
def remove_files_and_folders(project)
    puts "** Removing Cocoapods files and folders from project **"

    ## Project
    # BE CAREFUL WITH GROUP(LINK) NAME AND GROUP PATH(FOLDER)
    project.groups.find{ |group| group.path == "Pods" }&.remove_from_project()
    project.save()

    # File system
    system('rm -rf Pods')
    #system('rm Podfile')
end


### MAIN ###
puts "********** Cocoapods CLEAN UP **********"
cocoapod_clean_actions()

puts "********** Cocoapods EXTRA CLEAN UP **********"
project = Xcodeproj::Project.open "./WhiteLabel.xcodeproj"

clean_build_settings(project)
clean_build_phases(project)
remove_files_and_folders(project)

project.save()

And it can be called

ruby PodExtraClean.rb
Reimond Hill
  • 4,278
  • 40
  • 52
2

Delete all related pod files:

  • xx.xcworkspace
  • Podfile
  • Podfile.lock

and in the Project Navigator:

Click on the project name (blue icon) --> Targets (*) --> Build Phases --> Remove "[CP] Check Pods manifests.lock" (click on the "x")

(*) Click on the project name, you might have to click on "Show project and target list" to see the side bar first.

Neph
  • 1,823
  • 2
  • 31
  • 69
Mailavan C
  • 21
  • 2
  • I also deleted the "Pods" folder because I was only using a single one, otherwise just delete the single "NameOfThePod" folder inside the "Pods" folder. – Neph Jul 17 '19 at 13:11
2

If you just want to remove one pod and keep others you may have installed, open the podfile in your app directory and delete the one you want to remove. Then navigate to your app directory using terminal and type:

pod update

This will remove the pod you removed from the podfile. You will see it has been removed in the terminal:

Analyzing dependencies
Removing FirebaseUI
Removing UICircularProgressRing

Note that this method will also pull any updates to the other pods in your podfile. You may or may not want that.

TM Lynch
  • 403
  • 3
  • 13
  • Per the documentation, you should use `pod install` for adding/removing pods. This is specifically to avoid updating like you said here. You can read more on their 'Guides' on this very topic... https://guides.cocoapods.org/using/pod-install-vs-update.html – Mark A. Donohoe Aug 06 '19 at 14:41
1

I am gonna write what iv done very briefly (to delete any CocoaPods from my project)..

  1. delete any added folder (frameworks, Pods,...)
  2. delete any added files (PROJECT.xcworkspace, PodFile, PodFile.lock, Pods-PROJECT.debug.xcconfig, Pods-PROJECT.release.xcconfig,...)
  3. just leave your original ones (PROJECT, PROJECT_Tests, PROJECT.xcodeproj)
  4. remove framework reference from the project on xcode

To remove the framework reference from xcode:

  1. Use the Project Navigator
  2. Select Project
  3. Select Target PROJECT
  4. Select Build Phases from the top options
  5. leave the default groups (Target Dependencies, Compile Sources, Linked Binary with Libraries, Copy Bundle Resources) and delete any other
SoliQuiD
  • 2,093
  • 1
  • 25
  • 29
1
  1. Remove the podfile name from .plist
  2. Reinstall the pod again (use this link for pod installation)
Kampai
  • 22,848
  • 21
  • 95
  • 95
Bibin Joseph
  • 234
  • 2
  • 7
1

I don't think you need to deintegrate anymore. I was able to do it with the following command in terminal:

pod install

and it automatically removed the ones that are no longer in the podfile

1

The following command work for me to delete a specific element and the install is back.

`$ pod deintegrate
$ pod cache clean --all
$ pod install`
0

Use these Terminal's commands (Don't forget to use sudo at the beginning of new lines):

open:YourDir YouName$ sudo gem uninstall cocoapods
Password:?
Remove executables:
    pod, sandbox-pod

in addition to the gem? [Yn]  Y
Removing pod
Removing sandbox-pod
Successfully uninstalled cocoapods-1.4.0
open:YourDir YourName$ gem list --local | grep cocoapods
cocoapods-core (1.4.0)
cocoapods-deintegrate (1.0.2)
cocoapods-downloader (1.1.3)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.3.0)
cocoapods-try (1.1.0)

Uninstall the list one by one like this:

open:YourDir YourName$ sudo gem uninstall cocoapods-core
Successfully uninstalled cocoapods-core-1.4.0
open:YourDir YourName$ sudo gem uninstall cocoapods-trunk
Successfully uninstalled cocoapods-trunk-1.3.0
open:YourDir YourName$ sudo gem uninstall cocoapods-try
Successfully uninstalled cocoapods-try-1.1.0
open:YourDir YourName$ gem list --local | grep cocoapods
open:YourDir YourName$ sudo gem uninstall cocoapods-stats
Successfully uninstalled cocoapods-stats-1.0.0
open:YourDir YourName$ sudo gem uninstall cocoapods-search
Successfully uninstalled cocoapods-search-1.0.0
open:YourDir YourName$ sudo gem uninstall cocoapods-downloader
Successfully uninstalled cocoapods-downloader-1.1.3
open:YourDir YourName$ sudo gem uninstall cocoapods-plugins
Successfully uninstalled cocoapods-plugins-1.0.0
open:YourDir YourName$ gem list --local | grep cocoapods
cocoapods-deintegrate (1.0.2)
open:YourDir YourName$ sudo gem uninstall cocoapods-deintegrate
Successfully uninstalled cocoapods-deintegrate-1.0.2
open:YourDir YourName$ sudo gem uninstall cocoapods-stats
Successfully uninstalled cocoapods-stats-1.0.0
open:YourDir YourName$ sudo gem uninstall cocoapods-search
Successfully uninstalled cocoapods-search-1.0.0
open:YourDir YourName$ sudo gem uninstall cocoapods-downloader
Successfully uninstalled cocoapods-downloader-1.1.3
open:YourDir YourName$ sudo gem uninstall cocoapods-plugins
Successfully uninstalled cocoapods-plugins-1.0.0
open:YourDir YourName$ gem list --local | grep cocoapods
cocoapods-deintegrate (1.0.2)
open:YourDir YourName$ sudo gem uninstall cocoapods-deintegrate
Successfully uninstalled cocoapods-deintegrate-1.0.2
CrownFord
  • 709
  • 5
  • 15
0

I was able to remove my pods in the project using the CocoaPods app (Version 1.5.2). Afterwards I only deleted the podfile, podfile.lock and xcworkspace files in the folder.

Berkant
  • 31
  • 3
0

enter image description here

pictorial representation detailed

vilas deshmukh
  • 389
  • 2
  • 5