Jun 18, 2013

Color Go source codes in Xcode 4.x

By default, Xcode does not syntax hightlight.
But, we can configure in the following way.

HOW TO
  1. Download the shell script
  2. Config the path
  3. Execute the shell script
  4. Check

1. Download the shell script

The script that empower Xcode syntax highlighting is distributed.

Download go4xcode.sh  from here.

There is no need to download go.sclangspec, because it is contained in SDK of Google App Engine.
By default, it is here.
/Applications/google_appengine/goroot/misc/xcode/4/go.xclangspec


2. Config the path

The script uses the environment variable $GOROOT.
Check whether it is configured correct path.
$ su
$ echo $GOROOT
If displayed path to goroot, there is no problem.
If else, set the path to goroot.
$ export GOROOT=/Applications/google_appengine/goroot/


3. Execute the shell script

Let's execute the shell script.
$ sh go4xcode.sh
Backing up plugindata file.
Adding Go language specification entry.
Duplicate Entry Was Skipped: Xcode.SourceCodeLanguage.Go
Installing Go language specification file for Xcode.
Run 'sudo rm -rf /var/folders/*' and restart Xcode to update change immediately.
Syntax coloring must be manually selected from the Editor - Syntax Coloring menu in Xcode. 

Remove trashes according to message.
$ rm -rf /var/folders/*

it's complete.


4. Check

Launch the Xcode.
If installing is succeed, there is a new menu Editor -> Syntax Coloring -> Go.



When click this, Xcode syntax highlighting source code.
But this is not configure automatic.

No comments:

Post a Comment