Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jaredsinclair/d5960a947c538cb8ef4d8527aa6ed888 to your computer and use it in GitHub Desktop.
Save jaredsinclair/d5960a947c538cb8ef4d8527aa6ed888 to your computer and use it in GitHub Desktop.

Set value

GCC_PREPROCESSOR_DEFINITIONS = FOO=My Value

Add Constants.m

It is particularly important to check that the definition of your value exists here, as it will not cause a compilation failure, but instead result in the generation of @"FOO".

@import Foundation;

#include <os/base.h>

#ifdef FOO
NSString* const MyConstant = @OS_STRINGIFY(FOO);
#else
#error Undefined
#endif

Bridging Header

@import Foundation;

extern NSString* const MyConstant;

Access it from Swift

print("value: ", MyConstant)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment