roddi / ValidateStoreReceipt

validate the receipt a well-known computer company's application store sends
355 stars 37 forks source link

Alternative to statically defining ID and version (while still statically defining them) #19

Open urkle opened 12 years ago

urkle commented 12 years ago

Using some Macro magic we can do this.

#define makeStr(s) makePStr(s)
#define makePStr(s) #s

#if !defined APP_BUNDLE_ID && !defined APP_BUNDLE_VERSION
#error  Define APP_BUNDLE_ID and APP_BUNDLE_VERSION
#endif

NSString * const bundleVersion = @makeStr(APP_BUNDLE_VERSION);
NSString * const bundleIdentifier = @makeStr(APP_BUNDLE_ID);

This will still statically define them, YET allow them to be "updated" with the via macro defines. So simply adding

APP_BUNDLE_ID=com.example.${PRODUCT_NAME} APP_BUNDLE_VERSION=${APP_VERSION} (assuming you also have a ${APP_VERSION} variable defined) to the xcode preprocessor settings will allow central management of the bundle ID and version for receipt validation as well as Info.plist generation.

ItalyPaleAle commented 12 years ago

+1 for this