I have a project named XXX
. I want to rename this project to YYY
.
Note that XXX
is an extremely common term (for e.g. "data", or simply "project"), and thus a simple RegEx search-and-replace is not possible, out of risk of corrupting the project configuration files.
My current project directory contains the following items:
XXX
XXXTests
XXX.xcodeproj
and I want to rename them to:
YYY
YYYTests
YYY.xcodeproj
... respectively, with the necessary changes being reflected in my project file.
How can I accomplish this without having to manually create and populate a new project?
Edit: It is absolutely ridiculous that this has become my most upvoted question.
Note: for Xcode 14, Sept. 2022: in some cases Xcode now automatically renames the scheme, when Xcode performs Step 1 above. If so, there is nothing to do in Step 2.
git mv oldname newname
. Note that when using git mv old new
you generally must (i) completely commit all other changes (ii) only then git mv old new
(iii) commit that (iv) only then make further changes. If steps i-ii-iii-iv are followed, git will maintain history through the rename.}Info.plist
and Product Bundle Identifier
.Info.plist
, update it (it may have been updated automatically in Step 1).Product Bundle Identifier
, unless it is utilizing the ${PRODUCT_NAME} variable. In that case, search for "product" in the settings and update Product Name
. If Product Name
is based on ${TARGET_NAME}, click on the actual target item in the TARGETS list on the left of the settings pane and edit it, and all related settings will update immediately.Prefix Header
's path is also updated to the new name.""
) quotes if the path contains a space (
).Code Signing Entitlements
. Accordingly, rename the actual entitlements file in the Project Navigator also. (Side note: In Xcode 13 entitlements files have a yellow checkmark icon in the Project Navigator; you may have created one if e.g. you use shared containers/App Groups.)Further points.
At this stage, open the overall folder simply in the Mac finder. Type the old name in the file text search. You will see that the old name appears very often as customModule="OldName"
in all storyboard files. (Explanation.) These can be fixed, in Xcode, one by one, on each storyboard: Tap on the view controller in the file inspector, and be sure to tap on the actual storyboard in the white column on the left of the actual storyboard panel. Tap on the Identity Inspector (4th small button) in the right hand panel. Look at the Custom Class -> Module field. Notice it seemingly shows NewName in gray. However (still as of Xcode14.2) it is incorrect. Simply tap the drop-down, and explicitly select the new name. (If you now review that storyboard file with a text editor, you will see it is fixed.) You may prefer to change them all just using a plain text editor.