Code 173 no longer triggers receipt generation

My macOS application exits with code 173 when the Mac AppStore receipt validation fails. This used to trigger a system dialog that allowed me to enter test user credentials which then created an AppStore receipt. Now this behaviour changed to just showing a dialog stating that the application is damaged and needs to be redownloaded from the AppStore. This makes it impossible for me to test receipt validation for my app.

What might have caused this change in system behaviour? I'm even getting this "damaged application" dialog when I delete the "_MASReceipt" folder from third party applications when I'm pretty sure that before it also showed this dialog that allows to enter AppStore credentials and recreate a valid receipt.
Answered by Schubert in 702880022

It's now working again.

I have the same problem, also the code:

Code Block
NSBundle *mainBundle = [NSBundle mainBundle];
NSURL *receiptURL = [mainBundle URLForResource: @"receipt" withExtension: @""];
receiptData = [NSData dataWithContentsOfURL: receiptURL options: NSDataReadingMappedAlways error: &theError];

crashes without logging any errors in the console pane in XCode or the console when I use the dataWithContentsOfURL method and then I start to get all of the application is damaged alerts.

How can you test your receipt validation code with this bug? You should file a bug report. Also there are other threads about this.
It's working again (without me having done anything). So I guess this was a fluke in the AppStore.

This appears to be randomly happening again. Curious if anyone else has been experiencing this problem lately. Found the following related logs in the Console:

default    15:39:49.352585-1000    storeuid    <StoreKitClient: 0x7f8898d2d820>: Using active account. Sandbox: 1, receipt exists: NO, receipt is stub: NO
default    15:39:49.354734-1000    commerce    storeuid[552] starting request app-receipt-create
default    15:39:49.455240-1000    commerce    <CKStoreRequest: 0x7f94a1f64e10> https://p100-sandbox.itunes.apple.com/WebObjects/MZFinance.woa/wa/createAppReceipt
default    15:39:49.877166-1000    commerce    StoreSession: StatusCode: 200; <private>; Environment: SB-MR; URL: https://p100-sandbox.itunes.apple.com/WebObjects/MZFinance.woa/wa/createAppReceipt
error    15:39:49.879812-1000    storeuid    <ReceiptRefreshRequest: 0x7f889a1616e0>: No receipt data in response
error    15:39:49.879883-1000    storeuid    <ReceiptRefreshRequest: 0x7f889a1616e0>: Error fetching receipt for X - Error Domain=com.apple.commerce.client Code=500 "(null)"
default    15:39:49.880675-1000    storelegacy    StoreLegacy: Failed to renew receipt for application at path X : 'The operation couldn’t be completed. (com.apple.commerce.client error 500.)'
error    15:39:49.930396-1000    diagnostics_agent    Invalid receipt [0 bytes]

Apple broke this. All developers have the same problem. It's probably not a bug in XCode, more likely would be macOS 12.0.1 Monterey or the App Store. You won't be able to build your app with receipt validation until they fix this - probably in the next update of Monterey.

Again this is no longer working for me. Am I alone with this problem or can anyone else confirm this?

I updated to the release candidates of Monterey 12.1 and Xcode 13.2 and the problem persists. One would think this should be a top priority issue.

Dear @eskimo, could you, please, provide us any support for this issue?

I've been doing the same process for the same app for 9 years, same build, sandbox in-app, etc, etc. Now, without changing anything, I am completely blocked with the error described in this thread. I've tried just everything possible, from new certificates, cancelling and recreating all certificates, etc, etc. But nothing, the app closes during startup, log shows:

  • Error fetching receipt for xxxx - Error Domain=com.apple.commerce.client Code=500 “(null)”
  • ‘The operation couldn’t be completed. (com.apple.commerce.client error 500.)’

Then the nightmare message App is damaged ... Instead of relaunching the app asking for the sandbox account login as have always happened.

On this thread and a few others, you can see that there are many developers facing the same situation without any alternatives.

Thanks in advance, Fernando

I'm seeing this again now on macOS 12.3.1. After exit(173), macOS brings up the system dialog for app store credentials, then fails with the message "the application is damaged and needs to be redownloaded from the AppStore" for my Xcode builds, and also for my archived TestFlight builds. Until recently, it would fetch the _MASReceipt automatically without a dialog. Does anyone know what might have changed? Whether this is something I broke? Something on Apple's end? Something in my system? Logging in and out of the app store, rebooting, have no effect.

Is there anything that we can do on our end? I'm facing the same problem.

I'm not prompted for a sandbox user anymore. Somehow the system has remembered the sandbox user. Is there a way to remove the sandbox user-data? Maybe that will help.

Until then: the 500 error is clearly something at the App Store end that is broken. You would think that Apple has monitoring in place on errors happening on their services...

App receipt generation is broken. I'm getting this message on macOS Monterey 12.3.1 with Xcode 13.3.1. What can be done?

“My App” is damaged and can’t be opened. Delete “My App” and download it again from the App Store.

+1 ... Building my app with macOS 12.3.1 (M1) and Xcode 13.3.1, and no receipt is retrieved after exiting with 173. Tried App Store log out / log in (sandbox and regular account) as well as reboot to no avail.

+1, filed a duplicate feedback FB10014055 

This issue started for me today (5/13/22) IMMEDIATELY after Mac Software Update installed Xcode Command Line Tools 13.4. After that ANY MacOS App running in Xcode under does an Exit(173) due to NOT finding any App Store Receipts. I get this message:

“x” is damaged and can’t be opened. Delete “x” and download it again from the App Store.

I am not sure why it installed 13.4 before Xcode 13.4 is released but that is what update automatically installed. I'm on MacOS 12.3.1 (M1) and running Xcode 13.3.1.

I tried rolling back to the 13.3.1 Command line tools but that didn't fix anything.

Only way I can run and develop my mac apps now is to comment out the Receipt check.

Bug report filed - FB10017618

Same issue for me. Started immediately after Mac Software Update installed Command Line Tools 13.4. Still running Xcode 13.3.1 and tried rolling back to command tools for 13.3.1. Didn't help :( Apple!!! Dang it

It's working again now.

I still wished this was mentioned on https://developer.apple.com/system-status/ whenever it goes down.

Hadn't tried Sandbox testing in a while and it's DOA for me again. Just got done filing feedback FB1014100.

Code 173 no longer triggers receipt generation
 
 
Q