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

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

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

XXX XXXTests XXX . xcodeproj

我想把它们重命名为:

年年 年 YYY.xcodeproj

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

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


当前回答

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

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

别忘了备份你的项目!

Xcode Project Renamer

其他回答

如果它的反应本机,你可以做的是: 您可以更改package中的name属性。Json,运行react-native upgrade,然后让react覆盖android/ios文件。但是,如果有未保存的代码,则不要覆盖索引文件。

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.

为卢克-韦斯特的精彩回答补充一点:

使用CocoaPods时

第二步之后:

Xcode辞职。 在主文件夹中,重命名OLD。xcworkspace到NEW.xcworkspace。

第四步之后:

In Xcode: choose and edit Podfile from the project navigator. You should see a target clause with the OLD name. Change it to NEW. Quit Xcode. In the project folder, delete the OLD.podspec file. rm -rf Pods/ Run pod install. Open Xcode. Click on your project name in the project navigator. In the main pane, switch to the Build Phases tab. Under Link Binary With Libraries, look for libPods-OLD.a and delete it. If you have an objective-c Bridging header go to Build settings and change the location of the header from OLD/OLD-Bridging-Header.h to NEW/NEW-Bridging-Header.h Clean and run.

Xcode 11.0 +。

现在真的很简单了。只需转到Project Navigator,即Xcode窗口的左侧面板。 按Enter键使其激活以进行重命名,就像更改文件夹名称一样。

只需要在这里更改新名称,Xcode会要求你重命名其他东西。

.

点击这里的重命名,你就完成了。

如果你对根文件夹的名称感到困惑,比如为什么它没有改变,那么它只是一个文件夹。它只是用一个新名字重新命名它。

更改项目名称;

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