Xcode 4(和依赖项)的编译、构建或存档问题
这个问题在过去几周内不断发展,涵盖了 的更一般性问题xcode4 (以及从较旧的 xcodes)。
然而,许多问题可以通过遵循同一组说明来解决。
如果您遇到以下任何问题,请尝试接受的答案中的方法:
- Xcode 4 无法存档应用程序
- Xcode 4 创建了不可用的存档
- Xcode 4 不会创建 .ipa
- Xcode 4 由于预处理器错误而无法编译
- Xcode 4 无法查找标头
- Xcode 4 的代码完整无法正常工作
- 项目依赖项无法编译
- 添加依赖项会导致上述任何问题
原始问题
标题:在 Xcode 4 中找不到“词法或预处理器问题文件”
我有一个Xcode 4 中的项目可以正常构建并在设备和模拟器上运行,但在尝试存档时,在查找与静态库关联的头文件时出错:
In file included from /Volumes/Development/Path/LBProject/LBProject/LBProject-Prefix.pch:15:
In file included from /Volumes/Development/Path/LBProject/LBFDefines.h:23:
In file included from /Volumes/Development/Path/LBProject/Classes/LBProjectAppDelegate.h:11:
In file included from /Volumes/Development/Path/LBProject/LBProject/../FKNDirectory/FKNDirectoryManager.h:10:
/Volumes/Development/Path/LBProject/LBProject/../FKNDirectory/FKNDataModel.h:11:9: fatal error: 'Merchant.h' file not found [1]
#import "Merchant.h"
^
1 error generated.
Xcode 给出错误
lexical or preprocessor issue file not found
Much 谷歌搜索显示很多人遇到这个问题但没有解决方案。任何人都得到了修复,甚至是线索。
更新:在所有配置中,用户标头
搜索路径均设置为${BUILT_PRODUCTS_DIR}
。除了存档之外,它可以使用任何配置构建良好。
更新 2: Merchant.h
是自动生成的核心数据类,因此位于 .xcdatamodeld
包内,但是标头全部被复制构建库时到公共头目录。
This question has evolved over the past several weeks to cover more general issues with xcode4 (and upgrading projects form older xcodes).
However many of the issues can be solved by following the same set of instructions.
If you have any of the following issues, try the methods in the accepted answer:
- Xcode 4 fails to archive an App
- Xcode 4 creates an unusable archive
- Xcode 4 does not create an .ipa
- Xcode 4 fails to compile due to preprocessor errors
- Xcode 4 cannot find headers
- Xcode 4's code complete is not working
- Project dependancies won't compile
- Adding a dependancy causes any of the above issues
Original Question
Title: "lexical or preprocessor issue file not found" in Xcode 4
I have a project in Xcode 4 that will build fine and run on the device and simulator but when trying to Archive it errors when looking for headers files associated with a static library:
In file included from /Volumes/Development/Path/LBProject/LBProject/LBProject-Prefix.pch:15:
In file included from /Volumes/Development/Path/LBProject/LBFDefines.h:23:
In file included from /Volumes/Development/Path/LBProject/Classes/LBProjectAppDelegate.h:11:
In file included from /Volumes/Development/Path/LBProject/LBProject/../FKNDirectory/FKNDirectoryManager.h:10:
/Volumes/Development/Path/LBProject/LBProject/../FKNDirectory/FKNDataModel.h:11:9: fatal error: 'Merchant.h' file not found [1]
#import "Merchant.h"
^
1 error generated.
Xcode gives the error
lexical or preprocessor issue file not found
Much Googling has show many people are having this issue but no solution. Anyone got a fix or even a clue.
Update: The user header
search paths are set to ${BUILT_PRODUCTS_DIR}
in all configurations. It builds fine using any configuration except when archiving.
Update 2: Merchant.h
is a Core Data class that is auto-generated and therefore inside .xcdatamodeld
package, however the headers are all copied to the public headers directory when the library is built.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
$(LOCAL_APPS_DIR)
$(LOCAL_APPS_DIR)
我在 XCode 4 中遇到了同样的问题:“未找到词法或预处理器问题 MyFile.h”。然而,MyFile.m 不是一个静态库,只是一个标准类。 MyFile.m 和 MyFile.h 已正确包含在项目中并建立了索引。
所以...我退出了 XCode 和模拟器,然后重新启动它们,问题就消失了。
I had the same problem in XCode 4: "Lexical or preprocessor issue MyFile.h not found". However, MyFile.m was not a static library, just a standard class. And MyFile.m and MyFile.h were included properly and indexed in the project.
So ... I quit XCode and the Simulator, then restarted them and the problem disappeared.
我发现当我将目标构建设置“扫描所有源文件以查找包含”从“否”更改为“是”时,问题就消失了。
I found that the problem went away when I changed the target build setting "scan all source files for includes" from no to yes.
我能够解决这个问题,无需对任何构建设置进行任何更改,只需将 .h 文件复制到查找器中的项目目录中即可。我根本没有将它们添加到项目中。只要将它们放在项目的文件系统目录中似乎就足以让 Xcode 的隐式链接正常工作。更多详细信息 在这里。
I was able to resolve this issue without any changes to any of the build settings by simply copying the .h files into the Project's directory in the finder. I did NOT add them to the project at all. Just having them in the project's filesystem directory seemed to be enough to allow Xcode's implicit linking to work properly. More details here.
我有一个像这样奇怪的问题。将“扫描所有资源文件...”更改为“是”没有帮助。我查看了框架搜索路径,注意到我有
它看起来是正确的,但仍然失败。然后我尝试重新排列 2 和 2 的顺序。 3 突然之间一切都变得很好了。所以不知道为什么会出现这个问题,但想将其添加到要尝试的事情列表中,以防它对其他人有帮助。
I had a weird issue like this. Changing "Scan all resource files..." to Yes didn't help. I took a look at the Framework Search Paths and noticed that I had
It seemed right but was still failing. I then tried rearranging the order of 2 & 3 and all of a sudden it built fine. So not sure why that was the hickup, but wanted to add it to the list of things to try in case it helps someone else.
我的解决方案是将我的更改
为
,一切都重新开始工作。
不寻常的是,它在构建后突然停止工作
几次。
My solution was to change my
to
and everything started working again.
What was unusual was that it had stopped working suddenly after building
a few times.
设置为“是”时,问题自行解决
当我将“构建设置”->“项目”->“搜索路径”
The problem resolved itself when I set
Build Settings->Project->Search Paths to Yes
我的项目中有相同的 2 个目标(
GHUnit
的 Project 和 ProjectTest)。当我的方案设置为Project时,
的导入出现“未找到词法或预处理器问题文件”< /em>.但是当我设置为方案ProjectTest时,一切正常。因此,我也在 Project 中添加了GHUnitIOS.framework
。I had the same — 2 targets in my project (Project and ProjectTest of
GHUnit
). When my scheme was set up to Project, the import of<GHUnitIOS/GHUnit.h>
was problem of “lexical or preprocessor issue file not found”. But when I set as a scheme ProjectTest, everything was OK. So, I have addedGHUnitIOS.framework
in Project too.看起来您的标头搜索路径不正确,未在活动方案的构建设置中正确配置。验证它们并使用当前设置更新您的问题。
Looks like your header search paths are incorrect not configured properly in your build settings for the active scheme. Verify them and update your question with the current setting.
我在模拟器上遇到类似的问题,但在设备上没有,并且我的标题搜索路径字段为空(似乎是默认的)。但改变工作空间似乎已经解决了这个问题。也许您可以尝试创建一个新的工作区,将您的项目添加到其中,看看是否有帮助。现在我正在调查原因。
I'm having similar issues on the simulator but not the device and my header search path fields are empty (Seems to be default). But changing Workspaces seems to have solved the issue. Maybe you could try creating a new Workspace, add your project to it and see if that helps. Now I'm investigating why.
我的项目中的一个特定 .h 文件出现了“文件未找到”错误。我通过从项目中删除该 .h 文件(选择“删除引用”)并重新添加它来解决该问题。
I was getting this "file not found" error for one particular .h file in my project. I resolved the issue by removing that .h file from the project (selecting "Remove references") and re-adding it.
添加更多变体:我在
Compile Source
构建阶段有两个foo.m
实例,这在某种程度上导致了foo.h 的“找不到标头”
。Adding on more variant: I had two instances of
foo.m
in theCompile Source
build phase, which some how caused "Header not found" forfoo.h
.另一个机会:
在工作区项目中:在“目标”中查看“构建阶段”部分。正如许多手册所说,您需要有一个复制文件构建阶段来将所有标头复制到另一个位置,因为 iOS 框架不能包含要共享的标头文件(这是我的情况)。
为这些复制文件选择“产品目录”作为目标选项。或者您喜欢的另一个目录,标题将驻留在其中。
这对我有用。存档(或发布)目录的构建可能与 Debug 构建中的预期非常不同。
另请检查您的工作区设置和构建目录。
XD
Another chance:
In workspace project: watch in the Target for section Build Phases. As many manuals says you need to have a Copy Files Build Phase to copy all your headers to another place, as iOS Framework cannot contain header files to be shared (this is my case).
Choose for those Copy Files as Destination option "Products Directory". Or another directory of your like where the headers will reside.
That worked for me. Probably the build for Archive (or Release) directory is very different than expected in build for Debug .
Also check in your workspace settings your build directory.
XD
对我来说,这个问题是在我向项目添加新文件后发生的;从 NSObject 派生的空白 .m 和 .h。以下是我解决它的方法:
我然后重新添加了它们,它也起作用了。
绝对是 xCode 中的错误...
For me, this issue occurred after I added new files to the project; a blank .m and .h derived from NSObject. Here's how I resolved it:
I then Re-added them afterward and it also worked.
Definitely a bug in xCode...