xcodebuild没有显示所有的编译错误?

5

我的项目有2个编译错误(在XCode中显示)。

但是当我使用终端中的xcodebuild编译该项目时,只显示一个编译错误。

xxx$xcodebuild -sdk iphoneos -configuration Debug
....
....
[self updateAccountInfo];1
                         ^
1 warning and 1 error generated.

有没有办法让xcodebuild显示所有编译错误?
在Xcode的偏好设置中,打开一般标签,选择“错误后继续构建”选项。这里是相关问题的链接
我需要使用xcodebuild实现相同的功能。
编辑:思考和研究了这些天后,我认为xcodebuild无法实现此功能。它与xcode不同。当我们使用xcode编译iOS项目时,xcode通过clang编译每个.m文件。因此,xcode具有“错误后继续构建”功能。

尝试使用 clang 标志 -ferror-limit=0(仅猜测)。 - trojanfoe
@trojanfoe,我刚刚尝试了“-xcodebuild -sdk iphoneos -configuration Debug OTHER_CFLAGS="-ferror-limit=0"”,但它没有起作用。 - Wellbin Huang
1
好的,那么运行 defaults write com.apple.Xcode PBXBuildsContinueAfterErrors YES 怎么样? - trojanfoe
@trojanfoe,“PBXBuildsContinueAfterErrors”对我很有效。非常感谢,这正是我想要的。 - Wellbin Huang
2个回答

5

您需要设置Xcode的偏好设置来完成此操作(从Terminal.app):

$ defaults write com.apple.Xcode PBXBuildsContinueAfterErrors YES

xCode 8版本:

$ defaults write com.apple.dt.Xcode IDEBuildingContinueBuildingAfterErrors 1

4
谢谢!我使用 "xcodebuild -sdk iphoneos -configuration Debug PBXBuildsContinueAfterErrors=YES" 来完成此操作。 - Wellbin Huang

5

如果你想在最新版本的xcodebuild/xctool中继续构建错误后的项目,你需要使用-IDEBuildingContinueBuildingAfterErrors=YES运行它们。

例如:

xctool -project SampleProject.xcodeproj/ -scheme SampleProject -sdk iphonesimulator build -IDEBuildingContinueBuildingAfterErrors=YES

看起来PBXBuildsContinueAfterErrors不再受支持。

此外,您可以使用defaults write com.apple.dt.Xcode使此设置永久生效。如果您想查看当前版本的IDE如何控制该设置,可以调用defaults read com.apple.dt.Xcode并搜索"errors"和"continue"。


谢谢。但是我需要的是在一次编译中显示所有的编译错误。经过深思熟虑,我认为这是不可能完成的任务。假设ClassA依赖于ClassB,现在ClassA和ClassB都有编译错误,编译器只能显示ClassB中的错误。对吗? - Wellbin Huang

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接