xcode 使用 cocoapods 时,更改 PRODUCT_NAME 的最佳方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31120403/
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
When using cocoapods, what is the best way to change the PRODUCT_NAME?
提问by chris P
I created an app with name "ABC". Months later I decided to change the name to "ABCD". I believe the way I changed it, was in my Podfile, I changed target "ABC" do
to target "ABCD" do
. However, I recall going through quite a few issues/errors afterward in my workspace that caused a lot of stress. It was so long ago that I can't quite recall though.
我创建了一个名为“ABC”的应用程序。几个月后,我决定将名称更改为“ABCD”。我相信,我改变了它的方式,在我Podfile,我换target "ABC" do
到target "ABCD" do
。但是,我记得后来在我的工作区中遇到了很多问题/错误,这造成了很大的压力。不过那是很久以前的事了,我记不太清了。
Now I'm ready to submit, and I want to change the name one last time. I've changed the name in iTunes Connect, but now I want to change my PRODUCT_NAME, and my bundle identifier to match.
现在我准备提交了,我想最后一次改名。我在 iTunes Connect 中更改了名称,但现在我想更改我的 PRODUCT_NAME 和我的包标识符以匹配。
What is the best way to do this? Should I change the target fields in my Podfile? Or should I leave them, and just change something else in Xcode? Or do I need to change both or more than one thing?
做这个的最好方式是什么?我应该更改 Podfile 中的目标字段吗?还是我应该离开它们,然后在 Xcode 中更改其他内容?还是我需要同时更改两件事或多于一件事?
回答by Warren Burton
When you have a Pod file the .xcworkspace
and Pods.xcodeproj
is generated dynamically by the pod install
process.
当你有一个 Pod 文件时,.xcworkspace
和Pods.xcodeproj
是由pod install
进程动态生成的。
So one way to deal with this is
所以处理这个问题的一种方法是
- Change your product name
- Close the project in Xcode
- Discard the existing
.xcworkspace
,Pods
folder &Podfile.lock
- Run
pod install
again.
- 更改您的产品名称
- 在 Xcode 中关闭项目
- 丢弃现有的
.xcworkspace
,Pods
文件夹 &Podfile.lock
- 再跑
pod install
。
The cocoapods engine will regenerate its project, pull the Pods from its cache and recreate its Pods.xcodeproj
with the new project settings.
cocoapods 引擎将重新生成它的项目,从它的缓存中提取 Pods 并Pods.xcodeproj
使用新的项目设置重新创建它。
This might be a little more complex in the case where you have other dependancies besides your main project and the Pods
project in your workspace.
如果除了主项目和Pods
工作区中的项目之外还有其他依赖项,这可能会更复杂一些。
You'll probably want to have everything committed to source control before you do this so you can revert if it goes wrong.
在执行此操作之前,您可能希望将所有内容都用于源代码控制,以便在出错时可以恢复。
回答by Sergey Sahakyan
I solved if for my project with this steps.
我用这个步骤解决了我的项目。
I install cocoapods-deintegrate
[sudo] gem install cocoapods-deintegrate
and call pod deintegrate on my project.
open XCode, click on project name and click again with delay to rename, follow xcode instructions
run pod install again on your project.
NOTE: if you are just Capitalising, or Uppercassing project name do it with other temp name: for me locdel->aaa->Locdel.
回答by nitsuka
I've been scouting the internet to no avail looking for an answer to this. While editing the podfile and running pod install again fixes the renaming problem, in my case it broke my application as those pods had evolved while my app had stayed the same. If you have concerns about backwards compatibility and don't want to reinstall your dependencies I suggest you do as I did and edit directly the .xcworkspace and .xcodeproj files using a text editor.
我一直在互联网上寻找答案,但无济于事。在编辑 podfile 并再次运行 pod install 修复了重命名问题时,在我的情况下,它破坏了我的应用程序,因为这些 pod 已经发展,而我的应用程序保持不变。如果您担心向后兼容性并且不想重新安装依赖项,我建议您像我一样使用文本编辑器直接编辑 .xcworkspace 和 .xcodeproj 文件。