ios 移动 xcode 项目导致红色文本(项目中缺少文件)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4613358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
move xcode project causes red text (missing files from project)
提问by arachide
When I move iphone project directory to a new path. There are some red texts indicate the missing files from the project source codes. How to avoid these?
当我将 iphone 项目目录移动到新路径时。有一些红色文本表示项目源代码中缺少的文件。如何避免这些?
回答by snibbe
Here is how to locate the missing (red) files using the Xcode 4 interface:
以下是使用 Xcode 4 界面查找丢失(红色)文件的方法:
- Select the file or files in the left hand Project Navigator (the folder icon)
- In the right sidebar click on "File Inspector" which is the leftmost icon resembling a page
- In the "Identity and Type" section, there is a grey box labeled "Location".
- Click on the small icon to the lower left that resembles a file browser - this will come up with a file browser to locate the file.
- 在左侧项目导航器(文件夹图标)中选择一个或多个文件
- 在右侧边栏中,单击“文件检查器”,这是最左侧的类似于页面的图标
- 在“身份和类型”部分,有一个标记为“位置”的灰色框。
- 单击左下方类似文件浏览器的小图标 - 这将出现一个文件浏览器来定位文件。
Voila, you are done.
瞧,你完成了。
回答by DowntownDev
Xcode 7
Xcode 7
1.) Right click on the red (missing) file.
1.) 右键单击红色(丢失)文件。
2.) Select "Show File Inspector"
2.) 选择“显示文件检查器”
3.) Look at the right hand side of the screen under "Identity and Type" between "Location" and "Full Path"
3.) 在“位置”和“完整路径”之间的“身份和类型”下查看屏幕右侧
4.) Click on the folder icon to the right of the file name.
4.) 单击文件名右侧的文件夹图标。
5.) Navigate to the file's new location in the pop-up window and select the file.
5.) 在弹出窗口中导航到文件的新位置并选择文件。
回答by j2emanue
I encountered this issue when copying my project from one mac to another. The solution for me:
我在将我的项目从一台 Mac 复制到另一台时遇到了这个问题。对我来说的解决方案:
assuming your files are grouped (in folder)
假设您的文件已分组(在文件夹中)
from xcode open the group in file inspector
The group will probably be missing the absolute path.
press the little icon nearby to pick the folder to associate the group with.
restart xcode to see the changes.
从 xcode 在文件检查器中打开组
该组可能会缺少绝对路径。
按附近的小图标选择要与组关联的文件夹。
重新启动 xcode 以查看更改。
回答by user556415
I had the same problem, when I changed the permission on the files/folders to everyone read/write they then appeared in Xcode.
我遇到了同样的问题,当我将文件/文件夹的权限更改为所有人读/写时,它们就会出现在 Xcode 中。
回答by James O'Brien
This worked on a Pod project. Quit XCode.
这适用于 Pod 项目。退出 XCode。
rm -rf project.xcworkspace/xcuserdata/*
rm -rf project.xcworkspace/xcuserdata/*
Restart XCode and reopen project.
重新启动 XCode 并重新打开项目。
回答by mazenqp
回答by Steve
- In Finder, create a duplicate of the project directory just in case all goes squiffy.
- In Finder, open the project directory that contains all the files with red references
- For all the red files you see in XCode, except the info.plist file (see step 5 below), highlight them in Finder and drag them from Finder to XCode's project navigator. i.e. import them.
- In XCode's "Choose options for adding these files" window: a) Select Copy items into Destination's group folder (if needed) b) Select Create groups for any added folder c) Select Add to Targets, and press Finish
- Highlight and drag the info.plist file from Finder to Project Navigator and repeat step 4 WITHOUT selecting Add to Targets
- If you had groups in Project Navigator (e.g. Supporting Files), reorder the files to be in the right places.
- Delete the original bad red references in Project Navigator, and Cmd-Shift-K to clean for good measure.
- Build and run on a device to remove the bad reference to the .app file
- 在 Finder 中,创建项目目录的副本,以防万一。
- 在 Finder 中,打开包含所有带有红色引用的文件的项目目录
- 对于您在 XCode 中看到的所有红色文件,除了 info.plist 文件(参见下面的第 5 步),在 Finder 中突出显示它们并将它们从 Finder 拖到 XCode 的项目导航器中。即导入它们。
- 在 XCode 的“选择添加这些文件的选项”窗口中: a) 选择将项目复制到目标的组文件夹(如果需要) b) 选择为任何添加的文件夹创建组 c) 选择添加到目标,然后按完成
- 突出显示 info.plist 文件并将其从 Finder 拖到 Project Navigator 并重复步骤 4 而不选择 Add to Targets
- 如果您在项目导航器中有组(例如支持文件),请将文件重新排序到正确的位置。
- 删除 Project Navigator 中的原始不良红色引用,并使用 Cmd-Shift-K 进行清理以获得良好的度量。
- 在设备上构建并运行以删除对 .app 文件的错误引用
回答by Alex Terente
When you create these files be sure to save in your app directory. Or if you import classes from other project be sure to check the copy option.
创建这些文件时,请务必保存在您的应用程序目录中。或者,如果您从其他项目导入类,请务必检查复制选项。
回答by shannoga
I dont know if this is the main reason but when you are importing files to the application, do you mary the "Copy items in to destination group's folder (if needed)" ?
我不知道这是否是主要原因,但是当您将文件导入应用程序时,您是否会选择“将项目复制到目标组的文件夹(如果需要)”?
this make sure the file is not only referenced but added to your project folder and ir will move any where you move your project.
这确保该文件不仅被引用,而且被添加到您的项目文件夹中,并且 ir 将移动您移动项目的任何位置。
回答by shannoga
Did you move files in to folders directly in your project folder and not in xcode?
您是否直接将文件移动到项目文件夹中的文件夹中,而不是在 xcode 中?