This set of instructions will help you get started with finding potential bugs in your app. They are provided for developers who do not have their provisioning certificate yet.
Why would you want to use this static code analysis tool? Why wouldn’t you? It’s another tool in your belt to detect bugs early and is probably a good idea to do before submission to the App Store.
Debugprofile that Xcode sets up for you when you create a new iPhone project.
Project > Set Active Build Configuration > Debug
xcodebuildfrom the root directory of your project.
If you haven’t run this tool before, you may run into this output:
$ xcodebuild === BUILDING NATIVE TARGET Property Machine OF PROJECT Test Project WITH THE DEFAULT CONFIGURATION (Debug) === Checking Dependencies... CodeSign error: Code Signing Identity 'iPhone Developer' does not match any code-signing certificate in your keychain. Once added to the keychain, touch a file or clean the project to continue. ** BUILD FAILED **
In this particular case, the project was set up to build against the iPhone device and not the iPhone simulator. Building for the device requires you to use an iPhone provisioning certificate which can be had for USD 99 from the Apple iPhone Developer Program. If you wish to write and compile software without a provisioning certificate - you may still test your app in the simulator provided with the SDK however you will not be able to test your app on the device itself.
Project > Edit Project Settings
Simulator - iPhone OS 2.2(or whichever version of the iPhone OS you wish to build for).
Code Signing Identityis set to
Don't Code Sign(if you don’t have a provisioning certificate yet).
Code Signing Identitydisclosure) and ensure it is also set to a simulator SDK. Also ensure the value for this option is
Don't Code Sign.
xcodebuildinside your project’s directory and your project should now build.
xcodebuild clean scan-build -k -V xcodebuild