Skip to content

Instantly share code, notes, and snippets.

@nganphant
Last active November 28, 2023 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nganphant/c7af53c72ea37eaf6a6a488b559ac1a4 to your computer and use it in GitHub Desktop.
Save nganphant/c7af53c72ea37eaf6a6a488b559ac1a4 to your computer and use it in GitHub Desktop.
Step 1 - Rename the project
Click on the project you want to rename in the "Project navigator" in the left panel of the Xcode window.
In the right panel, select the "File inspector", and the name of your project should be
found under "Identity and Type". Change it to your new name.
When the dialog asks whether to rename or not rename the project's content items,
click "Rename". Say yes to any warning about uncommitted changes.
Step 2 - Rename the scheme
At the top of the window, next to the "Stop" button, there is a scheme for your product
under its old name; click on it, then choose "Manage Schemes…".
Click on the old name in the scheme and it will become editable; change the name and click "Close".
Step 3 - Rename the folder with your assets
Quit Xcode. Rename the master folder that contains all your project files.
In the correctly-named master folder, beside your newly-named .xcodeproj file, there is
probably a wrongly-named OLD folder containing your source files.
Rename the OLD folder to your new name
(if you use Git, you could run git mv oldname newname so that Git recognizes this is a move,
rather than deleting/adding new files).
Re-open the project in Xcode. If you see a warning "The folder OLD does not exist",
dismiss the warning. The source files in the renamed folder will be grayed out because the path has broken.
In the "Project navigator" in the left-hand panel, click on the top-level folder
representing the OLD folder you renamed.
In the right-hand panel, under "Identity and Type", change the "Name" field from the OLD name to the new name.
Just below that field is a "Location" menu. If the full path has not corrected itself,
click on the nearby folder icon and choose the renamed folder.
Step 4 - Rename the Build plist data
Click on the project in the "Project navigator" on the left, and in the main panel select "Build Settings".
Search for "plist" in the settings.
In the Packaging section, you will see Info.plist and Product Bundle Identifier.
If there is a name entered in Info.plist, update it.
Do the same for 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.
Search the settings for "prefix" and ensure that Prefix Header's path is also updated to the new name.
If you use SwiftUI, search for "Development Assets" and update the path.
Step 5:
[If target name has changed and you had already installed pods] Edit the Podfile target and set it to your new target name. Run "pod deintegrate" and pod install then.
Clear Derived Data
Open your project.xcworkspace, Edit Scheme -> Run -> Executable -> Set your target
Step 7 - Clean and rebuild your project
Command + Shift + K to clean
Command + B to build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment