Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcodebuild generating empty compile_commands.json

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

Step1: xcodebuild -target OClintDemo -configuration Debug -scheme OClintDemo -sdk iphonesimulator
Step2: OClintDemo jenkins$ xcodebuild -sdk iphonesimulator | tee xcodebuild.log
Step3: oclint-xcodebuild xcodebuild.log
Step4: oclint-json-compilation-database -- -o=report.html

but i am getting compile_commands.json empty file, and report.html contains following- OCLint Report Summary: TotalFiles=0 FilesWithViolations=0 P1=0 P2=0 P3=0 [OCLint (http://oclint.org) v0.7]

like image 400
iGagan Kumar Avatar asked Dec 15 '22 20:12

iGagan Kumar


2 Answers

Xcode 8 does not 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 a single project

xcodebuild -project PROJECT_NAME.xcodeproj | xcpretty -r json-compilation-database --output compile_commands.json
like image 158
abdullahselek Avatar answered Dec 17 '22 10:12

abdullahselek


Here's how I got a proper compile_commands.json file (Xcode 8.3)

Clean your build

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

This ensures xcodebuild recompiles all of your files, which would then make them appear in the compilation database.

Build and generate compile_commands.json:

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

You should obviously replace the workspace and scheme with your projects values. You can also run this against a project by using -project instead of -workspace.

like image 25
nenchev Avatar answered Dec 17 '22 09:12

nenchev