Xcode 构建失败并显示“致命错误:AST 文件格式错误或损坏” Crashlytics.h

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

Xcode build fails with "fatal error: malformed or corrupted AST file" Crashlytics.h

objective-cxcodecrashlytics

提问by Mike Vosseller

I recently enabled modules in my Xcode project build settings ("Enable Modules (C and Objective-C)") and now I frequently get the below build error. It works the next time I build (without any changes) but it is annoying because it happens very often (several times an hour).

我最近在我的 Xcode 项目构建设置中启用了模块(“启用模块(C 和 Objective-C)”),现在我经常收到以下构建错误。它在我下次构建时工作(没有任何更改)但很烦人,因为它经常发生(每小时几次)。

fatal error: malformed or corrupted AST file: 'could not find file '/Users/mpv/dev/project/Crashlytics.framework/Headers/Crashlytics.h' referenced by AST file' note: after modifying system headers, please delete the module cache at '/Users/mpv/Library/Developer/Xcode/DerivedData/ModuleCache/M5WJ0FYE7N06'

致命错误:格式错误或损坏的 AST 文件:'找不到文件 '/Users/mpv/dev/project/Crashlytics.framework/Headers/Crashlytics.h' 引用的 AST 文件'注意:修改系统头文件后,请删除模块缓存在“/Users/mpv/Library/Developer/Xcode/DerivedData/ModuleCache/M5WJ0FYE7N06”

Crashlytics recommended removing Crashlytics.h from the precompiled header file (.pch) and importing directly in each source file that needs it. This greatly reduces the problem but I still occasionally get a Crashlytics.h file not found error when building.

Crashlytics 建议从预编译的头文件 (.pch) 中删除 Crashlytics.h 并直接在需要它的每个源文件中导入。这大大减少了问题,但我仍然偶尔会在构建时遇到 Crashlytics.h 文件未找到错误。

fatal error: 'Crashlytics/Crashlytics.h' file not found
#import <Crashlytics/Crashlytics.h>

回答by Alex the Ukrainian

First, try going to Product -> Clean menu in Xcode. Then rebuild when it finishes.

首先,尝试转到 Xcode 中的 Product -> Clean 菜单。然后完成后重建。

If that doesn't work, go to your [Name]-Prefix.pch file in the Supporting Files folder, and delete the #import line. Build. It will have errors, it's ok, now start typing it again and make sure to select the right choice from the drop-down suggest menu so it auto-fills the rest of the line for you. (This step worked for me).

如果这不起作用,请转到 Supporting Files 文件夹中的 [Name]-Prefix.pch 文件,然后删除 #import 行。建造。它将有错误,没关系,现在开始再次输入它并确保从下拉建议菜单中选择正确的选项,以便它为您自动填充该行的其余部分。(这一步对我有用)。

Good luck! Love it when Xcode goes weird like this :)

祝你好运!当 Xcode 变得像这样奇怪时,我喜欢它:)

回答by pkamb

I hit this issue after updating my version of Xcode via the Mac App Store.

通过 Mac App Store 更新我的 Xcode 版本后,我遇到了这个问题。

After updating Xcode, the xcode-selectCommand Line Tools version of Xcode was still set to the old version. This was creating some kind of mismatch in xcodebuild.

更新 Xcode 后,Xcode 的xcode-selectCommand Line Tools 版本仍然设置为旧版本。这在xcodebuild.

I solved the issue like so:

我这样解决了这个问题:

  1. Xcode > Preferences > Command Line Tools. Select the newest Xcode version.
  2. Quit Xcode
  3. Delete the ~/Library/Developer/Xcode/DerivedDatadirectory.
  4. Run build script again. Success!
  1. Xcode > Preferences > Command Line Tools. 选择最新的 Xcode 版本。
  2. 退出 Xcode
  3. 删除~/Library/Developer/Xcode/DerivedData目录。
  4. 再次运行构建脚本。成功!


For SEO purposes, when I was hitting this issue I saw the following errors:

出于 SEO 的目的,当我遇到这个问题时,我看到了以下错误:

error: InputFile /Users/user/source/Your-PCH-Prefix.pch 0 1406772618 191 33188... malformed line 9; 'InputFile' should have exactly five arguments

Also:

还:

xcodebuild[53039:5503] stream error: stream error at offset 29: created by an unsupported XCDependencyGraph build
xcodebuild[53039:4e0b] stream error: stream error at offset 29: created by an unsupported XCDependencyGraph build
** BUILD FAILED **


The following build commands failed:
    Write auxiliary files
    MappingModelCompile