简体   繁体   English

OCLint Xcode 9.3.1 故障

[英]OCLint Xcode 9.3.1 Failure

I have the following Run Script, available at http://oclint-docs.readthedocs.io/en/stable/guide/xcode.html我有以下运行脚本,可在http://oclint-docs.readthedocs.io/en/stable/guide/xcode.html 获得

source ~/.bash_profile
cd ${SRCROOT}
xcodebuild clean
xcodebuild | xcpretty -r json-compilation-database --output compile_commands.json
oclint-json-compilation-database -- -report-type xcode

But, when I execute it, I receive the following error.但是,当我执行它时,我收到以下错误。 (1 failure) oclint: Not enough positional command line arguments specified (1 失败) oclint: Not enough positional command line arguments specified

oclint version is OCLint version 0.13 and Xcode 9.3.1 oclint 版本是 OCLint 版本 0.13 和 Xcode 9.3.1

I have found a way to generate a JSON compilation database from an Xcode project without relying on external tools.我找到了一种无需依赖外部工具即可从 Xcode 项目生成 JSON 编译数据库的方法。 Tested with Xcode 13.4.1 on macOS 12 Monterey and Apple Silicon M1 Pro .在 macOS 12 Monterey 和Apple Silicon M1 Pro上使用Xcode 13.4.1进行了测试。

Inside your Xcode Build Settings, or when invoking xcodebuild you can set the following compiler flag:在您的 Xcode 构建设置中,或者在调用xcodebuild时,您可以设置以下编译器标志:
OTHER_CFLAGS = $(inherited) -gen-cdb-fragment-path $(PROJECT_DIR)/CompilationDatabase

This instructs clang to emit a fragment of the compilation database for each compilation.这指示 clang 为每次编译发出编译数据库的片段。 These fragments can easily be combined into the final compilation database by using the following command:使用以下命令可以轻松地将这些片段组合到最终的编译数据库中:
sed -e '1s/^/[\'$'\n''/' -e '$s/,$/\'$'\n'']/' *.json > compile_commands.json

Of course it's a good idea to validate fragments, but that cannot be done without external tools.当然,验证片段是个好主意,但如果没有外部工具,这是无法做到的。

For full details regarding compiler flags, validation of fragments, and references, check out the gist:有关编译器标志、片段验证和引用的完整详细信息,请查看要点:
Generate a JSON Compilation Database from an Xcode project 从 Xcode 项目生成 JSON 编译数据库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM