Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
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:
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?
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
In the calling environment the code that calls getReceiptData() calls exit(173) if there is no receipt. According to the latest documentation exit(173) should tell macOS to ask for one's iTunes test user ID and password. If these are valid it should fetch a valid App Store receipt, put it in the Contents/_MASReceipt/ directory and relaunch the app.

I tested this this morning by calling exit(173) at various places in my receipt validation code and it doesn't work. Thinking that this might be a bug like the one that will only open and display the Help Book if the app is in the Applications folder, I tried this as well. No, there is a bug in mac OS Monterey 12.0.1 that makes it impossible to use this feature to debug one's receipt validation code. This means that I can't update my app at the app store because the testers at the App Store won't be able to launch my app - they will get an alert saying that the app is damaged and to reload it from the store.
 

prime17569

macrumors regular
May 26, 2021
192
490
I tried using exit(173) in my Mac app (SwiftUI & Mac Catalyst) and it works as intended on macOS Monterey 12.0.1 with Xcode 13.0. The app quits and a password dialog pops up.

The code I used is from here:

EDIT: Okay, I'm seeing what you're seeing now. Looks like it only prompts for a password the first time you use exit(173). After that, it goes directly to the error message.

EDIT: I went to App Store > Preferences and signed out of my sandbox account. The password dialog then came up for me the next time I launched my app. I think this is what you need to do.
 
Last edited:

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
I tried using exit(173) in my Mac app (SwiftUI & Mac Catalyst) and it works as intended on macOS Monterey 12.0.1 with Xcode 13.0. The app quits and a password dialog pops up.

The code I used is from here:

EDIT: Okay, I'm seeing what you're seeing now. Looks like it only prompts for a password the first time you use exit(173). After that, it goes directly to the error message.

EDIT: I went to App Store > Preferences and signed out of my sandbox account. The password dialog then came up for me the next time I launched my app. I think this is what you need to do.
No, for me and a bunch of other developers the password dialog never pops up even once. I'm signed out of the App Store. I'm using XCode 13.1 so it could be an XCode bug.

I'll try what you say but basically the no Help Book and exit(173) bugs need to get fixed by Apple. In Bug Reporter there are "more than ten" other reports of this bug. If you file a help request with Apple developer they will delete it and not even reply. I tried TWICE. Also that tech note isn't helpful - the problem isn't with in-app purchases, it's with App Store receipts.
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
Thanks for your help. I was signed in at App Store with my test user account. Signing out of the App Store and signing back in with my sandbox test user account doesn't fix this. Apple really ****ed up this time.
 
Last edited by a moderator:

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
If I sign out of my sandbox tester account in App Store I will get a dialog asking me to sign in with my tester e-mail and password. This is right. Then it will sign me into the App Store automatically but it won't attach a receipt in Contents/_MASReceipt/ as it should, then it terminates the app with the ******** alert that the app is damaged.
 
Last edited by a moderator:

prime17569

macrumors regular
May 26, 2021
192
490
If I sign out of my sandbox tester account in App Store I will get a dialog asking me to sign in with my tester e-mail and password. This is right. Then it will sign me into the App Store automatically but it won't attach a receipt in Contents/_MASReceipt/ as it should, then it terminates the app with the ******** alert that the app is damaged.

Yep, definitely a bug on Apple's part. There isn't much that can be done until it is fixed.
 

kaunteya

macrumors newbie
Dec 12, 2021
3
0
I am having a similar experience in the past few days. I think this is happening after updating to macOS Monterey.
Even after launching the app from Finder( and not from Xcode), there is no receipt being downloaded.
I think the first step that is going wrong is I am not able to get a Sandbox alert where I typically enter my sandbox user credentials. It shows me a regular alert with my email address already prefilled from the App Store account.
I did try to open a DTS ticket but they asked me to open report it on feedbackassistant. It has been more than 5 days and I am yet to hear from Apple.
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
I am having a similar experience in the past few days. I think this is happening after updating to macOS Monterey.
Even after launching the app from Finder( and not from Xcode), there is no receipt being downloaded.
I think the first step that is going wrong is I am not able to get a Sandbox alert where I typically enter my sandbox user credentials. It shows me a regular alert with my email address already prefilled from the App Store account.
I did try to open a DTS ticket but they asked me to open report it on feedbackassistant. It has been more than 5 days and I am yet to hear from Apple.
All Mac Developers have the same problem. If any one is running the pre-release version of Monterey it would be useful to try to call exit(173) in your application and see if it is fixed.

I opened a DTS ticket on it TWICE and they deleted it. In feedback assistant in my bug report they had it labeled as more than ten similar reports but later reduced it to only mine. This tells me that they know about it but won't acknowledge it, which is a bad way to handle this in my opinion.
 
Last edited:

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
I upgraded to macOS Monterey 12.1. This does NOT include a new version of the App Store app and it DOES NOT FIX THE EXIT 173 BUG.
 

kaunteya

