1. Introduction of tools
Infer is a static program analysis tool that can be used to analyze Java, C, and objective-c programs, which are written in OCaml.
Infer was first deployed on Facebook to analyze each line of code before it was released for mobile apps, and now Facebook uses this tool to analyze the Android, IOS apps that are being developed, including Facebook Messenger, Instagram and some other applications. Infer not only for mobile application analysis, but also for the analysis of C, Java and other not Android system code. At present, infer focuses on discovering problems such as access to null pointers, leaks of resources and memory, and the crash of mobile phone programs or severe performance degradation.
2. Download Unzip
2.1 https://github.com/facebook/infer/releases
2.2 Tar XF infer-0.2.0. Tar
3. Setting up the environment (you can see the install.md inside the unpacking package)
3.1 Download Install Opam (https://opam.ocaml.org/doc/Install.html)
3.2 Installing Clang
Xcode-select--install
3.3 Installing OCaml
Opam Init--comp=4.01.0 # (answer ' y ' to the question)
Eval ' opam config env '
Opam Install sawja.1.5 atdgen.1.5.0 javalib.2.3a extlib.1.5.4
4. Installing infer
CD Infer
./update-fcp.sh &&. /facebook-clang-plugin/clang/setup.sh &&./compile-fcp.sh
Make-c Infer
Export path= ' pwd '/infer/bin: $PATH
5. Engineering Static Analysis
Analytics App:
Infer--Xcodebuild-target <target name>-configuration <build configuration>-sdk <SDK>
Sample Detection Helloworldapp Engineering:
Infer--Xcodebuild-target helloworldapp-configuration debug-sdk iphonesos8.3
You need to use --incremental
(or -i
) to make the result output of an incremental compilation:
Infer--incremental--xcodebuild-target helloworldapp-configuration debug-sdk iphonesos8.3
or clean up before compiling:
Xcodebuild-target helloworldapp-configuration debug-sdk iphonesos8.3 Clean
OK, here you will see the results you want to see.
Reference Document: Http://infer.liaohuqiu.net/docs/getting-started.html
Tool-infer, Static code detection