The Receigen documentation, and other sources, suggest validating your app’s receipt as soon as possible, early in the main
method even.
When I call the Receigen-generated code in main
method, I get a execution-interruption when the app has no Receipt.
int main(int argc, char *argv[])
{
@autoreleasepool {
MyPrefix_CheckReceipt( [[MyReceiptRefreshDelegate alloc] init] );
return UIApplicationMain(argc, argv, nil, NSStringFromClass([XMAppDelegate class]));
}
}
The call to return UIApplicationMain
shows this error message in Xcode 7.3.1:
Thread 1: EXC_BAD_ACCESS (code=1, address=0xe)
Moving this call to MyPrefix_CheckReceipt
from main
method to the top of my app delegate’s didFinishLaunchingWithOptions
method is a workaround. No EXC_BAD_ACCESS
error occurs when receipt is not present.
Having no Receipt can happen in the field when a user restores their app from a backup via iTunes app on a Mac or PC. And having no Receipt always happens in development when executing via Xcode on a real hardware iOS device for the first time or after having deleted the app from device.
Running a second time exhibits no such error. I verified the receipt is successfully retrieved from the fake "sandbox" App Store, and is present on the second run.
So the Question is: Why does the Receigen code fail with a crash when no Receipt is found but only when the verification call is made from the main
method?