What Does Question Mark Mean in Xcode Project Navigator? - xcode

In the project navigator in Xcode, I am not sure what the ? is trying to tell me next to the file name.
I am sure it is not a coincidence that this is the same file that I dragged from my root directory for the project to the Classes folder (because the .mm file was there and I wanted them to be together). The project still compiles just fine, however my code sense broke recently and I am wondering whether this may be part of the issue.
Thanks!

It's the file untracked by source control.

Those characters refer to the source control.
? - Unversioned
M - Modified
A - Added
A+ - Moved/Renamed (R as of Xcode 13)
U - Newer version of a file on source control
More reference here

You can add to source control by selecting the untracked files

Following steps resolved issue for me:
Select all your files with "?"
Right click and select Source Control
Select Add Selected Files
Select Commit Selected Files...
On the popup dialog just drop some comment (no matter what=)
Screen

Those are uncommitted files if your using GIT, you need to right click Source Control>Commit Selected File manually. It should take away the "?" on the new version of Xcode 6.3.2 as of today

Along with all other answers. This shouldn't happen by default UNLESS you have changed the settings in Xcode.
From Xcode Preferences >> Source Control >> make sure 'Add and remove files automatically' is selected

I suddenly get one my file Unversioned (with ? mark), but it was old file.
It was .m file. Before problem occurred, I created copy of it, for making new similar class. I renamed a class and add new file to XCode.
Problem (with old file become Unversioned) was in not renamed comment string at beginning:
//
// MyFirstClass.m
When I renamed it, problem with Unversioned file was resolved.
//
// MySecondClass.m
Hope it'll helpful somebody.
P.S. Additionally maybe needed to remove and copy back this files.

Stage the Unstaged file, if its a working copy and the ? will change to A

Related

Accidentally deleted file in Xcode

I accidentally had one of my files selected in a project in Xcode and pushed delete and it was deleted. Anyone know how to recover it? It won't let me undo. Please help.
The file itself is not deleted, it is simply removed from the Project Navigator.
To add it back, go to
File -> Add files to "projectName"
and select the missing file, after having navigated to the project's folder if needed.
Or simply hit cmd+z
May be its too late but for someone else it might be good to know, that's why I am answering it.
Go to File >>> Add Files'Your Project Name' there will be a list of all files which have been removed from project, select and add them back.
Now these files are back in project, but they don't have any reference yet so xCode will give you error saying "Storyboard do not have any file of this name", now you have to add references, for this just right click on that missing files and add that file to project.
NOTE: If you have removed files directly to trash then restore from trash and repeat second step to add reference back in project.
This file should be in the trash folder, look in that folder or you can search via apple spotlight.
The following steps will allow you to recover (a) deleted file(s):
Click on the trash icon on the bottom right
Search for the file(s) and move it back into your project folder
In XCode, go to File, Add Files to ..., then select the file(s) you've just restored
There are some files that XCode deletes utterly without warning. These files are permanently deleted unless you have a backup.

