本文翻译自:How to remove CocoaPods from a project?
What's the right way of removing CocoaPods from a project? 从项目中删除CocoaPods的正确方法是什么? I want to remove the whole CocoaPod. 我要删除整个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. 我只需要一个xcodeproj而不是xcworkspace。
#1楼
参考:https://stackoom.com/question/16vWP/如何从项目中删除CocoaPods
#2楼
Removing CocoaPods from a project is possible, but not currently automated by the CLI. 可以从项目中删除CocoaPods,但目前尚无法通过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. 第一件事,如果唯一的问题是无法使用xcworkspace
,则可以使用--no-integrate
标志将CocoaPods与xcodeproj
使用,这将产生Pods.xcodeproj
而不是工作区。 Then you can add this xcodeproj
as a subproject to your main xcodeproj
. 然后,您可以将此xcodeproj
作为子项目添加到主xcodeproj
。
If you really want to remove all CocoaPods integration you need to do a few things: 如果您确实要删除所有CocoaPods集成,则需要做一些事情:
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. 此外,这些指令是对的CocoaPods版本0.39.0
,他们可以用新版本的变化。
- Delete the standalone files (
Podfile
Podfile.lock
and yourPods
directory) 删除独立文件(Podfile
Podfile.lock
和您的Pods
目录) - Delete the generated
xcworkspace
删除生成的xcworkspace
- Open your
xcodeproj
file, delete the references toPods.xcconfig
andlibPods.a
(in theFrameworks
group) 打开您的xcodeproj
文件,删除对Pods.xcconfig
和libPods.a
的引用(在Frameworks
组中) - Under your
Build Phases
delete theCopy Pods Resources
,Embed Pods Frameworks
andCheck Pods Manifest.lock
phases. 在您的Build Phases
删除Copy Pods Resources
,Embed Pods Frameworks
和Check Pods Manifest.lock
阶段。 - 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. 完成这些步骤后,应使用集成CocoaPods之前存在的单个xcodeproj
进行设置。 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! 此外,我们一直在寻找有关如何改善CocoaPods的建议,因此,如果您遇到问题,请在我们的问题跟踪器中提交它们,以便我们提出解决问题的方法!
EDIT 编辑
As shown by Jack Wu in the comments there is a third party CocoaPods plugin that can automate these steps for you. 如Jack Wu在评论中所示 ,有一个第三方CocoaPods插件可以为您自动执行这些步骤。 It can be found here . 可以在这里找到。 Note that it is a third party plugin and might not always be updated when CocoaPods is. 请注意,它是第三方插件,可能在CocoaPods更新时可能不会总是更新。 Also note that it is made by a CocoaPods core team member so that problem won't be a problem. 还要注意,它是由CocoaPods核心团队成员制作的,因此不会出现问题。
#3楼
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. 按照接受的答案进行编辑,现在您可以使用第三方插件cocoapods-deintegrate ,它是可靠的,因为它是由CocoaPods核心团队成员制作的。
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 . 您可以手动将它们从项目中删除,但是感谢cocoapods-clean ,还有另一个工具可以帮助您清洁它们。
Finally, the uninstallation work is still not completed, cocoapods-clean
don't clean the Podfile
, just run: 最后,卸载工作仍未完成, cocoapods-clean
不会清除Podfile
,只需运行:
rm Podfile
Cheers! 干杯!
Before removing you should ensure you have a backup of your project! 删除之前,应确保已备份项目!
#4楼
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!' Keith的回答很好-我只想指出,因为Cocoapods 0.36开始支持Dynamic Frameworks ,如果您使用的是'use_frameworks!'。 in your 'Podfile' and you wish to remove the Cocoapods, you must do this: 在“ Podfile”中,并且您希望删除Cocoapods,必须执行以下操作:
- Under
Build Phases
deleteEmbed Pods Frameworks
phase. 在“Build Phases
删除“Embed Pods Frameworks
阶段。
#5楼
- The first thing that you will need to do is remove the
Podfile
,Podfile.lock
, thePods
folder, and the generated workspace. 您需要做的第一件事是删除Podfile
,Podfile.lock
,Pods
文件夹和生成的工作区。 - Next, in the
.xcodeproj
, remove the references to thePods.xcconfig
files and thelibPods.a
file. 接下来,在.xcodeproj
,删除对Pods.xcconfig
文件和libPods.a
文件的引用。 - Within the Build Phases project tab, delete the Check Pods Manifest.lock section (open), Copy Pods Resources section (bottom) and Embed Pod Resources(bottom). 在“构建阶段”项目选项卡中,删除“检查Pod Manifest.lock”部分(打开),“复制Pod资源”部分(底部)和“嵌入Pod资源”(底部)。
- Remove
Pods.framework
. 删除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). 您可以通过简单地将pod文件夹中的任何文件夹拖到项目中来完成此操作(我更喜欢将它们放入我的Supporting Files文件夹中)。
It worked for me. 它为我工作。
#6楼
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.)... 要从项目中完全删除Pod,您需要先安装两件事...以下是(假设您的系统中已经安装了cocoa-pods。)...
- Cocoapods-Deintegrate Plugin Cocoapods-Deintegrate插件
- Cocoapods-Clean Plugin Cocoapods-Clean插件
Installation 安装
Cocoapods-Deintegrate Plugin Cocoapods-Deintegrate插件
Use this following command on your terminal to install it. 在终端上使用以下命令进行安装。
sudo gem install cocoapods-deintegrate
Cocoapods-Clean Plugin Cocoapods-Clean插件
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 Cocoapods-Deintegrate插件
Use this following command on your terminal to deintegrate the pods from your project first. 在终端上使用以下命令首先将项目中的Pod集成在一起。
pod deintegrate
Cocoapods-Clean Plugin Cocoapods-Clean插件
After deintegration of pod from your project use this following command on your terminal to clean it completely. 将Pod从项目中解集成后,请在终端上使用以下命令彻底清洁它。
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.. 完成上述任务后,Podfile仍应保留在您的项目目录中。只需手动删除该文件或在终端上使用以下命令。
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. 希望这会有所帮助。