Login

Automated Clang From Xcode - [video]

Anyone who uses Clang will appreciate this script.

What It Does

The AppleScript will see if you have more then one project open. If so, a dialog appears asking you to choose which project you wish to run clang against. Once chosen a new Terminal window will open, cd into the chosen projects directory and execute the clang commands.
Pretty cool, huh!

Instructions

Save the AppleScript on your computer and name it clang.scpt. Create a new User Script in Xcode and paste the following.

running time: 00:01:57 Large View

Make sure to change the path to where the clang.scpt resides on your computer.

#!/bin/sh
/usr/bin/osascript /path/to/clang.scpt
Feedback

As always, please let me know if you have any bugs, complaints, suggestion or such.

--GNU		Standard GNU applies
--
--Date:		Thursday February 5, 2009 
--Author: 	Craig Williams
--Desc:		Run clang from Xcode using AppleScript

tell application "Xcode"
	try
		set openProjects to every project
	on error
		display dialog "No Projects Open"
		return
	end try

	set projectList to {}
	if (count of openProjects) is greater than 1 then
		repeat with i from 1 to count of openProjects
			set thisProj to item i of openProjects
			set end of projectList to (name of thisProj)
		end repeat
		set chosenProj to choose from list projectList ¬
			with title ¬
			"Choose project to run clang against." with prompt "Choose Project"
		if chosenProj is false then return
		set theProject to item 1 of chosenProj
		set theProject to project theProject
	else
		set theProject to project 1
	end if
	my runClang(project directory of theProject)
end tell

on runClang(projectPath)
	set clangCmd to "cd " & quoted form of projectPath & ";"
	set clangCmd to clangCmd & "scan-build xcodebuild -configuration Debug clean;"
	set clangCmd to clangCmd & "scan-build -V xcodebuild -configuration Debug"

	tell application "Terminal"
		activate
		do script with command clangCmd
	end tell
end runClang

Comments  

 
0 # 2011-07-28 03:34
Hi I am getting the error while executing the clang
Reply | Reply with quote | Quote
 

Add comment


Security code
Refresh

 

Product Categories