Xcode - 重命名项目导致问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1106097/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:40:15  来源:igfitidea点击:

Xcode - renaming project causes problem

iphonexcodeprojectrename

提问by quano

I'm currently working on an iphone application. I started working on this from a project template that I found on the internet. Now I want to rename this project. I've successfully renamed the actual project file, folder and the executables and some other stuff, but there is one weird problem. If I try running the application on my iphone device, Xcode refuses to run the executable with the new name - it's trying to run the old one with the old name instead, and thus it happens that it says: "No launchable executable present at path." Which is true, since the path is wrong (wrong name). The weird thing is that it works on the iphone simulator - it's using the correct executable path.

我目前正在开发一个 iphone 应用程序。我从我在互联网上找到的一个项目模板开始研究这个。现在我想重命名这个项目。我已经成功地重命名了实际的项目文件、文件夹和可执行文件以及其他一些东西,但是有一个奇怪的问题。如果我尝试在我的 iphone 设备上运行该应用程序,Xcode 拒绝使用新名称运行可执行文件 - 它会尝试使用旧名称运行旧的,因此它会说:“路径中不存在可启动的可执行文件.” 这是真的,因为路径错误(名称错误)。奇怪的是它可以在 iphone 模拟器上运行——它使用了正确的可执行路径。

Any help would be appreciated.

任何帮助,将不胜感激。

回答by Colin Gislason

In 3.2.1 on Snow Leopard, there is a "Project->Rename..." menu item that works like a charm. I think it was introduced in 3.2. Shame that it's Snow Leopard only.

在 Snow Leopard 的 3.2.1 中,有一个“项目->重命名...”菜单项,它的作用就像一个魅力。我认为它是在 3.2 中引入的。可惜只有雪豹。

回答by Reed Olsen

Renaming Xcode projects can be an absolute nightmare. I personally feel that the best way to "Rename" a project is to create a new Xcode project and copy in the necessary files. I know this seems inconvenient, but it's the most straight-forward approach that I know of.

重命名 Xcode 项目绝对是一场噩梦。我个人认为“重命名”项目的最佳方法是创建一个新的 Xcode 项目并复制必要的文件。我知道这看起来很不方便,但这是我所知道的最直接的方法。

Currently, renaming a project involves doing a couple of find/replaces on the project, and changing things in the project settings.

目前,重命名项目涉及对项目进行几次查找/替换,以及更改项目设置中的内容。

I would love if Xcode automated this for you. This is one thing where Eclipse really shines as an IDE.

如果 Xcode 为您自动执行此操作,我会很高兴。这是 Eclipse 作为 IDE 真正闪耀的地方。

Good luck!

祝你好运!

回答by quano

http://aplus.rs/cocoa/how-to-rename-project-in-xcode-3x/

http://aplus.rs/cocoa/how-to-rename-project-in-xcode-3x/

I found that to work quite well. Basically, if it's only the executable name you want to change, then open the main project file (the .xcodeproj) as a folder (right click > show package contents), and open the files in there. Then search them for (regular expression this) product.*name, and for each item you find, replace that which is on the right side of the equal sign to what you want your executable file to be named.

我发现它工作得很好。基本上,如果它只是您想要更改的可执行文件名称,则将主项目文件(.xcodeproj)作为文件夹打开(右键单击 > 显示包内容),然后打开其中的文件。然后在它们中搜索(正则表达式 this)product.*name,对于您找到的每个项目,将等号右侧的内容替换为您希望为可执行文件命名的内容。

I used the text editor smultron for that. Awsome program...

为此,我使用了文本编辑器 smultron。牛逼的节目...

回答by retcon

I just want to add to the above answers that Apple have made this relatively easy in XCode 3.2 - just rename the whole project in Project->Rename and also change the product name in the project settings...

我只想补充上述答案,Apple 在 XCode 3.2 中使这相对容易 - 只需在 Project->Rename 中重命名整个项目,并在项目设置中更改产品名称...

