Macos – How to view file’s path in XCode

iphonemacososx lionxcode

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.

Best Answer

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
Related Question