XCode4 - How to change only directory folder name - iphone

When creating a project in XCode 4 with the name My_Project, the default folder that is created is contains a subfolder with the same name that contains all the headers, plists, etc. I don't want my project to have nested folders with the same name(ex. My_Project -> MyProject).
How do I go about changing the directory name from "My_Project" to something like "My_Project_Source". I've found plenty on renaming the whole project but I just want to change that folders name to something more descriptive.
When trying to solve this I renamed the folder and updated the references. Still the compiler is looking for the info.plist and such in the default directory name "My_Project". There must be something I'm missing in the build setting.
Thanks for your help!

Check the items in the Target build settings like those shown in the image below:
For example, if I renamed my folder from XML Signature Finagler to srcFolder, I'd need to change the Info.plist File setting to srcFolder/XML Signature Finagler-Info.plist. Likewise, the Prefix Header path would need to be updated as well.

Related

Unable to get xcode project to index appropriate directories

So I had to delete my project and then reclone it from my repository, but when I clone down the project and I open it, other files from some time ago show in there, how is this possible?
Example this is the cloned directory:
But when I open the project, it shows this project structure:
Also it produces the following error when attempting to build the project:
Build input file cannot be found: '/Users/Development/Projects/MapGlider/Application/Utilities/Extensions.swift'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?
All help will be appreciated!
The structure of the project as you see it in Xcode is a combination of file system + information about your project in YourProject.xcodeproj/project.pbxproj file. So you have a mismatch between file system and that file, which is typically a result of inaccurate checkin (for example some changes were done directly in file system, and the project was not updated), or a bad merge (developer A did everything right, developer B, or even the same developer on a different branch, overrode those changes incorrectly).
So what you need to do is to fix those errors one by one.
Note: the steps below assume the project is in your control. If you are using some script or tool to generate the project, you will have to address those issues via that tool or script instead.
First, fix the project structure:
Make sure Inspectors on the right side in Xcode are open. Choose File inspector tab
Focus on a folder inside Xcode, and check Name, Location and Full Path of the folder. Especially notice the Full Path, if it's incorrect, change it to a correct one. Here's the example how. Repeat for all folders and files you want to have in the project
Delete all folders and files you don't want to have in the project from Xcode. For example you can delete Extensions which appears as a file in your project, while it's actually a folder. Typically while deleting you should be able to delete them from file system as well if it exists, but if not, you can double check in file system and delete files / folders from there as well.
Add folders and files missing from the project if needed. Follow Add existing files and folders to a project section in the linked page.
Once you cleaned up the project, you need to review / fix all your project targets:
To fix the Project targets
Try to build each target. If it succeeds, most likely everything is resolved (although watch out for runtime errors for resource files - so you may need to test your app to ensure nothing is missing too).
If building a target fails, you will need to see why. For example
if file is missing from the target, but you already added it to the Xcode project, you can add it to the target (see this page).
if file is missing from the target and is not visible in Xcode, go back to step 4 of the previous procedure and add those files to Xcode project, and then add them to the target
if a file is nowhere to find and is not needed, you can delete it from target. If it was needed, then... well, you have a problem and need to locate your missing code in your source repo or rewrite it.

Xcode - build setting "EXCLUDED_SOURCE_FILE_NAMES" not working

I am trying to exclude some .swift and .storyboard files from my project (Xcode9) for release build using EXCLUDED_SOURCE_FILE_NAMES.
But its not working for me.
Is it possible to give any folder name to exclude it completely?
How to give multiple files and folder name?
It is not working if I give path like ../ForlderName/*.
Folder is at the same level as my project.
Is it possible to exclude sub-folders files as well?
I am able to exclude if my hierarchy is
MyProject Folder
|_
MyProject Folder
|_FolderToBeExcluded
If I gave FolderToBeExcluded/* it is working but file in FolderToBeExcluded's subfolders are not getting excluded.
If my heirachy is like this (ie folder to be excluded and project folder both at same level)
FolderToBeExcluded
MyProject Folder
|_
MyProject Folder
If I give ../FolderToBeExcluded/
or $(SRCROOT)/../FolderToBeExcluded/
both are not working
If I give directly any one of the file name which is to be excluded it is getting exclude without giving full path.
Is it the limitation of EXCLUDED_SOURCE_FILE_NAMES?
If I gave FolderToBeExcluded/* it is working but file in FolderToBeExcluded's subfolders are not getting excluded.
The reason subfolders are not excluded is because of the /*. That tells it to look for files in FolderToBeExcluded. If you just give FolderToBeExcluded (no slash after) then it will exclude all files in that folder and all subfolders. At least that is what I found.
An important gotcha I ran into today is that you can't exclude files within a folder reference, but you can exclude an entire referenced folder.
When you add a folder to Xcode it will ask you if you want to create a group or create a folder reference. If you choose the second option, then you'll need to be aware that you can't exclude files within the folder, but you can exclude the entire folder.
For me it worked if I define the value of EXCLUDED_SOURCE_FILE_NAMES like this:
$(SRCROOT)/../FolderToBeExcluded/*.*
I am using Xcode 9.4.1
This seems to be the only solution:
Use groups without folders for every subfolder in excluded directory
Exclude ${PROJECT_DIR}/{Path to Excluded Folder}/* in EXCLUDED_SOURCE_FILE_NAMES settings

How to rename the folder name in xcode project with out corrupting the files

In my xcode project i have created a folder manually named "MyClasses" to place the newly added files/classes to this folder.
Now i have nearly 30 classes in this folder.
when i renamed this folder , all the files in this folder are gets Erased.
Now i need to rename the folder to "ViewControllerClasses".
But i lost 30 .h, .m, xib files. [lucky i have a copy & and zip file]
How to rename the folder with out corrupting the files.
Renamed it to myviewcontrollerclasswes
When i renamed
Two Solutions
Method_1. Try Manual editing:
« Drag your MedChart.xcodeproj to TextWrangler (or any text editor)
« Use find button to find "FolderName" (Your folder name)
« Replace all with new name.
« In some project you may notice header search path problem...goto header search path and replace with new name.
Method_2. Use Xcode to choose base folder:
Rename folder in finder then use Xcode to choose same folder.
NOTE as of 2017:
Now Xcode 9 synchronises the folder and the project hierarchy automatically.
NOTE as of 2013:
Duplicate and rename Xcode project & associated folders
The "folders" what you see in XCode under your project file are not real folders in the file system, only virtual folders administered in the .xcodeproj file. You can organize your files in the project folder independently from their location in the file system. Some prefers to map the file system folder structure inside the project folder structure, some others store all source files in one big folder in the file system and organize them only in the project folders: it's rather a question of preference.
However if you rename/move physically the files in the file system, you will have to delete and re-add them to your project since XCode will not know where to find them. Pay attention not to delete them physically only remove them from XCode project, then re-add them and reorganize as you want.
One more thing to note: if you are using version control system you will have to inform also its client (svn or git most likely) that you have renamed/moved your files. If you want to keep file revision history it will be a good idea to issue the copy/move command explicitly to the version control otherwise it will treat your files as deleted from the old location and added as new in the new location.
In case anyone is still having trouble with this:
Select the folder or file in the left-side bar of XCode corresponding to the folder you want to rename (for me I renamed the folder containing all my files so I selected the topmost folder)
On the right-side bar, below where it says 'Location', click the folder icon.
In the file explorer that opens up rename the existing folder to whatever name you'd like it to be, then afterwards select it and press 'Ok'.
XCode should update the file locations accordingly.
Keep in mind that if you rename something which contains a file that is hard-coded as a certain path in your build settings, XCode will throw an error. You'll have to manually change those paths in your build settings.
This worked for me, hope it works for you too.
You should just run a search and replace on the project file (if you are working with version control and with other developers you will have seen this file a lot without a doubt), it's the project.pbxproj file located inside the xxxxxxxx.xcodeproj file.
Just right click (Control + Click) on the file and select "Show Package Contents" to find the xcodeproj file.
I still find it easier than all these methods to simply create a new folder in your file navigator and then drag your files from the other folder into it. Sometimes the simplest way is the best way. It literally takes me 10 seconds and I don't need to leave Xcode.

xcode4 file not found when is already in project

I'm using touch JSON, I imported and copied the files inside my folder,
then #import "CJSONDeserializer.h" which is recognized by the autocompleter, but when building, it appears that CJSONDeserializer file not found
So what am I doing wrong while importing, or how to make it recognize the files?
My best guess is that you have not added the header files to your target. To do so go to your project navigator top level, select it, select target, and go to the "search paths" sections, then in the header search path add the path to the CJSONDeserializer.h relative to where your .xcodeproject is.
Where did you place the imported files? make sure you copy the files to the project and not just reference them. Also, go to Build Settings in xcode when clicking the main project, try to edit the option Header Search Paths with the path of the imported files
While copying file have checked the box asking for copy to this folder. If yes then delete and try again. This issue has encountered several times while importing file or copying.

xcode4 group folder to bundle sub directory

If I create a group of images as resource files in xcode4 right menu, How can I :
-automaticly create this group name as sub-directory in resource path, with all the files in it?
-get all the names of files in that folder ?
thanks.
I don't think Xcode can do these things.
In addition, Xcode doesn't suggest to make a lot of folders in your project folder. The default folders created by template is good enough. You do NOT need to manager them by yourself.
But if you insist on managing folders in your project by yourself, you should do it with Finder and then add them to Xcode as References (Make sure "Create groups for any added folders" is selected).