Duplicate and rename Xcode project & associated folders [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I would like to be able to duplicate an entire Xcode project, rename the project and the associated files without Xcode going mental, and without having to manually re-import all files to the project.
This answer is the culmination of various other StackOverflow posts and tutorials around the internet brought into one place for my future reference, and to help anyone else who may be facing the same issue. All credit is given for other answers at the end.
Duplicating an Xcode Project
In the Finder, duplicate the project folder to the desired location of your new project. Do not rename the .xcodeproj file name or any associated folders at this stage.
In Xcode, rename the project. Select your project from the navigator pane (left pane). In the Utilities pane (right pane) rename your project, Accept the changes Xcode proposes.
In Xcode, rename the schemes in "Manage Schemes", also rename any targets you may have.
If you're not using the default Bundle Identifier which contains the current PRODUCT_NAME at the end (so will update automatically), then change your Bundle Identifier to the new one you will be using for your duplicated project.
Renaming the source folder
So after following the above steps you should have a duplicated and renamed Xcode project that should build and compile successfully, however your source code folder will still be named as it was in the original project. This doesn't cause any compiler issues, but it's not the clearest file structure for people to navigate in SCM, etc. To rename this folder without breaking all your file links, follow these steps:
In the Finder, rename the source folder. This will break your project, because Xcode won't automatically detect the changes. All of your Xcode file listings will lose their links with the actual files, so will all turn red. Note: You may have to do Step 2 first, then come back to this step.
In Xcode, click on the virtual folder which you renamed (this will likely be right at the top, just under your actual .xcodeproject) Rename this to match the name in the Finder, this won't fix anything and strictly isn't a required step but it's nice to have the file names matching.
In Xcode, Select the folder you just renamed in the navigation pane. Then in the Utilities pane (far right) click the icon that looks like dark grey folder, just underneath the 'Location' drop down menu. From here, navigate to your renamed folder in the finder and click 'Choose'. This will automagically re-associate all your files, and they should no longer appear red within the Xcode navigation pane.
In your project / targets build settings, search for the old folder name and manually rename any occurrences you find. Normally there is one for the prefix.pch and one for the Info.plist, but there may be more.
If you are using any third party libraries (Testflight/Hockeyapp/etc) you will also need to search for 'Library Search Paths' and rename any occurrences of the old file name here too.
Repeat this process for any unit test source code folders your project may contain, the process is identical.
This should allow you to duplicate & rename an Xcode project and all associated files without having to manually edit any Xcode files, and risk messing things up.
Credits
Many thanks is given to Nick Lockwood, and Pauly Glott for providing the separate answers to this problem.
Duplicating an Xcode 4 Project
Renaming xcode 4 project and the actual folder
I'm posting this since I have always been struggling when renaming a project in XCode.
Renaming the project is good and simple but this doesn't rename the source folder. Here is a step by step of what I have done that worked great in Xcode 4 and 5 thanks to the links below.
REF links:
Rename Project.
Rename Source Folder and other files.
1- Backup your project.
If you are using git, commit any changes, make a copy of the entire project folder and backup in time machine before making any changes (this step is not required but I highly recommended).
2- Open your project.
3- Slow double click or hit enter on the Project name (blue top icon) and rename it to whatever you like.
NOTE: After you rename the project and press ‘enter’ it will suggest to automatically change all project-name-related entries and
will allow you to de-select some of them if you want. Select all of
them and click ok.
4- Rename the Scheme
a) Click the menu right next to the stop button and select Manage Schemes.
b) Single-slow-click or hit enter on the old name scheme and rename it to whatever you like.
c) Click ok.
5 - Build and run to make sure it works.
NOTES: At this point all of the important project files should be renamed except the comments in the classes created when the project
was created nor the source folder. Next we will rename the folder in
the file system.
6- Close the project.
7- Rename the main and the source folder.
8- Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor.
9- Search and replace any occurrence of the original folder name with the new folder name.
10- Save the file.
11- Open XCode project, test it.
12- Done.
EDIT 10/11/19:
There is a tool to rename projects in Xcode I haven't tried it enough to comment on it.
https://github.com/appculture/xcode-project-renamer
As of XCode 7 this has become much easier.
Apple has documented the process on their site:
https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/RenamingaProject/RenamingaProject.html
Update: XCode 8 link:
http://help.apple.com/xcode/mac/8.0/#/dev3db3afe4f
I am using this script after I rename my iOS Project. It helps to change the directories name and make the names in sync.
http://github.com/ytbryan/rename
NOTE: you will need to manually change the scheme's name.
I'm using simple BASH script for renaming.
Usage: ./rename.sh oldName newName
#!/bin/sh
OLDNAME=$1
NEWNAME=$2
export LC_CTYPE=C
export LANG=C
find . -type f ! -path ".*/.*" -exec sed -i '' -e "s/${OLDNAME}/${NEWNAME}/g" {} +
mv "${OLDNAME}.xcodeproj" "${NEWNAME}.xcodeproj"
mv "${OLDNAME}" "${NEWNAME}"
Notes:
This script will ignore all files like .git and .DS_Store
Will not work if old name/new name contains spaces
May not work if you use pods (not tested)
Scheme name will not be changed (anyway project runs and compiles normally)
In the example code for the book "Instant OpenCV for iOS" I have found a bash script that copies a project from a folder to another.
Doing a little research I've found a blog post from what seems to be the original author of the script: http://mohrt.blogspot.it/2009/01/renaming-xcode-project-from-command.html, where you can download the script. I gave it a try and running it from terminal like this
sh renameXcodeProject.sh <name-of-existing-folder> <name-of-folder-to-create>
works fine.
Additional info can be found opening the file with a text editor. Hope that helps
I using Xcode 6+ and I just do:
Copy all files in project folders to new Folders (with new name).
Open *.xcodeproj or *.xcworkspace
Change name of Project.
Click on schema and delete current chema and add new one.
Here is done, but name of window Xcode and *.xcodeproj or *.xcworkspace still <old-name>. Then I do:
pop install
Open <new name>.xcworkspace
One more thing to try!
When I copied all of my files, opened the project, and renamed it, everything changed to my new project name except for the test target! I got a linker error that said I was missing a file called "myOldProjectname.app". Here's what fixed it:
Click on your project settings and select your test target
Click on build settings and search for "test host"
Check those 2 file paths. Chances are that those 2 paths are still pointing at your old project name.
Hope that helps!
For anybody else having issues with storyboard crashes after copying your project, head over to Main.storyboard under Identity Inspector.
Next, check that your current module is the correct renamed module and not the old one.

