Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to debug another developer's iPhone project. I am using XCode 4.2 on Mac OS X Lion.

Now, when I try to compile the project, I get an error saying that some files are missing. These files are shown red in the Project Navigator. However, I am unable to find the original path where these files are supposed to be.

For example, let say the project name is Project1. A developer had a folder with shared libraries outside this project's folder and he used them in his project. When I load the project in XCode, I can see that there is another folder there called SharedLibs, but all files inside of it are red (as that folder is missing from my hard drive).

Is there a way to click on red files or something to find out their original path? As the missing files are general 3rd party libraries, I want to create the folder in the correct path and to fill it with the missing libraries.

Thanks in advance for any help.

share|improve this question
If only files are missing, you can right-click and select Show in Finder. It will open the folder where the file should be located. – Daniel Beck Jan 12 '12 at 9:33
I think this may be it. I have no idea how I overlooked this option. – JoeM Jan 12 '12 at 9:47
up vote 2 down vote accepted

You can right-click any element and select Show in Finder. It will display the best possible match that exists, e.g. the immediate parent folder if only the file is missing, its parent folder if the immediate parent folder is missing, etc.

Alternatively, you can use Xcode's AppleScripting capabilities to determine the full path of items in your project.

Open AppleScript Editor and paste the following:

set out to ""
tell application "Xcode"
    tell project "Fooo"
        repeat with g1 in groups
            set c1 to name of g1
            repeat with g2 in groups of g1
                set c2 to c1 & " » " & name of g2
                repeat with g3 in groups of g2
                    set c3 to c2 & " » " & name of g3
                    repeat with g4 in groups of g3
                        set c4 to c3 & " » " & name of g4
                        repeat with r4 in file references of g4
                            set out to out & c4 & " » " & name of r4 & "  ——— " & full path of r4 & "
                        end repeat
                    end repeat
                    repeat with r3 in file references of g3
                        set out to out & c3 & " » " & name of r3 & "  ——— " & full path of r3 & "
                    end repeat
                end repeat
                repeat with r2 in file references of g2
                    set out to out & c2 & " » " & name of r2 & "  ——— " & full path of r2 & "
                end repeat
            end repeat
            repeat with r1 in file references of g1
                set out to out & c1 & " » " & name of r1 & "  ——— " & full path of r1 & "
            end repeat
        end repeat
        repeat with r0 in file references
            set out to out & " » " & name of r0 & "  ——— " & full path of r0 & "
        end repeat
    end tell
end tell

Change the project name ("Fooo") and run it, and, check the output. It will contain the full paths to all items traversed. It depends on your project structure though -- it will only traverse groups (folders) of the top four levels and their file/folder references.

This is the output for a newly created Cocoa Application project named Cocoa:

Cocoa » Document.xib » en  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/en.lproj/Document.xib
Cocoa » MainMenu.xib » en  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/en.lproj/MainMenu.xib
Cocoa » Supporting Files » InfoPlist.strings » en  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/en.lproj/InfoPlist.strings
Cocoa » Supporting Files » Credits.rtf » en  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/en.lproj/Credits.rtf
Cocoa » Supporting Files » Cocoa-Info.plist  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/Cocoa-Info.plist
Cocoa » Supporting Files » main.m  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/main.m
Cocoa » Supporting Files » Cocoa-Prefix.pch  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/Cocoa-Prefix.pch
Cocoa » Document.h  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/Document.h
Cocoa » Document.m  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/Document.m
CocoaTests » Supporting Files » InfoPlist.strings » en  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/CocoaTests/en.lproj/InfoPlist.strings
CocoaTests » Supporting Files » CocoaTests-Info.plist  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/CocoaTests/CocoaTests-Info.plist
CocoaTests » CocoaTests.h  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/CocoaTests/CocoaTests.h
CocoaTests » CocoaTests.m  ——— /Users/danielbeck/Library/Autosave Information/Cocoa/CocoaTests/CocoaTests.m
Frameworks » Other Frameworks » AppKit.framework  ——— /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/AppKit.framework
Frameworks » Other Frameworks » CoreData.framework  ——— /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/CoreData.framework
Frameworks » Other Frameworks » Foundation.framework  ——— /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Foundation.framework
Frameworks » Cocoa.framework  ——— /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Cocoa.framework
Frameworks » SenTestingKit.framework  ——— /Developer/Library/Frameworks/SenTestingKit.framework
Products »  ——— /Users/danielbeck/Library/Developer/Xcode/DerivedData/Cocoa-crnllmegeptunwfweqdljydsrsnq/Build/Products/Debug/
Products » CocoaTests.octest  ——— /Users/danielbeck/Library/Developer/Xcode/DerivedData/Cocoa-crnllmegeptunwfweqdljydsrsnq/Build/Products/Debug/CocoaTests.octest

You can of course adjust the script to your project's structure, and traverse the item hierarchy to the missing items. In this case, the file's full path is displayed as output in AppleScript.

tell application "Xcode"
    tell project "Fooo"
        tell group "Frameworks"
            tell group "Other Frameworks"
                full path of file reference "aaa"
            end tell
        end tell
    end tell
end tell
share|improve this answer
YES I know this is clearly recursive. I just couldn't convince AppleScript to recognize Xcode types passed as parameter in the function I wrote to do that. Working on it. – Daniel Beck Jan 12 '12 at 10:31

Highlight a red file in the Project Navigator. On the other side of the window, in the Utilities Panel, select File Inspector. At the top you have Identity and Type. Second sub-section there deals with the file path. The popup will give you various ways to view the path (various "Relative to" options and an Absolute Path option). To the right you have a small "window" icon, which you can click on to choose the file (once you've figured out where the right ones are). The right-arrow icon will take you to the file if it's there (pretty much the same thing as Show in Finder).

You might get some clues there as to where it's trying to look for them, or last thought they were located.

You might first want to check what this panel says about the group the red files are in. You can set the default location for new files added to a given group here. Note: Once the path is set for a group and you have some files in it, you're best to leave that path setting alone. If everything in the group is red, then setting the proper path on the group's folder can fix all the red files in one shot.

And I can't say for sure, but I seem to remember that doing it this way will preserve any bindings you had set up prior to the files disappearing. Assuming they match what the project thinks should be there.

share|improve this answer

Umm, no. However, you can get the files from the person and add it to your project by right clicking the "SharedLibs" folder and selecting "Add files to Project1". That'll work.

share|improve this answer
Is there a way to know where SharedLibs folder is located? There are many folders with the same name accros the parent folder. The main problem is that many folders outside PRoject1 dir are incorporated into the project and some of them have the same names. – JoeM Jan 12 '12 at 9:42
Not to mention that these files are located on the remote server and I am reluctant adding some new files. Yet the project is rather big (a few gigs) and I would not like to download it if I don't have to. – JoeM Jan 12 '12 at 9:44
You can use Show in Finder (Xcode 4) or Reveal in Finder (Xcode 3.x). Hope that helps. – thandasoru Jan 12 '12 at 10:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .