Infer Error: External Error: *** capture failed to execute: exited with code 65

Infer Error: External Error: *** capture failed to execute: exited with code 65

我正在 运行 推断我的一个混合 iOS 项目。以下是命令,

infer --keep-going -o ./Infer --skip-analysis-in-path Pods -- xcodebuild clean build -workspace Codes/Project/Project.xcworkspace -scheme Main -configuration Release SWIFT_OPTIMIZATION_LEVEL=-Onone

构建日志末尾出现以下错误。

External Error: *** capture failed to execute: exited with code 65
Error backtrace:
Raised at Stdlib.input_line.scan in file "stdlib.ml", line 449, characters 14-31
Called from Stdio__In_channel.input_line_exn in file "src/in_channel.ml" (inlined), line 68, characters 13-30
Called from IBase__Utils.with_channel_in in file "src/base/Utils.ml", line 260, characters 11-44
Re-raised at IBase__Die.raise_error.do_raise in file "src/base/Die.ml", line 26, characters 8-56
Called from Integration__Driver.capture in file "src/integration/Driver.ml", line 145, characters 6-36
Called from IBase__Utils.timeit in file "src/base/Utils.ml", line 429, characters 16-20
Called from IBase__ScubaLogging.execute_with_time_logging in file "src/base/ScubaLogging.ml", line 79, characters 29-44
Called from Backend__GCStats.log_f in file "src/backend/GCStats.ml", line 90, characters 10-14
Called from Dune__exe__Infer.run in file "src/infer.ml", line 20, characters 2-36
Called from IBase__Utils.timeit in file "src/base/Utils.ml", line 429, characters 16-20
Called from IBase__ScubaLogging.execute_with_time_logging in file "src/base/ScubaLogging.ml", line 79, characters 29-44
Called from Dune__exe__Infer.run in file "src/infer.ml", line 25, characters 22-94

如何解决?

infer version = 1.1.0_1
Xcode: 12.4
MacBook Pro, 2012 model
macOS: Catalina, 10.15.7

以下步骤解决了我的问题,

第 1 步: 使用以下命令升级推断版本,

brew upgrade infer #worked with version 1.1.0_1

步骤 2: 使用以下命令从正确的项目目录创建 compile_commands.json 文件,

xcodebuild -workspace Codes/Project/Project.xcworkspace -scheme Main -sdk iphoneos14.4 COMPILER_INDEX_STORE_ENABLE=NO OTHER_CFLAGS="-DNS_FORMAT_ARGUMENT(A)= -D_Nullable_result=_Nullable" | tee xcodebuild.log | /usr/local/bin/xcpretty -r json-compilation-database -o compile_commands.json

这里的workspace, scheme, sdk, xcpretty location值要根据自己的来改。如果未安装 xcpretty,则必须先使用 sudo gem install xcpretty.

安装它

第 3 步:在实际的推断命令中使用创建的文件,例如,

infer run --keep-going --skip-analysis-in-path Pods --compilation-database-escaped compile_commands.json