ios file corruption

Ok so some how 2 of my classes had ended up in a weird directory
projectname>projectname.xcodeproj>
In my infinite wisdom I tried to transfer these to the proper directory were the rest of my classes are (projectname directory)
However now I cant compile due to it not being able to find certain files
what file can I edit to check to see where it's looking for these files?
UPDATE 1
in response to the first answer I have tried readding the files. which has netted me some different errors. Specifically that Cameleon-Prefix.pch, no matter how many times I re add it always shows red.
A quick fix for this is to delete the files from Xcode, but in the confirmation dialog, choose to just release the references. Then add the files again (from the File menu Add Files… item).
If you want to see where Xcode expects to find the files, choose the file in the navigator pane on the left, and set up the right hand pane with this configuration.
And from there you can click on the detail disclosure buttons to see even more.
Edited to add
Make sure this is the same file pointed to in your build settings:
Do a similar search for pch to make sure the same thing goes with the pch file

xcode little icon - what does it mean? and why are they not copied into app

I have no idea what these little A and ? mark mean, I do know that the ones with the ? are not in the budle, however they are in the xcode list, they are editable, they are not read only, i see them as marked to be copied into the bundle (as it is phonegap and the whole www dir should be copied)... but somehow it's not going.... what do these little icons mean? A (archive??!?!) ? = (no reference or something...?)
Those are for source control. If you've created a new project in Xcode 4 and not unticked the relevant box, you have a GIT repository automatically.
'A' means that the file is to be added to the repository when next you commit. '?' means that you've added the file to your project but you haven't yet told Xcode what you want to do with respect to source control. You can set what you want to do by right clicking the files or by selecting them and going to File -> Source Control.
In any case, they're completely unrelated to how the project is built.

Adding an existing implementation file to an Xcode project won't work

As I write most of my code using MacVIM, I need to add the new files to the XCode project in order to compile them into the executable. Today however I encountered an implementation file (.m) which XCode won't allow to be added. It appears light gray in the appropriate finder window as if it were already included in the project, but when I try to build, I get a linker error, stating that the symbol defined this implementation file could not be found. The corresponding header file could be added without problems.
Any idea what could have caused this problem?
Btw. I deleted a former version of the same file from the "Classes" tree before, as well as many others which were successfully re-added.
I think I saw a similar problem once with an old version of Xcode. IIRC the way I resolved it was to:
rename the source file (temporarily)
add the renamed file to the project
do a "Save As..." on the renamed file to get it back to the original name
The file is probably already in your project, but not in the target you're building. Use the Detail view and Search bubble to find it, Get Info, and in the Targets tab of the info window, check the check box for the target you're building.
The other answer (removing and re-adding) works because you end up removing it from the project, then when you re-add it, it's added to the current target by default.
I found that deleting my pbxuser file from inside the .xcodeproj solved the problem for me. There were references to the files I couldn't add in there, surprisingly. This has happened to me many times over the years.
Another trick is to:
Move the file into a different directory
Add it to the XCode project from there
Move it to the desired location
Select the file in Groups & Files
Choose File > Get Info from the menu bar. The full path will appear in red.
Press the Choose... button and select the file at the new location.
If you are using Xcode 4, you can do the following steps to add an existing file into your target:
1) Select your file in "Project navigator" view (aka. click your myfile.m file in the folder tree of Xcode)
2) Click menu item "View" => "Utilities" => "Show File inspector" (or use the shortcut "Alt + Command + 1)
3) There is one section called "Target Membership", check the target you want
I fixed this by deleting the .xcuserstate file and restarting the project. I am using a workspace file, for all it's worth.
You can find any and all referencing files via
grep -r -h [NameOfFileThatYouAreTryingToAdd] *
from within your project directory.

Resources