Rename xcode project - ios

In all of my stupidity I've notice I misspelled my own project. I'm honestly scared to rename it in Mac due to certain filepaths referencing folders that now do not exist. Is there an easy way to rename a project?

Try refactoring, It should work fine, if it doesn't refactoring creates a snapshot instantly.
In Xcode, go to the navigator panel and select the target:
Go to the inspector panel (on the far right) and select the File Inspector icon. You can change the project name here. (You will get a pop-up dialogue to confirm the changes.)
so try it out, if it blows up restore, and create a new project, and migrate to the new one slowly (as #troop231) mentioned.
good luck!
source

I've posted this as an answer elsewhere, but this works like it should...
This is a four step change. And is a real pain
Step 0 - Backup your existing project
Quit Xcode
Right click the master folder containing the project file and the assets, select archive
This will create you an archive of the OLD project
Open the OLD project in Xcode again
Step 1 - Rename the project.
Click on the project you want to rename in the “project navigator” on the left of the Xcode view.
On the right select the “file inspector” and the OLD name of your project should be in there under “Identity and Type”, change it to the new name.
A drop down appears, with a “rename” ok box
Click rename.
Step 2 - Rename the Scheme
In the top bar, just by the “Stop” button, is the scheme for your OLD product, click this then “manage schemes”
Click on the OLD name in the scheme, and it will become editable, change the name. (If you click it twice, you go into the editor (which you don’t want) click the manage schemes button to get back again)
Step 3 - Rename the folder with your assets
Quit out of Xcode
In the correctly named master folder, there is your newly named xcodeproj file with the the wrongly named OLD assets folder. Rename the OLD folder to your new name
Reopen the project and you get a warning “The folder OLD does not exist”, dismiss the warning
On the left in the “project navigator” click the top level OLD folder name.
On the right in the “file navigator” under “Identity and type” you will see the “Name” entry, change this from the OLD to the new name
Just under this is the “location” entry, just below that is a folder symbol with the OLD name. click this and chose the newly renamed folder
Step 4 - Rename the Build plist data
Click on the project in the “project inspector” on the left, in the centre panel select “Build Settings”
in this section search for plist
Under packaging, you will see Info.plist, and Product bundle identifier.
In Info.plist rename the OLD entry
In the Product Identifier and rename the OLD entry
FINALLY you are done and can rebuild (Apple-key+shift+k clean, Apple-Key+b then build)

I've found myself in these situations many times and this is what has helped me without any issues. https://github.com/shabbirh/Xcode-Project-Renamer
There are many options out there, a few works, others don't.
Follow this and you can enjoy a cold or hot drink instead of fighting with the Xcode rename process.
Install dependency
Run the command
gem install xcode-project-renamer
And then lookup for the ProjectToBeRenamed.xcodeproj file
cd yourParentProject/
xcode-project-renamer ProjectToBeRenamed NewProjectName
# Verbose information here.
# at the end you would see
Done.
I hope this helps others.

If you've just started it's easiest to just create a new project with the correct name, then delete the old one. We (I) do this all the time.

To change Project name go through this scenario.
Select target
Select Build Settings
Search product name here
Then Change the new App name here
please note that the XCODE project name will not change but when you run the App name will be change

Related

Is there a way to hide bundle id and apple developer team from public GitHub projects?

I want to make my project open source but don’t really like the idea of my apple developer name and app bundle id being public. Is there a way I can hide it?
Ive not made an open source project before so open to all suggestions.
By default, Xcode stores your product bundle identifier and your development team identifier as build settings in your xcodeproj, along with all the other details of your project structure.
You can tell Xcode to load build settings from a file with the suffix xcconfig. By moving just those settings to an xcconfig file, and telling Git to ignore that file, you can publish your repo without publishing those settings.
Follow these steps to move those two settings out of your xcodeproj and into an xcconfig file:
Add a new file to your project. Use the ‘Configuration Setting File’ template:
Name the file project.xcconfig. Add it to the top-level group (which is your project itself) and don't add it to any targets.
Xcode should open project.xcconfig automatically. If it doesn't, click it in the project navigator to open it.
Open the project editor in a separate editor pane. You can create a separate editor pane by clicking this button in the top-right corner of the editor:
Then click on your project itself (the top-level group) in the project navigator to open the project editor:
Make sure the project itself is selected in the project editor's outline:
In the Configurations section, click the chevron next to “Debug” to show its child, which is the project itself. Then, on the project row, click the popup menu in the “Based on Configuration File” row and choose “project”. Do the same for the “Release”. When you're done, it should look like this:
Click on your target (your app) in the project editor's target list. Then click the “Build Settings” tab. Then click “All” and “Levels”.
In the search field at the top right, type product_bundle_identifier. Double-click the green box in the table that shows your product bundle identifier:
Xcode opens a popover where you can edit the product bundle identifier. Press ⌘C to copy the identifier to the clipboard.
In the other editor pane, which should still be editing project.xcconfig, add a line at the end with the text PRODUCT_BUNDLE_IDENTIFIER = and paste in the identifier using ⌘V.
Click on the “Product Bundle Identifier” row label in the build settings editor to select the row. Press the delete key.
Xcode removes the setting from your .xcodeproj, leaving it only in the project.xcconfig file. If you deselect the row in the build settings editor, it looks like this:
You can see that Xcode is now reading the setting from project.xcconfig.
Repeat the process for the “Development Team” setting. Search the build settings for development_team. Copy its value to project.xcconfig, using the setting key DEVELOPMENT_TEAM. Then select the “Development Team” row in the build settings editor and press the delete key to remove the setting from your .xcodeproj. Your project.xcconfig should now look like this:
//
// project.xcconfig
// HideDevInfo
//
// Created by Rob Mayoff on 1/24/23.
//
// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
PRODUCT_BUNDLE_IDENTIFIER = com.dqd.HideDevInfo
DEVELOPMENT_TEAM = SECRET123X
Clean your build folder (from the menu bar, choose Product > Clean Build Folder). Build and run your app. Make sure it still works.
Edit your .gitignore file. (If you don't already have one, create a new empty file at the top of your Git work tree.) Add a line that says project.xcconfig.
Commit your changes.
Please note that if this is not your first commit in the Git repository, your bundle identifier and your team identifier are still visible in the older commits. You may want to all your commits down to a single commit to remove them. There are ways to edit your commit history to remove those settings from all prior commits, but you'll need to post a separate question if you want to try that.

Getting error after changing project folder name in XCode

When I created my project, I called it "Project1". Then, later I've changed it to "Project2" from the Xcode. I changed all "Project1" to "Project2", but now, when I compile my project, it looks for files in Project2/Project1/myFile.swift and I get the next error:
<unknown>:0: error: no such file or directory: '/Users/myusername/Copy/Projects/Project2/Project1/myFile.swift'
I need to make that it will look at
/Users/myusername/Copy/Projects/Project2/myFile.swift
without Project1 in the path.
How can I solve this problem? Also, I changed from Xcode Identity and Type section Location of my project.
Today I had the same problem when I renamed the folder containing the Xcode project and some parent folders of it.
In my case there where a .swift file shown with it's name in red in the list of files of Xcode (Navigator area). I think that this means that Xcode was not capable to find that file.
I selected that file (actually it's not a real file but a representation of it).
Then, in the File Inspector (Utility area), I clicked on the Folder icon and chose the file on Finder.
This worked for me.
Renaming projects in xcode in one of the most annoying things in iOS development. I assume you want to rename your app. I faced this problem once and figured out a simple, clean way to do it.
Go back to the point where everything worked.
Open project in xcode and click on the project icon in the project structure( first file)
Go to the info tab
Search for Bundle Name. Most probably it will automatically be set to $(PRODUCT_NAME) which is a shell variable that will set your app name the same as the project name.
Set it to whatever you want your app name to be
Done
Note : If you use custom URL Schemes this might produce an error when redirecting.
ALWAYS use git or some other SVN in your projects. This will come in handy in this kind of situations
Change you folder name in you finder "Project1" to "Project2"
Remove "myFile.swift" file from project (copy on Desktop)
Restart Xcode. Copy "myFile.swift" in project select "Copy file to folder" hope this will help.

How to change the product name in XCode 4.5?

I have a workspace that contains a library and a project A, I wanted to create a project B which is the same as A except with a few small tweaks. So I copied the entire set of source files for A and make a copy, renamed them to B, then added the B project o the workspace.
I've created a new scheme for B but when I build and run the app has A's name.
I was looking at this past question
Change product name macro in iOS XCode project
but I cannot find a Product Name row in the Packaging setting when using XCode 4.5.2
Click on the name of the project (the root node) in the sidebar once to select it. Then click it a second time to edit it.
When you press return to save, it will bring up a confirmation dialog that will show you the changes that'll be made.
You may need to update your developer credentials to support the new app.
Edited to add:
This should be a caveat at the end of every Xcode-related question: Restart Xcode. It fixes crazy-making problems. :-)

move xcode project causes red text (missing files from project)

When I move iphone project directory to a new path.
There are some red texts indicate the missing files from the project source codes.
How to avoid these?
Here is how to locate the missing (red) files using the Xcode 4 interface:
Select the file or files in the left hand Project Navigator (the folder icon)
In the right sidebar click on "File Inspector" which is the leftmost icon resembling a page
In the "Identity and Type" section, there is a grey box labeled "Location".
Click on the small icon to the lower left that resembles a file browser - this will come up with a file browser to locate the file.
Voila, you are done.
Xcode 7
1.) Right click on the red (missing) file.
2.) Select "Show File Inspector"
3.) Look at the right hand side of the screen under "Identity and Type" between "Location" and "Full Path"
4.) Click on the folder icon to the right of the file name.
5.) Navigate to the file's new location in the pop-up window and select the file.
I encountered this issue when copying my project from one mac to another.
The solution for me:
assuming your files are grouped (in folder)
from xcode open the group in file inspector
The group will probably be missing the absolute path.
press the little icon nearby to pick the folder to associate the group with.
restart xcode to see the changes.
I had the same problem, when I changed the permission on the files/folders to everyone read/write they then appeared in Xcode.
This worked on a Pod project. Quit XCode.
rm -rf project.xcworkspace/xcuserdata/*
Restart XCode and reopen project.
In Finder, create a duplicate of the project directory just in case all goes squiffy.
In Finder, open the project directory that contains all the files with red references
For all the red files you see in XCode, except the info.plist file (see step 5 below), highlight them in Finder and drag them from Finder to XCode's project navigator. i.e. import them.
In XCode's "Choose options for adding these files" window: a) Select Copy items into Destination's group folder (if needed)
b) Select Create groups for any added folder
c) Select Add to Targets, and press Finish
Highlight and drag the info.plist file from Finder to Project Navigator and repeat step 4 WITHOUT selecting Add to Targets
If you had groups in Project Navigator (e.g. Supporting Files), reorder the files to be in the right places.
Delete the original bad red references in Project Navigator, and Cmd-Shift-K to clean for good measure.
Build and run on a device to remove the bad reference to the .app file
you just have to locate the missing file press in file icon in the identity and type you will find the full path just locate your file where do you move it click the file icon
When you create these files be sure to save in your app directory. Or if you import classes from other project be sure to check the copy option.
I dont know if this is the main reason but when you are importing files to the application, do you mary the "Copy items in to destination group's folder (if needed)" ?
this make sure the file is not only referenced but added to your project folder and ir will move any where you move your project.
Did you move files in to folders directly in your project folder and not in xcode?
This worked on a Pod project.
go into finder and project.
right click on your project .xcworkspace and click show package contents
right click on contents.xcworkspacedata and open with textEdit then make sure file path is correct. If project has been moved this can change
I also did this below but now sure if you need it
Quit XCode.
rm -rf project.xcworkspace/xcuserdata/*
Restart XCode and reopen project.
If you create an Xcode project, then move the .xcodeproj file or the newly created project folder to a different folder using Finder, subsequent builds may show many missing files which still reference the original folder locations (which no longer exist because you moved them). These missing files can appear as red text or as issues in the Issue Navigator.
This can happen when Xcode is configured to automatically add or remove files to/from source control (under Xcode > Preferences > Source Control). When configured this way, simply creating a project in Xcode causes new project folders and files to be marked for addition to source control. When you later move the project folder or .xcodeproj file these pending adds now point to missing files.
To resolve this issue when Subversion is the source control program, revert the pending adds for the phantom items from your local working copy folder. In my case this requires dropping into a Terminal window, navigating to the parent of the phantom project folder, then reverting the automatic add, e.g.
cd /my-working-copy-folder
svn status --depth infinity
svn status --depth infinity existing-parent-folder/phantom-project-folder/
svn revert --depth infinity existing-parent-folder/phantom-project-folder/
Note that the first svn status command will list both missing files as well as properly added, modified or deleted files which you must take care to avoid reverting. The second status command is "practice" for the final revert command, to ensure you've specified the proper path to revert.
I do not know git but I assume it offers corresponding commands.
It's too simple to do :
Close the project that includes the missed files and open the Xcode, go to "Organizer">"Projects" and remove the project from the list there. Open your project from Finder and that's it.
hope this help.

How can I change the name of an iOS app in Xcode?

I began an iPhone project the other day with a silly development code name, and now I want to change the name of the project since it's nearly finished. How can I do this?
Go to Targets in Xcode.
Build Settings on your project's target (your current development name).
Search for Product Name under Packaging. Change its value to what you want your new project name to be.
In new versions of Xcode (Xcode 5 too), to change the name of the project, follow these simple (detailed as possible) steps:
Note: In this example I'll change a hypothetical "Sample" name to a "Test" one.
Click twice slowly on the project root in the project navigator and then it becomes editable.
Rename the project.
After pressing Enter the assistant will suggest you to automatically change all project-name-related entries and will allow you to de-select some of them, if you want.
Press 'RENAME' and Xcode will do the rest. In the meanwhile Xcode may ask you about the option of making a snapshot of the project (it is very recommendable to do so).
In addition to renaming the project, you may want to rename the scheme so that it matches your new project name.
Repeat similar steps like 1 and 2, and press OK.
That's it.
Another scenario...
The previous explanation was related to changing the project name, but chances are that you only need to change the display name that appears below the app icon in the home screen. These are the steps:
In the "Supporting Files" group locate the info.plist (or related) file
Locate the "Bundle display name" key and change the value to the new name.
Delete the "old" app from the simulator or any other testing device.
Clean and rebuild your app again.
That's it. You will now see the new app name in your home screen.
You change the bundle display name in the info.plist file. It's as simple as that.
Changing the 'bundle display name' (as opposed to 'bundle name') is the only way to include characters like '+' in your applications name. Including special characters in the project name will cause an error when uploading to App Store!
In Xcode 4 search for "Product Name" under "Build Settings" tab of the target.
Select Target
Select Info
Insert Bundle Display Name and set App Title
If you want to change the display name only then you can directly change it in the property file (plist) of the app.
You can add a new row with the following key: Bundle display name
Here is an example for this:
When you use this the app name, which you have given with this key, it will be displayed.
So you can do this simply.
This is how I changed it in Xcode 4:
Click on your target file (the first main file of the application).
Go to Build Settings.
Scroll down you will find a bar called "Packaging".
Under Packaging you will see Product Name, and you can change the project name.
In Xcode 3.2, just select the Project entry in the Groups & Files panel, and select the menu item Project → Rename… It worked for me.
Xcode 7/8? It's in the plist that your target uses
For Xcode 10.2:
Although this question has many answers but I wanted to explain the whole concept in detail so that everyone can apply this knowledge to further or previous versions of Xcode too.
Every Xcode project consists of one or more targets. According to apple, A target specifies a product to build and contains the instructions for building the product from a set of files in a project or workspace. So every target is a product (app) on its own.
Steps to change the name:
Step 1: Go to the Targets and open the Info tab of the target whose name you want to change.
Step 2: View the Bundle name key under the Custom iOS Target Properties that is set to the default property of $(PRODUCT_NAME).
Step 3: You can either change the Bundle name directly (not recommended) or if you open the Build Settings tab then on searching for Product Name under Setting you will see that Product Name is set to $(TARGET_NAME).
Step 3A: You can change the Product Name or you can also change the Target Name by double clicking on the target.
So changing the Product Name (App Name) or Target Name both will result into similar results. But if you only want to change the App Name and want to keep using the same Target Name then only change the Product Name.
From Xcode 4.2 and onwards, you can use one more option.
Just click once on the .proj file name at the top in left navigation pane and it will be available for renaming. Rename it and the whole project will get renamed and not only the target.
For Xcode 11, if you want to change the App Display Name then simply go to plist and simply replace the value of CFBundleDisplayName:
<key>CFBundleDisplayName</key>
<string>Your App Name</string>
The best way I like in Xcode 5 is to change product name in building settings. Search "product name" in "building settings", and change it.
If you need to change the name of the application as it appears on the iPhone's home screen, you need to do it in the Target configuration, not the project configuration.
Expand the Targets group in Xcode, and then single-click the item under that. It should share the name of your project, which is also the default name of the application that gets generated.
Press Command + I to bring up the Info window, and then navigate to the Build tag.
Set the Configuration drop-down to read All Configurations.
Look for a setting called Product Name under the Packaging heading.
Change that value to the name you want for your compiled applications and, in the immortal words of Bugs Bunny: Voilà! Do a clean and a build. Your application will take on the new name.
If you want to change the name, that will be displayed on your screen, right under your icon, in Xcode 4, go to Targets → Info → Bundle Display Name and change it to whatever you want.
In Xcode 4 click on project name to start renaming.
It's very easy to change in Xcode 8. enter the app name in the "Display Name" field in Project Target → General Identity section.
Also: your target name may be the same as your app name - note that changing the target name does not change the app name - only the change in the target properties described below - will change the app name.
A note on the bundle display name -- this is the right way to change the name in your app menu, but you'll likely have to reset content and settings in your iOS simulator before you see the change actually take effect.
You can modify the Product Name without changing your Project Name (especially the directory).
Build Settings > search the keyword "product name" > update values
For the sake of gathering all relevant information in one place, here is the official answer to this question - and it is the only one that worked for me on Xcode 5.1.1
Just use the Identity and Type pane in Xcode.
Select the top-most line to the left (with your project name, number of targets, etc.).
Select the target you wish to rename.
Click on the name of the target again.
Type the new name.
Press Enter.
For changing the application name only (that will display along with the app icon) in Xcode 4 or later:
Click on your project file icon from Groups & Files panel, choose Target → Build Settings → Packaging → Product Name. Click on the row. A pop-up will come. Type your new app name here.
For changing the project name only (that will display along with project icon) in Xcode 4 or later:
Click on your project file icon from the Groups & Files panel, choose Project (above targets) from the right pane. Just see at the far right pane (it will be visible only if you have enabled "Hide or show utilities"). Look for the project name. Edit it to a new name you want to give your project.
Delete your app from simulator/device, clean and run. Changes should reflect.
That's it.
I saw many ways to change your app name on the home screen, and I don't think the necessity of edit your .plist file or changing Build Settings of target is justified.
By default in Xcode 7.2 you even don't have 'bundle display name' in your plist file.
And by default, your 'Product name' in 'Build settings' tab of your target is equal to $(TARGET_NAME). IMHO, it's convenient and didn't mean to change.
So you can simply change your Target name like hallski said in his comment for accepted answer. I made picture for it:
I think there is a bit of confusion:
Do you want to change the project name or
do you want to change the App name on the iOS dashboard?
Usually it is enough to change the latter, adding/modifying the BUNDLE DISPLAY NAME key in plist.
It is better to leave the project name untouched, but it may be changed.
Note that Bundle display Name can contain spaces and special characters, but project not. Doing so some cmd line tools will fail due to filename path rules.
And even more Bundle Display names can be localized.
So unless you are in early stage and need to change the internal project name, go on using the Bundle Display Name key.
Project Navigator → General → Display Name
There are
Product name ($(PRODUCT_NAME)): defaults to Target name. This is useful for scheme to select the right target
Bundle display name (CFBundleDisplayName): defaults to Product name. This is what is displayed to your iOS user
Follow these four steps maintaining serial no. And in step 4 give your desired name..
The easiest way: select the TARGET name, double click on it, and rename.
You'll see your app's new name underneath the icon on your device or simulator.
Using Javier's approach to rename my app works perfectly. There is just one small bit missing in the end that I wanted to add.
I still ended up getting a Mach-O Linker Error after a clean and rebuild. To resolve this; select yourProject (in the Project Navigator). Under Targets, select yourProjectTests (the test target) → under the General tab, update the Host Application's value to the newly renamed project.

Resources