...but after doing that, I still got the 'No launchable executable...' message.

...但这样做之后,我仍然收到“没有可启动的可执行文件...”消息。

The key is to restart XCodeafter this point (it seems actually necessary to do this), and everything should be okay.

关键是在这之后重启XCode(看来确实有必要这样做),一切都应该没问题了。

Just hoping this saves someone a few minutes of confusion!

只是希望这可以为某人节省几分钟的混乱!

回答by JordanC

One thing I had to do, after I thought everything was renamed everywhere was go to:
Project - > Edit Active Target

我必须做的一件事是,在我认为所有内容都已重命名后,转到:
项目 - > 编辑活动目标

Then edit the "Product Name" field under Packaging (on the build tab).

然后编辑“包装”下的“产品名称”字段(在构建选项卡上)。

回答by nicktmro

What I would suggest you do is just rename the Product. Right click Project then Build -> Packaging -> Product Name. Updating this Product Name should be enough.

我建议你做的只是重命名产品。右键单击“项目”,然后单击“构建”->“打包”->“产品名称”。更新此产品名称应该足够了。

回答by Sagar R. Kothari

Go for this link.

去这个链接。

http://www.thohensee.com/?page_id=180

http://www.thohensee.com/?page_id=180

This link not only provides the way of renaming the project. It also provides the details of changing executable name. Try it. I have implemented it in my project.

此链接不仅提供了重命名项目的方法。它还提供了更改可执行文件名称的详细信息。尝试一下。我已经在我的项目中实现了它。

Point to be Noted :

需要注意的地方:

Suppose old Name is "Sagar_RK"

假设旧名称是“Sagar_RK”

& New Name is "SagarRK"

& 新名称是“SagarRK”

Project will be renamed, but you need to remember following thing.

项目将被重命名,但您需要记住以下事项。

When you use shared application delegate. You must have to take delegate with old name application delegate.

当您使用共享应用程序委托时。您必须接受具有旧名称应用程序委托的委托。

For example

例如

Sagar_RKAppDel *t=(Sagar_RKAppDel*)[[UIApplication sharedApplication] delegate];

Try it out.

试试看。

Best of luck.

祝你好运。

回答by brian.clear

Rename project in XCode 4

在 XCode 4 中重命名项目

https://devforums.apple.com/message/378575#378575

https://devforums.apple.com/message/378575#378575

Open the Project Navigator Click on the project name at the top of the tree, tap again and rename box should appear Review changes - note it will try and change all text everywhere so unselect them as needed.

打开项目导航器单击树顶部的项目名称,再次点击,重命名框应出现查看更改 - 请注意,它将尝试更改所有文本,因此根据需要取消选择它们。

回答by Muzammil

enter image description here

在此处输入图片说明

Here is your Project name in XCode4. Simply change the name and press Enter. It works exactly like old XCode version (Project->Rename)...

这是您在 XCode4 中的项目名称。只需更改名称并按 Enter。它的工作原理与旧的 XCode 版本(项目->重命名)完全一样......

!! Enjoy !! :)

!! 享受 !!:)

回答by carlos_ms

None of these suggestions made my project work after I renamed it using Muzammil's suggestion (the so-called correct way of doing it). It's a shame that Apple cannot rename a project that their own tools created. Why not remove all ways of renaming of a project if not even Apple can do it?... shame on Apple!

在我使用 Muzammil 的建议(所谓的正确做法)重命名后,这些建议都没有使我的项目工作。遗憾的是,Apple 无法重命名他们自己的工具创建的项目。如果连 Apple 都做不到,为什么不删除所有重命名项目的方法?... 对 Apple 感到羞耻!

I renamed my project which had versioned xcdatamodels and trashed a lot of work... I'm still trying to make it build!

我重命名了我的项目,该项目已经版本化了 xcdatamodels 并浪费了很多工作......我仍在努力构建它!