Xcode无法发出预编译头文件? [英] Xcode failed to emit precompiled header?

查看:100
本文介绍了Xcode无法发出预编译头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此先感谢您为我提供的帮助.

thanks in advance for the help you will give me.

我昨天在互联网上搜索了半天,现在已经两个小时了,但我什么都没找到(除了那两个对无法发出用于桥接标头的预编译标头)

I have searched this for half a day over the internet yesterday and two hours now and I haven't found anything (more than those two links that did not help FMDatabase.h not found when using route-me library & Failed to emit precompiled header for bridging header)

这是我的问题:我只有一个以前的开发人员正在从事的项目,而当我尝试启动它时,这里有两个错误:

So here is my problem : I just had in hands a project that a previous developer has been working on, and when I try to launch it, here I have two errors :

无法发出预编译的头文件'/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLX.用于桥接头'/Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h'

failed to emit precompiled header '/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLXF.pch' for bridging header '/Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h'

/用户/我/下载/Alavoc-ios-master/Alavoc/externalLib/customClass/customClassViewController.h:13:9:错误:找不到"FMDB/FMDB.h"文件

/Users/me/Downloads/Alavoc-ios-master/Alavoc/externalLib/customClass/customClassViewController.h:13:9: error: 'FMDB/FMDB.h' file not found

还有一个这样写的致命错误(即使我只计算了两个错误,这个错误也出现在日志中,上面提到的另外两个错误之上)

There is also one fatal error wroten like this (even if I only have two errors counted, this one appears in the log above the two other ones previously described)

严重错误:模块文件'/用户/我/库/开发人员/Xcode/DerivedData/ModuleCache/30E4RG2TSVLXF/Foundation-3DFYNEBRQSXST.pcm'已过时,需要重建:签名不匹配注意:由进口'/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLX./用户/我/下载/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h:13:9:注意:包含在的文件中/用户/我/下载/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h:13:#import"customClassViewController.h"

fatal error: module file '/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache/30E4RG2TSVLXF/Foundation-3DFYNEBRQSXST.pcm' is out of date and needs to be rebuilt: signature mismatch note: imported by '/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLXF.pch' /Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h:13:9: note: in file included from /Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h:13: #import "customClassViewController.h"

customClassViewController.h第13行:

customClassViewController.h line 13 :

#import <FMDB/FMDB.h>

我想那些错误是联系在一起的.您是否知道它可能来自哪里?

I guess those errors are linked. Do you have any idea where it could come from ?

预先感谢您的帮助,我非常感谢!

Thanks in advance for your help guys, I really appreciate it!

编辑battlmonster(新错误):

这是两个错误(未找到文件(在Alavoc-Bridging-Header.h FMDB.h中未找到))并且未能发出预编译的头文件:

Here are the two errros (file not found (in Alavoc-Bridging-Header.h FMDB.h not found)) and failed to emit precompiled header :

严重错误:文件'/用户/我/下载/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h'自预编译头文件以来已被修改'/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLX.内置注释:请重建预编译的头文件'/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLX./用户/我/下载/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h:29:9:错误:找不到"FMDB/FMDB.h"文件

fatal error: file '/Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h' has been modified since the precompiled header '/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLXF.pch' was built note: please rebuild precompiled header '/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLXF.pch' /Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h:29:9: error: 'FMDB/FMDB.h' file not found

    ^ 1 error generated. <unknown>:0: error: failed to emit precompiled header

'/用户/我/库/开发人员/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2.用于桥接头'/Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h'

'/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLXF.pch' for bridging header '/Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h'

推荐答案

此错误与桥接头格式错误有关.桥接头文件是一个特殊的头文件,其中列出了所有Objective-C头文件,这些文件的类必须从Swift代码中可以访问.所有桥接标头定义都已预编译,可以从Swift中使用.在您的情况下,桥接标头是"Alavoc/bridge/Alavoc-Bridging-Header.h",并且包含customClassViewController.h的标头(来自Alavoc/externalLib/customClass),它指示您的开发人员希望访问customClassViewController.在Swift代码中.

