'How to remove CocoaPods from a project?
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.
Solution 1:[1]
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 xcodeproj
s 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.
- Delete the standalone files (
Podfile
Podfile.lock
and yourPods
directory) - Delete the generated
xcworkspace
- Open your
xcodeproj
file, delete the references toPods.xcconfig
andlibPods.a
(in theFrameworks
group) - Under your
Build Phases
delete theCopy Pods Resources
,Embed Pods Frameworks
andCheck Pods Manifest.lock
phases. - 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.
Solution 2:[2]
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
Solution 3:[3]
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.)...
- Cocoapods-Deintegrate Plugin
- Cocoapods-Clean Plugin
Installation
Cocoapods-Deintegrate Plugin
Use this following command on your terminal to install it.
sudo gem install cocoapods-deintegrate
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..
Cocoapods-Deintegrate Plugin
Use this following command on your terminal to deintegrate the pods from your project first.
pod deintegrate
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.
Solution 4:[4]
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!
Solution 5:[5]
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
Podifle
Podfile.lock
Then you can use your project again.
Have fun!
Test CocoaPod version = 1.2.0
Solution 6:[6]
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.
Solution 7:[7]
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!!!
Solution 8:[8]
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
deleteEmbed Pods Frameworks
phase.
Solution 9:[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.
Solution 10:[10]
- The first thing that you will need to do is remove the
Podfile
,Podfile.lock
, thePods
folder, and the generated workspace. - Next, in the
.xcodeproj
, remove the references to thePods.xcconfig
files and thelibPods.a
file. - Within the Build Phases project tab, delete the Check Pods Manifest.lock section (open), Copy Pods Resources section (bottom) and Embed Pod Resources(bottom).
- 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.
Solution 11:[11]
$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
$ rm Podfile
Solution 12:[12]
If not work, try
1. clean the project.
2. deleted derived data.
if you don't know how to delete derived data go here
Solution 13:[13]
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.
Solution 14:[14]
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.
Solution 15:[15]
I am gonna write what iv done very briefly (to delete any CocoaPods from my project)..
- delete any added folder (frameworks, Pods,...)
- delete any added files (PROJECT.xcworkspace, PodFile, PodFile.lock, Pods-PROJECT.debug.xcconfig, Pods-PROJECT.release.xcconfig,...)
- just leave your original ones (PROJECT, PROJECT_Tests, PROJECT.xcodeproj)
- remove framework reference from the project on xcode
To remove the framework reference from xcode:
- Use the Project Navigator
- Select Project
- Select Target PROJECT
- Select Build Phases from the top options
- leave the default groups (Target Dependencies, Compile Sources, Linked Binary with Libraries, Copy Bundle Resources) and delete any other
Solution 16:[16]
- Remove the
podfile
name from.plist
- Reinstall the pod again (use this link for pod installation)
Solution 17:[17]
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
Solution 18:[18]
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
Solution 19:[19]
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.
Solution 20:[20]
Solution 21:[21]
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...
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow