为什么 xcode 看不到这些文件,但它们实际存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17610469/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:36:17  来源:igfitidea点击:

Why xcode can't see these files, however they physically exist

xcode

提问by Hymanie Chan

Xcode run into compilation error while running the code.

Xcode 在运行代码时遇到编译错误。

Unfortunatetly I was not able to find a solution online.

不幸的是,我无法在网上找到解决方案。

These steps that I have commenced:

我已经开始的这些步骤:

=> git merge branch-name => can't find the files => git checkout branch-name file-name => files were physically found => xcode can't see it

=> git merge branch-name => 找不到文件 => git checkout branch-name 文件名 => 文件被物理找到 => xcode 看不到

??? enter image description here

??? 在此处输入图片说明

回答by Heckscheibe

You have to add them to your project at File -> Add Files To "Your Project"

您必须在文件 -> 将文件添加到“您的项目”中将它们添加到您的项目中

btw: Your project folder in Xcode does not necessarily reflect your actual folder structure you see in finder.

顺便说一句:您在 Xcode 中的项目文件夹不一定反映您在 finder 中看到的实际文件夹结构。



Edit:

编辑:

if you want it to be like that (Xcode folders are the same as the existing folders in your harddrive) I found a nice tool which does that for you: https://github.com/venmo/synx

如果您希望它像那样(Xcode 文件夹与硬盘驱动器中的现有文件夹相同),我找到了一个很好的工具,可以为您做到这一点:https: //github.com/venmo/synx

also, when creating new folders/groups in Xcode, you have to use the New Group with Folderoption to also create a folder for that group on your harddrive.

此外,在 Xcode 中创建新文件夹/组时,您还必须使用该New Group with Folder选项在硬盘上为该组创建一个文件夹。

回答by Sosily

Maybe when you add those files to the project you did not linked them to your Target.

也许当您将这些文件添加到项目时,您没有将它们链接到您的目标。

When you add file to your project make sure it's link to your target.

当您将文件添加到您的项目时,请确保它链接到您的目标。

enter image description here

在此处输入图片说明

check the following:

检查以下内容:

  1. select the file (.m file) that causing this error.
  2. select the file inspector
  3. make sure that your Target is selected in the check box.
  1. 选择导致此错误的文件(.m 文件)。
  2. 选择文件检查器
  3. 确保在复选框中选择了您的目标。

enter image description here

在此处输入图片说明

  • NOTE: you can't link .h files to the target, only .m and .swift
  • 注意:您不能将 .h 文件链接到目标,只有 .m 和 .swift

回答by Madhurya Gandi

Looks like whenever I added my files to git, I never actually added MyProject.xcodeproj/project.pbxproj file. This file has all the references for new files. Make sure you add that file to your git.

看起来每当我将文件添加到 git 时,我实际上从未添加过 MyProject.xcodeproj/project.pbxproj 文件。此文件包含新文件的所有参考。确保将该文件添加到 git 中。

回答by Khaled Jamal

Tested in xcode 11

在 xcode 11 中测试

You have to add them to your project by pressing right-click on the app folder Add files to "app"... select all the missing and NEEDED files, click on create groups option and press finish.

您必须通过右键单击应用程序文件夹将它们添加到您的项目将文件添加到“应用程序”...选择所有丢失和需要的文件,单击创建组选项并按完成。

Adding missing files to xcode

将丢失的文件添加到 xcode