[cfe-dev] Compile/refactor iOS Xcode projects

Mathieu Baudet mathieu.baudet at gmail.com
Fri Mar 7 16:06:11 PST 2014


To run frontend tools on xcode projects, a first solution is indeed to
generate a file compile_commands.json, possibly using xcodebuild -dry-run
and some parsing script like "oclint-xcodebuild" (see the oclint
project on github).

It is also possible to run frontend plugins directly by setting
appropriate "build settings" of xcode. (Several ways to do this, you
can set them on the command line for instance: xcodebuild build
FOO=bla.)

Here are a few build settings that I found useful to inject C flags:
  OTHER_CFLAGS
  OTHER_CPLUSPLUSFLAGS

or to replace the compiler(s) and linker(s):
  CC
  CPLUSPLUS
  LD
  LDPLUSPLUS
  LIBTOOL

The same approach works to control the "analyze" action:
  CLANG_ANALYZER_EXEC
  CLANG_ANALYZER_OTHER_FLAGS

Disclaimer: some of those build settings are undocumented (afaik). Use
at your own risk.

-- Mathieu

2014-03-07 11:33 GMT-08:00 Richard <legalize at xmission.com>:
>
> In article <1393616491465-4038170.post at n3.nabble.com>,
>     s0rcy <siddarth13+clangcfe at gmail.com> writes:
>
>> I've written a simple libtooling based tool to refactor source code, and
>> while it works on simple projects, I'd really like to run it over an iOS
>> Xcode project. Is there a way to do this?
>
> I think your best bet is to find some way of creating a
> compile_commands.json from your Xcode project.
>
> CMake can go the reverse direction -> making an Xcode project from
> CMakeLists.txt.
>
> Xcode projects are simple text files, you could probably get yourself
> generating a reasonable compile_commands.json from a simple perl or
> python script.
> --
> "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
>      The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
>          The Terminals Wiki <http://terminals.classiccmp.org>
>   Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list