How can I rename my .xcodeproj without it crashing?

时间:2015-04-24 21:30:05

标签: ios xcode

I've looked all over the internet and tried everything I could possibly think of to change a .xcodeproj name - for example: http://prntscr.com/6xrms6

But it all just crashes Xcode and then when I reopen it, my app breaks completely.

How can I fix this?

1 个答案:

答案 0 :(得分:1)

使用Bash和正则表达式将所有出现的旧项目名称更改为新项目名称。

SRCROOT='path/to/repo' # 1
find "$SRCROOT" -type f -not -regex '.*/\.git/.*' -not -name '.DS_Store' -print0 | xargs -0 -I {} bash -c 'file="{}"; sed -E -i "" "s/OldProjectName/NewProjectName/g" "$file"' # 2
find -E "$SRCROOT" -type f -regex '.*OldProjectName.*' -print0 | xargs -0 -I {} bash -c 'src="{}"; dst=$(echo "$src" | sed -E "s/OldProjectName/NewProjectName/g"); mkdir -p "$(dirname "$dst")"; mv "$src" "$dst"' # 3

说明:

  1. 包含OldProjectName.xcodeproj
  2. 的路径
  3. 更改" OldProjectName"的出现次数to" NewProjectName"在所需文件的内容
  4. 重命名文件以替换" OldProjectName"使用" NewProjectName"在文件路径中
  5. 注意:您可能需要编辑这些正则表达式以满足您的特定需求。如果您只想重命名项目而不是所有目标和/或类名,那么您需要使用正则表达式来狡猾。

    另外,我假设你已经尝试过点击重命名项目,但由于某些原因它没有工作......

    Click to rename project

相关问题