Skip to content

Instantly share code, notes, and snippets.

@jianhu
Created July 20, 2012 09:05
Show Gist options
  • Save jianhu/3149740 to your computer and use it in GitHub Desktop.
Save jianhu/3149740 to your computer and use it in GitHub Desktop.
Applescript to beautify Objc code in Xcode
tell application "Xcode"
if (frontmost of it = false) then
return
end if
set documentList to source document of it
set listLength to count of documentList
if listLength is less than 1 then
return --no opened source file in working space
end if
set filePath to path of item listLength of documentList -- get the last one
set filePathStr to filePath as text
if (filePathStr ends with ".m" or filePathStr ends with ".h") then --only format source file
do shell script "uncrustify -c ~/.uncrustify/objc.cfg --no-backup " & filePathStr -- where the essense resides..
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment