我有一个项目叫XXX。我想把这个项目重命名为YYY。

请注意,XXX是一个非常常见的术语(例如:“数据”,或者简单的“项目”),因此一个简单的RegEx搜索和替换是不可能的,因为有破坏项目配置文件的风险。

我的当前项目目录包含以下项目:

XXX XXXTests XXX . xcodeproj

我想把它们重命名为:

年年 年 YYY.xcodeproj

... 分别与必要的变化反映在我的项目文件。

我如何才能在不手动创建和填充新项目的情况下实现这一点呢?


当前回答

我在网上找到了一些有用的简单步骤:

in Finder change project's folder name open project/select project file in Xcode navigator/show the file inspector/under Identity and Type change Name as per your preference/Enter/wait few seconds till pop-up window appears/click rename/again wait few seconds - do not push OK/ select folder under project file in Xcode navigator/show the file inspector/under Identity and Type change name as per your preference/Enter/wait few secont till file under project file in Xcode nagivator changes its name in Xcode project status bar click on the project name (it appears when you hover over the beginning of line)/choose Manage schemes...till "Autocreate schemes" window shows up/2x click on project name under scheme column/enter/close "Autocreate schemes" window select project file in Xcode navigator/inXcode editor ~ interface builder area choose tab "Build setting"/in filter type the previous name of your project/click enter/in the line(s) where the previous name of your project appears within the root(s) - just change it to new name voala that's it

其他回答

有一个GitHub项目叫做Xcode project Renamer:

它应该在Xcode项目目录的根目录中执行,并使用两个字符串参数调用:$OLD_PROJECT_NAME和$NEW_PROJECT_NAME 脚本递归遍历所有文件和目录, 包括Xcode项目或工作空间文件,并替换所有发生的事件 $OLD_PROJECT_NAME字符串和$NEW_PROJECT_NAME字符串(两者都在 每个文件的名称和内容)。

别忘了备份你的项目!

Xcode Project Renamer

更改项目名称;

在project导航器中选择您的项目。 在文件检查器的Identity and Type部分中,在name字段中输入一个新名称。 按Return键。 将显示一个对话框,列出项目中可以重命名的项。该对话框包括更改后项目将如何显示的预览。 若要选择性地重命名项,请禁用不想重命名的任何项的复选框。若要仅重命名应用程序,请保持应用程序已选中,并取消选择所有其他项。 按“重命名”

加入卢克·韦斯特的公认答案。如你有任何权益:

关闭Xcode 更改授权文件名 进入Xcode,选择授权文件应该突出显示为红色,在文件检查器中选择文件夹图标,并选择您的重命名文件。 进入构建设置,搜索“授权”并更新授权的文件夹名称和文件名。 清洁和重建

我在网上找到了一些有用的简单步骤:

in Finder change project's folder name open project/select project file in Xcode navigator/show the file inspector/under Identity and Type change Name as per your preference/Enter/wait few seconds till pop-up window appears/click rename/again wait few seconds - do not push OK/ select folder under project file in Xcode navigator/show the file inspector/under Identity and Type change name as per your preference/Enter/wait few secont till file under project file in Xcode nagivator changes its name in Xcode project status bar click on the project name (it appears when you hover over the beginning of line)/choose Manage schemes...till "Autocreate schemes" window shows up/2x click on project name under scheme column/enter/close "Autocreate schemes" window select project file in Xcode navigator/inXcode editor ~ interface builder area choose tab "Build setting"/in filter type the previous name of your project/click enter/in the line(s) where the previous name of your project appears within the root(s) - just change it to new name voala that's it

One more thing to note that I don't think has been noted yet is if you are using CoreData objects along with a lazy persistentContainer in the AppDelegate file (or anywhere else), you may get an error saying NSManagedObjectContext is nil (or something along those lines). Change the name for any NSPersistentContainer to use the NEW app name. That should fix the issue! If not, according to this old SO post the solution is to delete your old .xcdatamodeld file and create a new one adding back all the entities again.