xcode 如何从项目中删除 CocoaPods?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16427421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove CocoaPods from a project?
提问by Andres
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.
从项目中删除 CocoaPods 的正确方法是什么?我想删除整个 CocoaPod。由于我的客户施加的一些限制,我无法使用它。我只需要一个 xcodeproj 而不是 xcworkspace。
回答by Keith Smiley
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
.
从项目中删除 CocoaPods 是可能的,但目前不能由 CLI 自动化。首先,如果您遇到的唯一问题是无法xcworkspace
使用xcodeproj
s ,则可以通过使用--no-integrate
将生成Pods.xcodeproj
但不是工作区的标志来使用 CocoaPods 和s 。然后您可以将其xcodeproj
作为子项目添加到您的主xcodeproj
.
If you really want to remove all CocoaPods integration you need to do a few things:
如果你真的想删除所有 CocoaPods 集成,你需要做一些事情:
NOTEediting 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) - 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.
- 删除独立文件(
Podfile
Podfile.lock
和您的Pods
目录) - 删除生成的
xcworkspace
- 打开您的
xcodeproj
文件,删除对Pods.xcconfig
和libPods.a
(在Frameworks
组中)的引用 - 在您
Build Phases
删除Copy Pods Resources
,Embed Pods Frameworks
和Check Pods Manifest.lock
阶段。 - 这可能看起来很明显,但您需要以其他方式集成 3rd 方库或从代码中删除对它们的引用。
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.
在这些步骤之后,您应该使用xcodeproj
集成 CocoaPods 之前存在的单个设置。如果我错过了什么让我知道,我会编辑这个。
Also we're always looking for suggestions for how to improve CocoaPods so if you have an issues please submit them in our issue trackerso we can come up with a way to fix them!
此外,我们一直在寻找有关如何改进 CocoaPods 的建议,因此如果您遇到问题,请在我们的问题跟踪器中提交它们,以便我们想出解决它们的方法!
EDIT
编辑
As shownby Hyman 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.
正如Hyman Wu 在评论中所示,有一个第三方 CocoaPods 插件可以为您自动执行这些步骤。可以在这里找到。请注意,它是第三方插件,当 CocoaPods 更新时,它可能不会总是更新。另请注意,它是由 CocoaPods 核心团队成员制作的,因此该问题不会成为问题。
回答by DevGansta
pod deintegrate
and pod clean
are two designated commands to remove CocoaPod from your project/repo.
pod deintegrate
和pod clean
是从项目/存储库中删除 CocoaPod 的两个指定命令。
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
原始解决方案在这里找到: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
CocoaPod 文档pod deintegrate
:https: //guides.cocoapods.org/terminal/commands.html#pod_deintegrate
回答by onCompletion
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,您需要先安装两件事...如下(假设您已经在系统中安装了可可豆。)...
- Cocoapods-Deintegrate Plugin
- Cocoapods-Clean Plugin
- Cocoapods-Deintegrate 插件
- Cocoapods-Clean 插件
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
Cocoapods-Deintegrate 插件
在终端上使用以下命令进行安装。
sudo gem install cocoapods-deintegrate
Cocoapods-Clean 插件
在终端上使用以下命令进行安装。
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-Deintegrate 插件
首先在您的终端上使用以下命令从您的项目中分解 pod。
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
Cocoapods-Clean 插件
从项目中分离 pod 后,在终端上使用以下命令将其彻底清理。
pod clean
完成上述任务后,Podfile 应该仍然保留在您的项目目录中。只需手动删除它或在终端上使用以下命令即可。
rm Podfile
Thats it...Now you have your project free from pods...Cleaned.
就是这样......现在你的项目没有豆荚......清理。
Removing Cocoapods from the system.
从系统中删除 Cocoapods。
Any way try to use the following command on your terminal to uninstall/remove the coca-pods from your system.
无论如何尝试在您的终端上使用以下命令从您的系统中卸载/删除 coca-pods。
sudo gem uninstall cocoapods
It will remove the coca-pods automatically.
它会自动移除古柯豆。
Thanks. Hope this helped.
谢谢。希望这有帮助。
回答by Allen
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!
在删除之前,您应该确保您有项目的备份!
回答by mistdon
pod deintegrate
pod deintegrate
After this cmd, no traces of Cocoapods left in your project.
在这个 cmd 之后,你的项目中没有任何 Cocoapods 的痕迹。
But your workspace referencing the Pods project still remains, you need to should remove below 3 files manually:
但是您引用 Pods 项目的工作区仍然存在,您需要手动删除以下 3 个文件:
xx.xcworkspace
Podifle
Podfile.lock
xx.xcworkspace
Podifle
Podfile.lock
Then you can use your project again.
然后您可以再次使用您的项目。
Have fun!
玩得开心!
Test CocoaPod version = 1.2.0
测试 CocoaPod 版本 = 1.2.0
回答by David Rees
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.
就像它需要从构建阶段中删除所有 pod 脚本并重新添加它们以使其工作,至少在我的情况下是这样。
回答by Chao Ruan
Keith's answer is great - I just want to point out that because Cocoapods 0.36is 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:
基思的回答很棒 - 我只想指出,因为Cocoapods 0.36开始支持动态框架,如果您使用的是“use_frameworks!” 在您的“Podfile”中,并且您希望删除 Cocoapods,您必须执行以下操作:
- Under
Build Phases
deleteEmbed Pods Frameworks
phase.
- 在
Build Phases
删除Embed Pods Frameworks
阶段。
回答by SZ.
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.
- 他要么想从项目中完全删除 pod
- 开发人员希望从 pod 中卸载项目中的特定框架。
In first case you have to use 'pod deintegrate' and follow several steps which are mentioned in the answers above.
在第一种情况下,您必须使用“pod deintegrate”并按照上述答案中提到的几个步骤进行操作。
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.
对于第二种情况,如果您想卸载安装在您的 pod 文件中的任何特定框架,只需在您的 pod 文件中以非常简单的方式可用,只需注释要卸载的框架并运行 pod install 命令。
# 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.
在这里,我想卸载 facebook 和解析框架(使用 pod 安装)而不是 iCarousel,这就是为什么我像上面那样更新了我的 pod 文件。
Now if I run pod install it will keep iCarousel as it is in my project and will remove facebook and parse.
现在,如果我运行 pod install 它将保持 iCarousel 在我的项目中,并将删除 Facebook 并解析。
回答by A.G
- 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
.
- 您需要做的第一件事是删除
Podfile
、Podfile.lock
、Pods
文件夹和生成的工作区。 - 接下来,在 中
.xcodeproj
,删除对Pods.xcconfig
文件和libPods.a
文件的引用。 - 在 Build Phases 项目选项卡中,删除 Check Pods Manifest.lock 部分(打开)、Copy Pods Resources 部分(底部)和 Embed Pod Resources(底部)。
- 删除
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).
您可能唯一想做的就是包含一些您以前使用过的库。您可以通过简单地将 pods 文件夹中的任何文件夹拖到您的项目中来完成此操作(我更喜欢将它们放入我的 Supporting Files 文件夹中)。
It worked for me.
它对我有用。
回答by Dynamic Methods
$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
$ rm Podfile