如何在XCode中查看文件的路径?

Joe*_*oeM 5 iphone xcode osx-lion macos

我正在尝试调试另一个开发人员的 iPhone 项目。我在 Mac OS X Lion 上使用 XCode 4.2。

现在,当我尝试编译该项目时,我收到一条错误消息,指出某些文件丢失。这些文件在项目导航器中显示为红色。但是,我无法找到这些文件应该所在的原始路径。

例如,假设项目名称为 Project1。开发人员在该项目的文件夹之外有一个包含共享库的文件夹,他在他的项目中使用了它们。当我在 XCode 中加载该项目时,我可以看到那里有另一个名为 SharedLibs 的文件夹,但其中的所有文件都是红色的(因为我的硬盘驱动器中缺少该文件夹)。

有没有办法点击红色文件或其他东西来找出它们的原始路径?由于丢失的文件是一般的第三方库,我想在正确的路径中创建文件夹并用丢失的库填充它。

预先感谢您的任何帮助。

Dan*_*eck 2

您可以右键单击任何元素并选择“在 Finder 中显示”。它将显示存在的最佳可能匹配,例如,如果仅缺少文件,则显示直接父文件夹;如果缺少直接父文件夹,则显示其父文件夹,等等。

\n\n
\n\n

或者,您可以使用 Xcode 的 AppleScripting 功能来确定项目中项目的完整路径。

\n\n

打开 AppleScript 编辑器并粘贴以下内容:

\n\n
set out to ""\ntell application "Xcode"\n    tell project "Fooo"\n        repeat with g1 in groups\n            set c1 to name of g1\n            repeat with g2 in groups of g1\n                set c2 to c1 & " \xc2\xbb " & name of g2\n                repeat with g3 in groups of g2\n                    set c3 to c2 & " \xc2\xbb " & name of g3\n                    repeat with g4 in groups of g3\n                        set c4 to c3 & " \xc2\xbb " & name of g4\n                        repeat with r4 in file references of g4\n                            set out to out & c4 & " \xc2\xbb " & name of r4 & "  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 " & full path of r4 & "\n"\n                        end repeat\n                    end repeat\n                    repeat with r3 in file references of g3\n                        set out to out & c3 & " \xc2\xbb " & name of r3 & "  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 " & full path of r3 & "\n"\n                    end repeat\n                end repeat\n                repeat with r2 in file references of g2\n                    set out to out & c2 & " \xc2\xbb " & name of r2 & "  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 " & full path of r2 & "\n"\n                end repeat\n            end repeat\n            repeat with r1 in file references of g1\n                set out to out & c1 & " \xc2\xbb " & name of r1 & "  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 " & full path of r1 & "\n"\n            end repeat\n        end repeat\n        repeat with r0 in file references\n            set out to out & " \xc2\xbb " & name of r0 & "  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 " & full path of r0 & "\n"\n        end repeat\n    end tell\nend tell\nout\n
Run Code Online (Sandbox Code Playgroud)\n\n

更改项目名称 ( "Fooo") 并运行它,然后检查输出。它将包含遍历的所有项目的完整路径。但这取决于您的项目结构——它只会遍历前四个级别的组(文件夹)及其文件/文件夹引用。

\n\n

这是新创建的Cocoa 应用程序项目的输出,名为Cocoa

\n\n
Cocoa \xc2\xbb Document.xib \xc2\xbb en  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/en.lproj/Document.xib\nCocoa \xc2\xbb MainMenu.xib \xc2\xbb en  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/en.lproj/MainMenu.xib\nCocoa \xc2\xbb Supporting Files \xc2\xbb InfoPlist.strings \xc2\xbb en  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/en.lproj/InfoPlist.strings\nCocoa \xc2\xbb Supporting Files \xc2\xbb Credits.rtf \xc2\xbb en  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/en.lproj/Credits.rtf\nCocoa \xc2\xbb Supporting Files \xc2\xbb Cocoa-Info.plist  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/Cocoa-Info.plist\nCocoa \xc2\xbb Supporting Files \xc2\xbb main.m  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/main.m\nCocoa \xc2\xbb Supporting Files \xc2\xbb Cocoa-Prefix.pch  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/Cocoa-Prefix.pch\nCocoa \xc2\xbb Document.h  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/Document.h\nCocoa \xc2\xbb Document.m  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/Cocoa/Document.m\nCocoaTests \xc2\xbb Supporting Files \xc2\xbb InfoPlist.strings \xc2\xbb en  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/CocoaTests/en.lproj/InfoPlist.strings\nCocoaTests \xc2\xbb Supporting Files \xc2\xbb CocoaTests-Info.plist  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/CocoaTests/CocoaTests-Info.plist\nCocoaTests \xc2\xbb CocoaTests.h  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/CocoaTests/CocoaTests.h\nCocoaTests \xc2\xbb CocoaTests.m  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Autosave Information/Cocoa/CocoaTests/CocoaTests.m\nFrameworks \xc2\xbb Other Frameworks \xc2\xbb AppKit.framework  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/AppKit.framework\nFrameworks \xc2\xbb Other Frameworks \xc2\xbb CoreData.framework  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/CoreData.framework\nFrameworks \xc2\xbb Other Frameworks \xc2\xbb Foundation.framework  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Foundation.framework\nFrameworks \xc2\xbb Cocoa.framework  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Cocoa.framework\nFrameworks \xc2\xbb SenTestingKit.framework  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Developer/Library/Frameworks/SenTestingKit.framework\nProducts \xc2\xbb Cocoa.app  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Developer/Xcode/DerivedData/Cocoa-crnllmegeptunwfweqdljydsrsnq/Build/Products/Debug/Cocoa.app\nProducts \xc2\xbb CocoaTests.octest  \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 /Users/danielbeck/Library/Developer/Xcode/DerivedData/Cocoa-crnllmegeptunwfweqdljydsrsnq/Build/Products/Debug/CocoaTests.octest\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n\n

您当然可以根据项目的结构调整脚本,并遍历项目层次结构以找到丢失的项目。在这种情况下,文件的完整路径将显示为 AppleScript 中的输出。

\n\n
tell application "Xcode"\n    tell project "Fooo"\n        tell group "Frameworks"\n            tell group "Other Frameworks"\n                full path of file reference "aaa"\n            end tell\n        end tell\n    end tell\nend tell\n
Run Code Online (Sandbox Code Playgroud)\n