Sorcerer13
Sorcerer13

Reputation: 86

Running a Clang LibTooling tool over an iOS Xcode project

I've written a toy libtooling based tool that does some analysis/source rewriting over ObjectiveC code. How do I run it over an iOS Xcode project?

I've looked at compiling the application through commandline/clang, but I haven't got it to work yet. Is it possible to chain my tool with xcodebuild? Or is there a better way to run the tool over an Xcode project?

Upvotes: 1

Views: 498

Answers (2)

user3839384
user3839384

Reputation: 11

I think what you need is JSON-Compilation-Database.

You can use xctool to generate a json compilation databse (xctool has a reporter that generate this thing, see the readme.)

The json compilation database is just a json file which contains all the compiler options (say, the header search path, the frame work search path) that need to pass to the clang and libtooling based tools.

Upvotes: 1

ekeren
ekeren

Reputation: 3458

If you want your tool to generate errors and warnings in code it should be a clang plugin and you can just change your project clang flags to load the plugin.

In your case it seems like you are using libtooling that alters the source code, you can simply add your script to your project build process prior to the "Compile Sources" stage.

  1. In Xcode -> Click on Project -> click on your desired Target -> Build Phases -> Click on Editor (Menu Bar) -> Add Build Phase -> Add Run Script
  2. Drag the new Run Script to be before Compile Sources
  3. Edit the run script phase to do what you want

Upvotes: 0

Related Questions