2

我在尝试构建我的 OCLint 聚合时收到以下错误。

我们在工作区中使用预编译的头文件,尽管它们在主目标和 OCLint 聚合中的引用完全相同,但由于某种原因,OCLint 聚合无法发现 pch。

这就是找不到“CocoaLumberjack/CocoaLumberjack.h”依赖项的原因。

我在 OS X 10.11.1 下运行 Xcode 7.1.1

*=== BUILD TARGET [Target] OF PROJECT [Project] WITH CONFIGURATION Debug ===
Check dependencies
ProcessPCH /var/folders/nv/y04q5c5s30567pk7w8lts7zr0000gn/C/com.apple.DeveloperTools/7.1.1-7B1005/Xcode/7.1.1-7B1005/Xcode/SharedPrecompiledHeaders/[Project]-Prefix-canqfypuftycqgglhiqfotrflhkv/[Project]-Prefix.pch.pch [Project]/[Project]-Prefix.pch normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/.../Dev/Applications/[Project]
    export LANG=en_US.US-ASCII
    export 

PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/.../StaticCodeAnalysis/OBJ-C/OCLint/oclint-0.8.1/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/local/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

   :
   :
/Users/.../Dev/Applications/[Project]/[Project]/[Project]-Prefix.pch:16:9: fatal error: 'CocoaLumberjack/CocoaLumberjack.h' file not found
[#import] <CocoaLumberjack/CocoaLumberjack.h>

        ^
1 error generated.
** BUILD FAILED **
[Project]

The following build commands failed:
    ProcessPCH /var/folders/nv/y04q5c5s30567pk7w8lts7zr0000gn/C/com.apple.DeveloperTools/7.1.1-7B1005/Xcode/7.1.1-7B1005/Xcode/SharedPrecompiledHeaders/[Project]-Prefix-canqfypuftycqgglhiqfotrflhkv/[Project]-Prefix.pch.pch [Project]/[Project]-Prefix.pch normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)*
4

2 回答 2

2

更新: 我可以通过发出以下命令来解决这个问题:

xcodebuild -workspace MyWorkspace.xcworkspace -scheme MyScheme
于 2015-12-16T17:02:49.927 回答
0

我在 macOS Monterey ( )上12.2尝试通过pre-commit. 来自 OCLint 的错误消息暗示缺少“编译数据库”,然后给出了'stdio.h' file not found系统 C 标准库头文件。

手动解决方案

解决方案是确保compile_commands.json顶级 C 构建目录中存在一个文件。如果您使用 CMake,这显然是自动生成的,但该项目没有使用 CMake。

手动创建文件:

compile_commands.json

[
{
  "directory": ".",
  "command": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -o enum-test.arm64.o -c enum-test.c",
  "file": "enum-test.c"
},
{
  "directory": ".",
  "command": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -o test-args.arm64.o -c test-args.c",
  "file": "test-args.c"
},
{
  "directory": ".",
  "command": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -o test-vars.arm64.o -c test-vars.c",
  "file": "test-vars.c"
},
{
  "directory": ".",
  "command": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -o cidr_ranges.arm64.o -c cidr_ranges.c",
  "file": "cidr_ranges.c"
},
{
  "directory": ".",
  "command": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -o rectangle.arm64.o -c rectangle.c",
  "file": "rectangle.c"
}
]

OCLint 错误信息:

compile_commands.json就我而言,在给出file not foundfor.h头文件之前,该错误暗示了缺失:

$ oclint  -enable-global-analysis -enable-clang-static-analyzer -max-priority-3 0  ./enum-test.c  -p=build -verbose --extra-arg -isysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk

Error while trying to load a compilation database:
Could not auto-detect compilation database from directory "build"
No compilation database found in ~/src/spikes/c-variables-and-data-types/build or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.

Compiling ~/src/spikes/c-variables-and-data-types/enum-test.c ...
 - Failed
Clang Static Analyzer ~/src/spikes/c-variables-and-data-types/enum-test.c - Finished with Failure

Compiler Errors:
(please be aware that these errors will prevent OCLint from analyzing this source code)

~/src/spikes/c-variables-and-data-types/enum-test.c:8:10: 'stdio.h' file not found

Clang Static Analyzer Results:

~/src/spikes/c-variables-and-data-types/enum-test.c:8:10: 'stdio.h' file not found


OCLint Report

Summary: TotalFiles=0 FilesWithViolations=0 P1=0 P2=0 P3=0


[OCLint (https://oclint.org) v21.10]
于 2022-02-03T00:07:02.223 回答