[LLVMbugs] [Bug 4083] New: Using Clang on iPhone

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Apr 26 15:40:46 PDT 2009


           Summary: Using Clang on iPhone
           Product: clang
           Version: unspecified
          Platform: Macintosh
        OS/Version: Mac System 9.x
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Documentation
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: chadsspameateremail at yahoo.com
                CC: llvmbugs at cs.uiuc.edu

When trying to use Clang on a project built for the iPhone (on Mac OS X) I
found that the instructions didn't provide the correct result.  Instead I
created alternate instructions which I have attached below.  Feel free to use
this to update your documentation for people building for the iPhone.


Step 1: Download the Mac OS X version of clang from this website:

Step 2: Double click on the download to unarchive it.

Step 3: Place the checker-xxx directory where you want to install Clang.  For
this example I'll place it in the Documents directory which would be
~/Documents.  The folder name is checker-0.189 in my example.

Step 4: Open Terminal and add Clang to your path by typing:
echo 'export PATH=~/Documents/checker-0.189/:$PATH' >> ~/.bash_profile

Replace ~/Documents and checker-0.189 as appropriate.

Step 5: Close the current terminal window or open a new terminal window.  This
must be done for the changes in the path to take effect.

Step 6: At this point you may need to set the code signing identity of the
project you want to scan.  This must be setup correctly or Clang will not be
able to build your project correctly.  In XCode you can set the code signing
identity to yourself by going to "Project->Edit Project Settings" in XCode and
then under the build tab finding "Code Signing Identity" and selecting
yourself.  This is the same step which is necessary to build on the device. 
Note that Clang will often try and build the release version of the application
so be sure the "Code Signing Identity" is also set correctly for the Release
"Configuration" you can select your "Configuration" by using the
"Configuration" pop-up menu.

Step 7: In the "Edit Project Settings" window above under the build tab you
should also set the Base SDK to Simulator-iPhone OS 2.2.1.  This will allow
Clang to better analyze the project.  You should not be building for the device
here or you will see warnings on the terminal that the arm processor is not
recognized by Clang and it can't find the appropriate version of GCC.

Step 7: In Terminal Navigate to the directory where the project you want to
test is located.  Make sure you are in the directory with the project.  In my
example the iCS folder is located on the desktop so I type:
cd ~/Desktop/iCS

Step 8: Once we are in the proper directory where the xcode project file is
located we can run the scan-build program which launches Clang.  It keys off of
the current path in terminal and builds the files/project within that
directory.  You should not specify a project name.  Though you can specify and
output directory using the -o option as I do below.  Once run successfully
Clang will create a series of HTML files in the output directory you specified.
 In my example I type:

scan-build -V -o ~/Desktop/ClangOutput xcodebuild

After the program finishes it automatically launches a web browser displaying
the Clang results.

Each time you run Clang will build the project and during the building finds
the errors it reports.  If you run Clang twice in a row the second time it will
generate no output because no files need to be built.  If you want Clang to
retest the entire project you will need to make a change that makes Clang
rebuild the entire project.  One example would be to modify the iCS_Prefix.pch
file by adding some whitespace.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list