This error is about a malformed bridging header. The bridging header is a special header file which lists all Objective-C header files with classes that must be accessible from Swift code. All the bridging header definitions are precompiled in a way to be ready to use from Swift. In your case the bridging header is "Alavoc/bridge/Alavoc-Bridging-Header.h", and it includes a header for customClassViewController.h (from Alavoc/externalLib/customClass), which indicates that your fellow developer wants that customClassViewController is accessible in Swift code.

现在关于桥接头的混乱之处在于,它没有递归地包含所有内容,即,它只是在定义的第一级上进行,如果您在Swift中想要导入的内容中导入了某些内容,则必须添加它明确地连接到桥接头,否则您可能会收到警告(有时甚至是错误).假设您在桥接头中有 #import"Ah" ,并且在"Ah"中有 #import"Bh" ,那么您可能必须添加"Bh"到桥接头.

Now the confusing thing about the bridging header is that it is not recursively including everything, i.e. it just looks on the first level of definitions, and if you import something in your import that you want in Swift, you have to add it to the bridging header explicitly, or else you'll probably get a warning (or an error sometimes). Say you have #import "A.h" in the bridging header, and you have #import "B.h" inside "A.h", then you likely would have to add "B.h" to the bridging header as well.

现在在示例A = customClassViewController和B = FMDB中,通常您需要将FMDB添加到桥接头中,但事实是您很可能不想通过桥接头将FMDB导出到Swift,因为这并不意味着这样做(它是针对您自己的objc代码,而不是针对第三方库的).

Now in your example A = customClassViewController, and B = FMDB, and normally you would need to add FMDB to the bridging header, but the thing is that you most likely don't want exporting FMDB to Swift via your bridging header, because it is not meant for this (it is for your own objc code and not for 3rd party libs).

解决方案是从"customClassViewController.h"中删除第13行.这可能会修复桥接头的编译,但可能会破坏customClassViewController,因此您需要在"customClassViewController.m"中包含FMDB,并且很可能使"customClassViewController.h"适应于与FMDB不相关的内容(或向前声明这些内容). @class X; )的用法.

The solution would be to remove line 13 from your "customClassViewController.h". This would likely fix the bridging header compilation, but probably break the customClassViewController, so you need to include FMDB in "customClassViewController.m" and most likely adapt the "customClassViewController.h" to not have anything related to FMDB (or forward-declare those usages with @class X;).

如果将 #import< FMDB/FMDB.h> 移至实现(.m)文件,但仍出现错误:找不到'FMDB/FMDB.h'文件,很可能是您的标题搜索路径中未列出FMDB路径.

If you move #import <FMDB/FMDB.h> to your implementation (.m) files and still get error: 'FMDB/FMDB.h' file not found, it is likely about FMDB path not being listed in your header search paths.

要解决最后一个问题,只需在Xcode构建设置的标题搜索路径"中包含正确的路径.假设FMDB位于/Users/me/Downloads/Alavoc-ios-master/Alavoc/ASDASD/FMDB(并且您有/Users/me/Downloads/Alavoc-ios-master/Alavoc/ASDASD/FMDB/FMDB.h),然后需要打开Xcode项目设置-在左侧选择目标-在顶部选择构建设置"-找到标题搜索路径"设置并添加/Users/me/Downloads/Alavoc-ios-master/Alavoc/ASDASD路径

To solve the last one just include the right path in your "Header Search Paths" in Xcode build settings. Let's say FMDB is located at /Users/me/Downloads/Alavoc-ios-master/Alavoc/ASDASD/FMDB (and you have /Users/me/Downloads/Alavoc-ios-master/Alavoc/ASDASD/FMDB/FMDB.h inside), Then you need to open Xcode project settings - select your target on the left - select "Build Settings" on the top - find "Header Search Paths" setting and add /Users/me/Downloads/Alavoc-ios-master/Alavoc/ASDASD path

这篇关于Xcode无法发出预编译头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