Search code examples
iosobjective-ciphonecompiler-directives

"Burning" the result of a #define


Suppose a define like this

#define myDate [NSDate date]

every time I use it, it gives me the current date, what is ok.

What I want is to store the date the code was compiled. Can I do that with defines or using any other way?

I want the date to be hard stored in the code.

Ok I know I can store the date as string, this is not what I want.


Solution

  • GCC has predefined macros for this. Check out __DATE__ and __TIME__.

    https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html

    Also, you can define your own key like CFBuildDate and increment it with a script : Xcode project's "Build number"