Analyze Objective-C/C++ with CodeMRI®

Performing Analysis of your Objective-C source code is a bit different than analysis with other supported languages. This is due to the “source-file” detection pattern used by Sci-Tools Understand Software and will require a minor change to your configuration in order to properly analyze it.

If attempting to analyze Objective-C codebases that have intermixed C/C++ & Obj-C header files follow the instructions at this link instead: https://silverthread.atlassian.net/wiki/spaces/CKB/pages/2775973890. Additionally, all these instructions can be altered to configure for Objective-C++

Configure Understand for Objective-C Processing

This guide assumes you have a valid vault and have successfully authenticated your user credentials. If you need help setting this up, review the https://silverthread.atlassian.net/wiki/spaces/CKB/pages/2527789057 for basic vault configuration.

First create your project and system

cmri shell project add -n project_name system add --selection project_name -n system_name -v 1 --origin /path/to/obj-c_code

Next select the project & system you’ve created to run a job.

cmri shell # If not currently in the shell select --add project_name/system_name-1 job run produce_reports

At this point you may or may not have had a successful run against your code-base. However, your analysis of this code base is almost certainly invalid. This is due to the fact that Understand is reading the .h extension as a C++ extension by default. To verify this, run the following command:

# Assumes your cmri installation is under /home/user/cmri # Also assumes your vault location is under /home/user/vault /home/user/cmri/understand5/scitools/bin/linux64/und list -all settings -db /home/user/vault/projects/project_name/systems/system_name-1/data/element.udb

This command will list out the configuration for your particular instance of Understand and the modifications made to this configuration by the specified system cmri was executed against. You can see below that the .h extension is configured to be analyzed as C++ Header Files.

To configure the system to analyze files with a .h extension, you will need to execute the following command.

Note that while a .udb is required as input to this command, this in reality makes a system wide change to your understand configuration. In a future update of CodeMRI we will be altering this behavior to operate on a per “cmri-system” basis.

You should now be globally configured to process Obj-C Header files.

Create an Objective-C Project & System

Now that Understand has been configured to process header files for the Objective-C codebase we can now create a system to execute against this.

With this sequence of commands executed you should now have valid metrics being reported for your Objective-C codebase.