Xcodebuild generates empty compile_commands.json

I am using the following commands to use oclint with xcode 5-

Step1: xcodebuild -target OClintDemo -configuration Debug schema OClintDemo -sdk iphonesimulator
Step 2: OClintDemo jenkins $ xcodebuild -sdk iphonesimulator | tee xcodebuild.log
Step 3: oclint-xcodebuild xcodebuild.log
Step4: oclint-json-compilation-database - -o = report.html

but i get empty compile_commands.json and report.html is OCLint Report Summary: TotalFiles = 0 FilesWithViolations = 0 P1 = 0 P2 = 0 P3 = 0 [OCLint ( http://oclint.org ) v0.7]

+4


source to share


4 answers


Xcode 8 doesn't support xctool, you can use xcpretty . Your xcodebuild command should be like this

If you are using a workspace

xcodebuild -workspace WORKSPACE_NAME.xcworkspace -scheme SELECTED_SCHEME | xcpretty -r json-compilation-database --output compile_commands.json

      



For one project

xcodebuild -project PROJECT_NAME.xcodeproj | xcpretty -r json-compilation-database --output compile_commands.json

      

+3


source


This is how I got the correct compile_commands.json

file ( Xcode 8.3 )

Clean up your build

xcodebuild clean -workspace WORKSPACE.xcworkspace/ -scheme "SCHEME"

This will ensure that xcodebuild will recompile all your files, which will then appear in the compilation database.



Create and generate compile_commands.json :

xcodebuild -workspace WORKSPACE.xcworkspace/ -scheme "SCHEME" | xcpretty -r json-compilation-database -o compile_commands.json

Obviously, you should replace the workspace and schema with the values โ€‹โ€‹of your projects. You can also run this for a project using -project

instead -workspace

.

+3


source


you try this script

#xctool oclint
xctool  -workspace iWeidao.xcworkspace \
        -scheme iWeidao \
        -reporter json-compilation-database:compile_commands.json clean build

oclint-json-compilation-database -v oclint_args "-report-type html -o report.html -rc=LONG_LINE=120"
open compile_commands.json
open report.html

      

here https://github.com/facebook/xctool/issues/270

+1


source


  • try to clean the assembly first and then rebuild
  • make sure there is no space in the file name or path.
0


source







All Articles