11

You're kidding, right?

Not only is it bad enough that I have to select Editor > Syntax Coloring > Javascript for every JS file in my project, whenever I restart Xcode 4, all the Syntax Coloring preferences set up disappear for each file. Shouldn't this be saved in the project somewhere?

  1. Why don't .js files automatically get detected as javascript syntax?

  2. And why doesn't Xcode save this preference at the project level or at the very least, for the files on which you've selected it?

Please tell me there's a better way.

Old McStopher
  • 6,295
  • 10
  • 60
  • 89
  • 1
    Xcode seams to recognize my js-file as JavaScript for me and it works fine (but adds them to "Compile Sources"). Maybe Xcode get confused by BOM-headers etc? did you create the files with Xcode or some other editor? Can you upload an example file that don't work for you? – Mattias Wadman Jan 09 '12 at 16:57
  • 1
    Give this a shot http://stackoverflow.com/questions/2138047/xcode-code-loses-syntax-coloring/7676487#7676487 – Geuis Jan 13 '12 at 16:38

2 Answers2

1

Syntax highlighting for JavaScript works fine for me in Xcode 4.3.2 (plus I haven't noticed any issues in earlier versions). Xcode is very temperamental - you should try deleting the derived data as jayboston suggests - I often have to do this and restart Xcode a number of times to have it work properly.

If that doesn't solve it then there's a chance your xcodeproj file might be a little corrupted or at least hard for the system to understand. Try creating a new project file and then importing all your old contents into it (manually - don't copy from the old project file) to see if that fixes anything.

Benjie
  • 7,701
  • 5
  • 29
  • 44
0

I can't specifically answer your questions as to "why" there's not autodetection and such, but perhaps rebuilding your project index will eliminate the need for the manual process of selecting the syntax highlighting preference ea time you start Xcode.

If you open up Organizer and select the "Projects" tab you'll see the Derived Data location. If you Delete it with the button to the right that will force Xcode to rebuild your project index which includes the syntax highlighting information.

I specifically haven't used Javascript in my xcode projects, but I've had similar syntax highlighting issues which this resolved.

Regardless of whether this works or not - some attention from APPl on this one would be great.

jaySF
  • 94
  • 1
  • 10