Projucer on macOS corrupting source files?

I have a project where when I add or remove a file in Projucer and then re-export to Xcode, a few - but not all - source files are corrupted.

The corruption looks like semi-random character deletion, duplication or transposition. For example, the lines:

    static const unsigned InsetHorizontal   =   10;         ///< Pixel inset distance.
    static const unsigned InsetVertical     =   10;         ///< Pixel inset distance.
    enum ColourIds


    static const unsigned InsetHorizontal   =   10;         ///< Pixel inset disance.
    static const unsigned InsetVertical     =   10;         ///< Pixel inset disanace.
    enum ColurIds

The corruption happens every time the project is re-exported to Xcode (typically when adding a new source file).

I can not see any obvious pattern that would explain why only a few files are corrupted. All the files in the project are plain ASCII with unix line-endings, appear have no gremlin characters, and there is nothing unusual in the .jucer file.

I can understand Projucer changing line endings, but “public” → “pbulic”?

Never edit files in projucer, it’s broken. Before saving to ide projects, make sure you close all open document (and make sure you have version control in place).

I have not lost any work due to this thanks to git and the obvious nature of the corruptions. However, you have to wonder if there are also more subtle corruptions that might get overlooked, such as switching digits inside of a number.

I can not find a specific sequence of events that leads to the corruption. Quitting Projucer temporarily fixes the problem, so only launching and using Projucer only when it is absolutely essential to make project changes is a viable workaround.

Without being able to reproduce this issue ourselves, there’s not much we can do to debug it here. If you can work out exactly what triggers the problem, that would help a lot.

I’d be very surprised if this happens as a matter of course when using the Projucer. Lots of users regularly resave projects as part of their workflows, so I’m sure we’d have other reports of this issue if it happened whenever the Projucer exported a project. I find it more likely that this is triggered by some particular aspect of your setup or workflow.

Do you have the project files open in Xcode (or another editor) while you’re saving in the Projucer? I wonder whether the behaviour you’re seeing could be caused by multiple programs trying to write/resave files simultaneously.

Some things you could try, to see whether they help:

  • In the Projucer, select “Document → Close all documents” before exporting the project, and/or
  • Close all project files in any other editors before exporting.