In my project's Target Phases I have a Copy Files item:
Destination Wrapper
Subpath @"Contents/_MASReceipt/receipt"
This creates a folder for the digital receipt that the App Store attaches to my app.
I get the receipt with the code:
I have used this code for years. The first time that you launch an unsigned app it should quit with error 173. Then a dialog should appear, asking for your iTunes test user name and password. Doing this should cause Apple to attach a valid receipt to the app and re-launch it. Then the app should run. You only have to do this after you clean your build folder or export your app.
Both calls to the methods that get the path to the _MASReceipt folder return correct results. Starting today when execution reaches the second dataWithContentsOfURL: I get an alert saying that the app is damaged and to reload it from the App Store. XCode doesn't log any errors in the log window.
How does Apple expect me to develop the app and test it if I have to comment out the receipt validation code?
Destination Wrapper
Subpath @"Contents/_MASReceipt/receipt"
This creates a folder for the digital receipt that the App Store attaches to my app.
I get the receipt with the code:
Code:
inline static NSData *getReceiptData(void)
{
NSError *theError = nil;
NSBundle *mainBundle = [NSBundle mainBundle]; //works
NSURL *appStoreReceiptURL = [mainBundle appStoreReceiptURL]; //works but won't work for dataWithContentsOfURL in debugging program
NSData *receiptData = [NSData dataWithContentsOfURL: appStoreReceiptURL options: NSDataReadingMappedAlways error: &theError];
if (!receiptData) { //if no data,try another way to fetch receipt data. This works while debugging:
NSURL *receiptURL = [mainBundle URLForResource: @"receipt" withExtension: @""]; //works and fetches data with dataWithContentsOfURL in debugging
receiptData = [NSData dataWithContentsOfURL: receiptURL options: NSDataReadingMappedAlways error: &theError];
}
if (!receiptData)
[NSException raise:@"MacAppStore Receipt Validation Error" format: @"Failed to fetch the MacAppStore receipt.", nil];
return receiptData;
}
I have used this code for years. The first time that you launch an unsigned app it should quit with error 173. Then a dialog should appear, asking for your iTunes test user name and password. Doing this should cause Apple to attach a valid receipt to the app and re-launch it. Then the app should run. You only have to do this after you clean your build folder or export your app.
Both calls to the methods that get the path to the _MASReceipt folder return correct results. Starting today when execution reaches the second dataWithContentsOfURL: I get an alert saying that the app is damaged and to reload it from the App Store. XCode doesn't log any errors in the log window.
How does Apple expect me to develop the app and test it if I have to comment out the receipt validation code?