how to change the project name in the header of xcode files - xcode

so recently I changed the name of my project by clicking on the target file of my xcode project inside the xcode developer suite. that changed almost everything accept a coupe of things.
One is the commented code at the top of each file still has the old name
//
// myClass.m
// oldname
//
// Created by iMac on 3/01/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
So I am wondering if there is a specific way of changing that old name from xcode.. or if i just have to go through each file and change them manually?
also the second issue is that in my file bundle some of the files still have to old name! so I am wondering how I change those without screwing up the application?

If u want change "MyCompanyName" from each file.
Move to search navigator shortcut is:cmd+shift+enter
On the left there is button called find,choose replace there and then choose wit wat name u want to replace the string current string "MyCompanyName".
All occurence of "MyCompanyName" will be replace with your new string in all project Files

To update all existing files, simply:
Press CMD+OPTION+SHIFT+F to open the Find and Replace.
Type in your old company name and the new company name.
Press Replace All
To change the default value of __MyCompanyName__ for new all new files created, you can do the following:
Select your project in Xcode (if the Inspector isn't visible, press CMD+1)
In the File Inspector along the right sidebar (if the File Inspector isn't visible, press CMD+OPTION+1), edit the Organization entry under the Project Document section:
All new classes that are added to the project will contain this new company name.

Related

Couldn't load a Xcode project with pods [duplicate]

How do I rename a project in Xcode 5?
What steps do I need to take?
In the past this was always a very tricky manual process.
Well, the answer is very very very Apple simple in Xcode 5!
In the Project Navigator on the left side, click 2 x slowly and the Project file name will be editable.
Type the new name.
A sheet will appear with a warning and will list all the items Xcode 5 believes it should change.
You can probably trust it, but you should inspect it.
The list will include the info.plist and various files, but also all the relevant strings from nib/xib files like MainMenu menus.
Accept the changes and you will get the prompt to save a snapshot of the project.
Always make a snapshot when Xcode asks, it will be useful to restore if something does not work.
Change the project name:-
Click on the target in xcode, on the right in "Identify and Type" under name change the name and press the ENTER button on your keyboard.
A window will appear confirming the change and what it will change. Once you confirm it will make the changes.
Change the root folder name:-
Go to the project directory and rename the root folder,
Open the project and u will find all the file are missing, u need to add all the files of project again
Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor.
4>Search and replace any occurrence of the original folder name with the new folder name.
5>Save the file.
Change the Scheme name:-
rename .xscheme file
If your Project is static framework then make sure your header file has public target membership
I really recommend just opening the folder in a general editor such as Sublime Text, and doing a find/replace across the whole folder. The other methods I found were unstable, particularly when combined with .xcworkspace and cocoapods.
In Xcode 8.0, to rename your project, just go through the following instructions as described in Xcode help:
1- Select your project in the project navigator.
2- In the Identity and Type section of the File inspector, enter a new
name into the Name field.
3- Press Return.
A dialog is displayed, listing the items in your project that can be
renamed. The dialog includes a preview of how the items will appear
after the change.
4- To selectively rename items, disable the checkboxes for any items
you don’t want to rename. To rename only your app, leave the app
selected and deselect all other items.
5- Click Rename.
Source: http://help.apple.com/xcode/mac/8.0/#/dev3db3afe4f
Xcode 6 (beta 6 as of now) seems to be not very reliable with renaming projects. For me it didn't rename several of the files and groups. It also doesn't rename the physical folder the project is in. To rename my project to be sure that everything is clean I went the extra length to create a new project with the new name and copy over all the files. The assets are easy to copy but groups have to be recreated. The biggest issue with this however are CoreData data model files. Trying to simply copy this will result in a corrupt model file, even though everything looks like it is alright.
When you re-name the project name in XCode5 then info.plist entry removed from Targets --- > General ---> identity. You just need to mention it again.
In Xcode 7, renaming a project can still break your app. Make sure you backed it up before trying it.
Click on the project icon and find the project name in the inspector pane. If you change it there, Xcode will ask you if you want to rename related files. Might work. But if not, try this brute force approach:
Close Xcode
Using an advanced text editor like Sublime Text or Atom, open the
root folder. It will open the folder structure.
Perform a Global Search and Replace (it's probably cmd + shift + f), and
replace My Wrong App Name with New App. If your project name contained spaces, also search for My_Wrong_App_Name and replace
with
New_App. This changes all file contents.
Now you need to find all
the files inside the project with your old app name. Rename them
all, also the folders.
Important: Open the project file with
right click > Show Package Contents, and rename all files in there.
Reopen your Xcode project or workspace. Compile.
If you use Pods, you need to open the pods project as well and change the files in there.
Here is another great example which works well with xcode 5

How do I rename a project in Xcode 5?

How do I rename a project in Xcode 5?
What steps do I need to take?
In the past this was always a very tricky manual process.
Well, the answer is very very very Apple simple in Xcode 5!
In the Project Navigator on the left side, click 2 x slowly and the Project file name will be editable.
Type the new name.
A sheet will appear with a warning and will list all the items Xcode 5 believes it should change.
You can probably trust it, but you should inspect it.
The list will include the info.plist and various files, but also all the relevant strings from nib/xib files like MainMenu menus.
Accept the changes and you will get the prompt to save a snapshot of the project.
Always make a snapshot when Xcode asks, it will be useful to restore if something does not work.
Change the project name:-
Click on the target in xcode, on the right in "Identify and Type" under name change the name and press the ENTER button on your keyboard.
A window will appear confirming the change and what it will change. Once you confirm it will make the changes.
Change the root folder name:-
Go to the project directory and rename the root folder,
Open the project and u will find all the file are missing, u need to add all the files of project again
Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor.
4>Search and replace any occurrence of the original folder name with the new folder name.
5>Save the file.
Change the Scheme name:-
rename .xscheme file
If your Project is static framework then make sure your header file has public target membership
I really recommend just opening the folder in a general editor such as Sublime Text, and doing a find/replace across the whole folder. The other methods I found were unstable, particularly when combined with .xcworkspace and cocoapods.
In Xcode 8.0, to rename your project, just go through the following instructions as described in Xcode help:
1- Select your project in the project navigator.
2- In the Identity and Type section of the File inspector, enter a new
name into the Name field.
3- Press Return.
A dialog is displayed, listing the items in your project that can be
renamed. The dialog includes a preview of how the items will appear
after the change.
4- To selectively rename items, disable the checkboxes for any items
you don’t want to rename. To rename only your app, leave the app
selected and deselect all other items.
5- Click Rename.
Source: http://help.apple.com/xcode/mac/8.0/#/dev3db3afe4f
Xcode 6 (beta 6 as of now) seems to be not very reliable with renaming projects. For me it didn't rename several of the files and groups. It also doesn't rename the physical folder the project is in. To rename my project to be sure that everything is clean I went the extra length to create a new project with the new name and copy over all the files. The assets are easy to copy but groups have to be recreated. The biggest issue with this however are CoreData data model files. Trying to simply copy this will result in a corrupt model file, even though everything looks like it is alright.
When you re-name the project name in XCode5 then info.plist entry removed from Targets --- > General ---> identity. You just need to mention it again.
In Xcode 7, renaming a project can still break your app. Make sure you backed it up before trying it.
Click on the project icon and find the project name in the inspector pane. If you change it there, Xcode will ask you if you want to rename related files. Might work. But if not, try this brute force approach:
Close Xcode
Using an advanced text editor like Sublime Text or Atom, open the
root folder. It will open the folder structure.
Perform a Global Search and Replace (it's probably cmd + shift + f), and
replace My Wrong App Name with New App. If your project name contained spaces, also search for My_Wrong_App_Name and replace
with
New_App. This changes all file contents.
Now you need to find all
the files inside the project with your old app name. Rename them
all, also the folders.
Important: Open the project file with
right click > Show Package Contents, and rename all files in there.
Reopen your Xcode project or workspace. Compile.
If you use Pods, you need to open the pods project as well and change the files in there.
Here is another great example which works well with xcode 5

Xcode - Change Company Name and Username

I want to change this:
//
// ViewController.h
// MyApp
//
// Created by _username on 12-04-05.
// Copyright _company_name. All rights reserved.
//
And I tried:
http://macdevelopertips.com/xcode/change-company-name-in-xcode.html and it didn't work.
I also tried this:
http://iosdevelopertips.com/xcode/change-company-name-from-within-xcode-on-a-per-project-basis.html but it did not exist in Xcode 4.
I'm using Xcode 4.2
go to System preferences -> users and groups -> click on your username
On that page there should be a button saying Open... click that and change that record in your contacts. When you create a new class it should get the information from that record!
For changing author name in Xcode 6, just go to User & Groups in system preferences, right click current user (make sure permission is unlocked), select Advanced Options, change the "Full name" section.
For the User Name:
Open up the address book and go to your user account, and edit your name (the large, bold line at the top). (Address Book is by default the first app in your Applications folder.)
If you don't know which contact is your user account: Open up System Preferences. Go to Users & Groups (in the System row); your user account should already be selected. Click on the "Open..." button for the Address Book Card.
Changing your name in the Address Book won't change any already-created files; it will only affect new files that you create.
For the Company Name:
In Xcode 4, open up your project. Select the top-most item in the Project Navigator (MyProjectName, 1 target, iOS SDK 4.3 -- or whatever). Open up the file inspector (View->Utilities). In the Project Document section, you should see an "Organization" line. Edit that, and new files that you create will display the new organization name. This is a project setting, hence you'll have to do it for every project.
For new projects that you create, the Organization Name will be whatever the value was on the previously open project. (You can edit it when creating the new project.)
I know this question is quite old, but I have found a way to customize the template without changing the Full name.
It basically consists on creating a custom plist file named IDETemplateMacros.plist, creating a new key named FILEHEADER under Root and putting the header text as the value. Then, you need to copy this header to one of the following locations:
Project user data: <ProjectName>.xcodeproj/xcuserdata/[username].xcuserdatad/
Project shared data: <ProjectName>.xcodeproj/xcshareddata/IDETemplateMacros.plist
Workspace user data: <WorkspaceName>.xcworkspace/xcuserdata/[username].xcuserdatad/
Workspace shared data: <WorkspaceName>.xcworkspace/xcshareddata/
User Xcode data: `~/Library/Developer/Xcode/UserData/``
I've tried copying it to my User Xcode data folder
More information can be found here
A full list of available macros can be found here or looking at the Xcode help

How to delete an old/unused Data Model Version in Xcode

How can I delete an old Data Model in Xcode? The option is disabled on the menu. (The models I want to delete have not been released to the public - they are interim development models.)
It's a hack, but this worked for me:
Set the Current version of the model in Xcode to one that you want to keep
Remove the .xcdatamodeld from your project (Right-click -> Delete -> Remove Reference Only)
Show the contents of the .xcdatamodeld package in the Finder (Right-click -> Show Package Contents)
Delete the .xcdatamodel file(s) that you don't want anymore
Re-add the .xcdatamodeld file to your project
This eliminates the need to manually modify any of the project metadata files.
I've just found the need to do this. I created a new model version then realised I didn't need it after all. I was surprised to find there was no way of deleting it (that I could find) from Xcode. Still, to remove it I did the following:
First I made sure it wasn't my current model version. Then I went to Finder and found my *.xcdatamodeld file. Right click and Show Package Contents on that. In there you will find the actual model file and can delete it.
This still doesn't remove it from Xcode and it will show red in the Files and Groups. To stop this from happening go back to Finder and Show Package Contents on your main *.xcodeproj file (you may want to make sure you have a backup of this first). In there open up and edit project.pbxproj do a find on your model version name, in my case "interval 8". For me it appeared on two separate lines. I removed these lines and now it's completely removed from Xcode.
This worked for me in XCode 10.3 without the ordering issue occurring when removing the whole model and adding it again:
Select any model version other than the one you want to delete.
From XCode, right-click the .xcdatamodeld file and select 'Show in Finder'.
Close XCode.
In finder, right-click the same file and select 'Show Package Contents'.
Write down the name of the model you want to remove, then from Finder, delete it.
Still in Finder, navigate to the project file (.xcodeproj).
Right-click and open with Atom or any other editor.
From the 'Project' pane open project.pbxproj file.
Remove all lines containing the model name you removed (Example: "ABC 17.xcdatamodel"). You will find two lines similar to the following:
9D88880323C545B800A789B9 / ABC 17.xcdatamodel / = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "ABC 17.xcdatamodel"; sourceTree = "";
and
9D88880323C545B800A789B9 / ABC 17.xcdatamodel /,
Note if you find a third line it will be something like:
currentVersion = 9D88880323C545B800A789B9 / ABC 17.xcdatamodel /;
That means it is the currently selected model. Never delete this line. Just change the text to another model version.
Re-open XCode.
My answer is not issue-specific at all but it's quick and works. For those using git. You can just discard unstaged changes.
git stash save --keep-index
Then you can drop that stash with a git stash drop command if you like.

CompanyName in all new Xcode files not working

Since upgrading to Xcode 4 my company name is not appearing in any new files I create instead this appears:
Copyright 2011 MyCompanyName. All
rights reserved.
I have gone into Terminal and run the command and restarted Xcode but nothing happens:
defaults write com.apple.Xcode
PBXCustomerTemplateMacroDefinitions'{"ORGANIZATIONNAME"
= "MyCompany";}'
defaults write com.apple.Xcode
PBXCustomerTemplateMacroDefinitions'{'ORGANIZATIONNAME'
= "MyCompany";}'
Select the project in the navigator and open the Utility pane. The organization name is found there.
Set your company name in your adresbook. Restart Xcode 4.
Works for Xcode 4 Build 4A304a
To update all existing files, simply:
Press CMD+OPTION+SHIFT+F to open the Find and Replace.
Type in your old company name and the new company name.
Press Replace All
To change the default value of __MyCompanyName__ for new all new files created, you can do the following:
Select your project in Xcode (if the Inspector isn't visible, press CMD+1)
In the File Inspector along the right sidebar (if the File Inspector isn't visible, press CMD+OPTION+1), edit the Organization entry under the Project Document section:
All new classes that are added to the project will contain this new company name.

Resources