How to remove CocoaPods from a project?
Asked Answered
A

23

597

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.

Amontillado answered 7/5, 2013 at 19:54 Comment(4)
And remember: next time use git and just roll it back!Sycophant
Run pod deintegrateMaidie
Follow steps in this link medium.com/app-makers/…Middleweight
Awesome question thank you! And great answers to the guys below. Saved me time on my project.Iphlgenia
Z
1106

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!

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.

Zusman answered 7/5, 2013 at 20:21 Comment(11)
Thank God for this post. I got screwed by this nightmare... https://mcmap.net/q/16317/-library-not-found-for-lpods and I've had to remove CP for now. ThanksFenestration
(In my case - March 2014 - it related to the whole "Parse / Facebook liraries / architecture settings" madness. Might help someone reading. Again thanks.)Fenestration
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.Tonguing
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.Tonguing
In my case I needed to reset all the build configurations. This should be added to your excellent answer.Covenantor
What do you mean reset your build configurations?Zusman
Going to leave this here because it worked great for me: github.com/kylef/cocoapods-deintegrateAbed
In addition to the above, I had to delete DerivedData and DerivedData/ModuleCache to get rid of the warnings.Calvano
If anyone is wondering why a million warnings are popping up in Xcode, it's because you need to commit your changes on git/svnLonely
Works like a charm!Pieper
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.Delectation
S
526

pod deintegrate and pod clean are two designated commands to remove CocoaPods from your project or repository.

Here is the complete set of commands:

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

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

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

Shylashylock answered 13/1, 2016 at 11:16 Comment(6)
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 LibrariesMiocene
Since version 1.0.0beta8 Cocoapods create strange Build Phases with such names: 📦 Check Pods Manifest.lock. Check if they are removed after deintegrate.Lessor
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.Outmost
I more, rm Podfile.lockOvid
Also need to remove the "<project>.xcworkspace" file since it is no longer needed. Just use XCode to open the "<project>.xcodeproj" file.Pyre
Works in 2024. The 1st step is redundant.Glioma
L
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.

Lola answered 3/10, 2015 at 10:44 Comment(3)
Whoa! pod clean deletes your workspace, even if you have other projects in it! Be careful!Import
@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....:(Lola
This was the best and clean solution among all. Thnx Mate!Illyes
B
59
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

Biffin answered 17/3, 2017 at 3:18 Comment(3)
Nice, also worked here after already having deleted the most stuff by hand.Musicianship
deintegrate nukes your workspace. Be careful if you happen to need it.Siret
@Biffin you saved y life second time.Maryland
D
54

I think there an easier way to do that.

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

But, there are still some files remaining:

Podfile
Podfile.lock
Workspace

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

Finally, the uninstallation work is still not completed. cocoapods-clean doesn't clean the Podfile. Just run:

rm Podfile

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

Dominickdominie answered 26/2, 2015 at 7:20 Comment(4)
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.Playreader
Thanks and more details here if you run into issues after a successful deintegrate.Hickman
Thanks that was smooth using 'cocoapods-deintegrate'Ambrosia
Thanks, it works on macOS Monterey, because you currently can't install cocoapods (great, right?) more details (but not the solution) groups.google.com/g/cocoapods/c/Egpg8Yp6qsYJacquelinejacquelyn
Z
24

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!!!

Zanazander answered 15/2, 2021 at 14:4 Comment(1)
Nice answer, it's working ....Middleweight
K
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.

Kubiak answered 17/2, 2016 at 2:21 Comment(1)
Specially helpful, if you renamed a project with pods integrated.Doall
D
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 the Embed Pods Frameworks phase.
Decrial answered 2/4, 2015 at 4:36 Comment(2)
Right. If you don't do this, you will get build errors.Landy
If there are any other files dealing with Pods inside of Build Phases delete them too.Outmaneuver
S
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.

Savory answered 29/7, 2016 at 12:42 Comment(0)
Y
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.

Yusuk answered 10/9, 2015 at 6:34 Comment(0)
T
5
$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
$ rm Podfile
Targett answered 25/1, 2020 at 11:43 Comment(1)
After getting rid of all of the cocoapods gem uninstall cocoapods-deintegrate cocoapods-cleanBushmaster
C
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
Credulity answered 22/9, 2022 at 3:24 Comment(0)
M
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?

Mongo answered 27/6, 2016 at 22:18 Comment(0)
C
3

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.

Campos answered 28/6, 2018 at 12:28 Comment(1)
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.Christcross
S
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
Stupefaction answered 1/3, 2021 at 11:13 Comment(0)
A
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.

Agnusago answered 14/3, 2019 at 2:52 Comment(1)
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... guides.cocoapods.org/using/pod-install-vs-update.htmlAfterdamp
C
2

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

$ pod deintegrate
$ pod cache clean --all
$ pod install
Childbearing answered 14/2, 2023 at 11:18 Comment(0)
O
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
Okelley answered 30/3, 2016 at 11:15 Comment(0)
P
1
  1. Remove the podfile name from .plist
  2. Reinstall the pod again (use this link for pod installation)
Parvati answered 18/4, 2016 at 13:46 Comment(0)
P
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

Pucida answered 6/5, 2020 at 3:22 Comment(0)
J
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
Jermayne answered 5/2, 2018 at 15:48 Comment(0)
T
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.

Thyratron answered 28/4, 2019 at 16:46 Comment(0)
B
0

enter image description here

pictorial representation detailed

Banquette answered 7/8, 2019 at 3:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.