facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.98k stars 2.02k forks source link

Bug in xcpretty causes Infer to lookup files from the wrong place #657

Open UkuLoskit opened 7 years ago

UkuLoskit commented 7 years ago

Hello!

This issue affects Infer as Infer seems to be relying it to gather the list of files to be analyzed.

https://github.com/supermarin/xcpretty/pull/230

dulmarod commented 7 years ago

Hi, thanks for letting us know. If I understand correctly there is a fix already underway, so once it gets merged, we should be fine, right?

UkuLoskit commented 7 years ago

It looks like it could use some prodding on xcpretty's side since the pull request has been been open for almost a year without any comments.

jvillard commented 7 years ago

Maybe we should disable the xcpretty integration by default? See also #759

marcuswu0814 commented 5 years ago

Hi @jvillard,

In my case, I had two projects, first is a CocoaPods project, it can build success without xcpretty and got correct report by infer.

Build with commnad:

infer --skip-analysis-in-path Pods -- xcodebuild -workspace Example/XX-SDK.xcworkspace -scheme XX-SDK-Example -configuration Debug -sdk iphonesimulator clean build

The second project is a App project that had a Watch extension, it can build success with --xcpretty flag, but got some error when reading file from DerivedData.

Build with commannd:

# Build success, but infer capture did not finish successfully.
infer --xcpretty --skip-analysis-in-path Pods -- xcodebuild -workspace ./iPhone-Project.xcworkspace -scheme iPhone clean build

# Build fail when compile a file look like related to Watch Extension
infer --skip-analysis-in-path Pods -- xcodebuild -workspace ./iPhone-Project.xcworkspace -scheme iPhone clean build

Error message:

    CompileC MyFolderPath/DerivedData/iPhone-fqtxfkpooicdeabsgdvplwuwcxrj/Build/Intermediates.noindex/Pods.build/Debug-watchos/Mixpanel-watchOS2.0.build/Objects-normal/arm64_32/SessionMetadata.o MyFolderPath/Pods/Mixpanel/Mixpanel/SessionMetadata.m normal arm64_32 objective-c com.apple.compilers.llvm.clang.1_0.compiler

I found and issue comment here, but I have no idea what the flags really are.

Any suggestions? Really appreciate.

jvillard commented 5 years ago

@marcuswu0814 have you tried the commands specified here?

xcodebuild <your build options> | tee xcodebuild.log
xcpretty -r json-compilation-database -o compile_commands.json < xcodebuild.log > /dev/null
infer run --skip-analysis-in-path Pods --clang-compilation-db-files-escaped compile_commands.json