Eric Roller's Development Blog

VersionNumber : parse error before ';' token

- Posted in macOS by

A not very well documented error message which occurs right at the beginning of the build, typically during compilation of the prefix file. The error is found in a derived file, for instance:

.../EnterMordor.build/DerivedSources/EnterMordor_vers.c:1: error: parse error before ';' token:

[...] const double EnterMordorVersionNumber __attribute__
((used)) = (double);

Observe that there is no valid argument after the equal sign. To find the cause, we must know that derived files are based on our build settings. In my case, the fault lies in the fact that the built setting VERSIONING_SYSTEM is set to apple-generic, but I was missing is a setting for the CURRENT_PROJECT_VERSION variable.

See also Xcode: Help -> Show Build Setting Notes -> Versioning.

According to Chris Hanson's article, the apple-generic versioning system uses agvtool to auto-update all Info.plist files. Also, there will be a TargetVersionString and a TargetVersionNumber variable available to your code. Right now, I you do not like or need all that, so I simply set the versioning system to "none" and continue to manually update the CFBundleShortVersionString and CFBundleVersion settings.