macrumors newbie
Dec 12, 2021
3
0
I upgraded to macOS Monterey 12.1. This does NOT include a new version of the App Store app and it DOES NOT FIX THE EXIT 173 BUG.
Hey. Thanks for letting us know.
So the fix will either be in the apple servers or there is a thin chance of fix available in new version of Xcode.

I also tried using storekit local testing as it does everything locally. That also does not work. Did any one try this until fix for sandbox users is available?
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
Today I upgraded to XCode 13.2.1. This problem is NOT fixed. It seems increasingly likely that this is a problem with the server at the App Store.
 

kaunteya

macrumors newbie
Dec 12, 2021
3
0
My ticket has been updated with the following info
Recent Similar Reports: More than 10
Resolution: Potential fix identified - In macOS 12.2
Does anyone know the release date of macOS 12.2?
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
No, there's no announced release date. If any developers are using the beta version it would be very helpful for them to see if the exit(173) bug is fixed.
 

lloyddean

macrumors 65816
May 10, 2009
1,047
19
Des Moines, WA
1642372890430.png
What exit bug?
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
Read the thread. When you launch your app before you return the app number to the OS with
Code:
return NSApplicationMain(argc, (const char **) argv);
you check for a valid App Store receipt. In your receipt validation code if there's no receipt you exit with error status of 173. If you are logged onto the App Store with your sandbox test user account it should add a valid App Store receipt to to your app bundle @"Contents/_MASReceipt/receipt". Then you have a test receipt in your app bundle and you can de-bug your receipt validation code. Then it should re-launch the app and ask for your sandbox test user id and password. If you enter a valid id and password (and your receipt validation code is ok) the app will run. This has now been broken for at least two months, making it impossible to build, test and submit new versions of macOS apps. I don't know what language you use but in C you would fetch a receipt by calling exit(173);

In bug reporter everyone that has reported this problem has their resolution changed to: Potential fix identified - In macOS 12.2. "Potential" doesn't sound very reassuring to developers, who have struggled with so many horrible bugs in macOS, XCode, etc.
 

prime17569

macrumors regular
May 26, 2021
192
490
In bug reporter everyone that has reported this problem has their resolution changed to: Potential fix identified - In macOS 12.2. "Potential" doesn't sound very reassuring to developers, who have struggled with so many horrible bugs in macOS, XCode, etc.

To your knowledge, has the issue been fixed in the 12.2 beta? I would check myself, but I can't install the beta right now due to a lack of storage space.
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
No, I haven't tested it on 12.2. I've decided not to install test versions of Apple's software to see if they are fixing bugs. Why should I spend a lot of time to be a test user for Apple's horrible bugs? Someone is getting payed to do this at Apple and really goofing up at our expense.
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
Mac developers are reporting on the Apple developer forums that it's NOT fixed in the 12.2 beta.
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
This appears to be fixed in 12.2. Last night I installed 12.2. When I build and run my application the first time XCode logs an error - no receipt but the second time it has installed a receipt. It doesn't ask for my test user ID so apparently they have changed it so it just adds a receipt if you are logged on to the App Store with the correct user ID and password.
 

prime17569

macrumors regular
May 26, 2021
192
490
This appears to be fixed in 12.2. Last night I installed 12.2. When I build and run my application the first time XCode logs an error - no receipt but the second time it has installed a receipt. It doesn't ask for my test user ID so apparently they have changed it so it just adds a receipt if you are logged on to the App Store with the correct user ID and password.
That's great to hear!
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
6/12/2022 this is broken AGAIN. This has been screwed up on and off for about FIVE YEARS.
 

prime17569

macrumors regular
May 26, 2021
192
490
6/12/2022 this is broken AGAIN. This has been screwed up on and off for about FIVE YEARS.
Which macOS version? 12.4 or the Ventura developer beta?

If this is on the Ventura beta, I suggest duping the original feedback report you sent to Apple and putting the beta's build number in the title. That way it'll show up to them as a new bug. Something like this:

SKTerminateForInvalidReceipt() and exit(173) do not generate new receipts in the Sandbox environment in macOS 13.0 beta (#build#)

Also, you might want to file it under the StoreKit framework (instead of App Store, etc.), since there were a number of StoreKit updates at WWDC (including in the App Store Server API, which is on Apple's side of things) which could have caused this regression.
 

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
424
30
Using Mac OS 12.4 and XCode 13.4.1, this is broken. This is a bug in XCode: XCode should post a dialog asking for your test user ID and password to fetch a receipt and re-launch your application. This has been broken for at least seven months. XCode also doesn't need to delete your receipt when you change a few lines of code but sometimes it does.

This is also a bug in the server at Apple. They had it patched so that it would fetch a receipt and relaunch your application without XCode asking for your credentials but then they broke that as well recently.

Apple is well aware of these problems but isn't fixing them. In order to get their attention I tried to ask for high-level code support twice but they won't respond to requests for support if this is your problem. There are many, many bug reports at Bug Reporter for this but they aren't fixing it. In my opinion this demonstrates real contempt for developers.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.