appStoreReceiptURL not found in AUv3 app extension

I have an Audio Unit app extension with an in-app purchase. When starting the app and running it as standalone, the in-app purchase's receipt can be verified without problems:

NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];

NSData *receipt = [NSData dataWithContentsOfURL:receiptURL                                             options:0                                               error:&readError];

However, when running the audio unit inside a host, receiptURL is file:///private/var/mobile/Containers/Data/PluginKitPlugin/D87B0A4A-2670-41AC-9400-2787A9B9982F/StoreKit/sandboxReceipt

and the receipt is nil, probably because the file does not exist or it cannot be accessed from the plug-in running in the host environment.

The error is: Error Domain=NSCocoaErrorDomain Code=260 "The file “sandboxReceipt” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/private/var/mobile/Containers/Data/PluginKitPlugin/63A457CA-305C-45B5-ABCB-60FEDA70E4FA/StoreKit/sandboxReceipt, NSUnderlyingError=0x28316c450 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

Although I'm running a Sandbox environment, I don't think that's the actual issue. So the question is, how to validate in-app purchase receipts from within an host?

What's more, once I do an in-app purchase in the standalone version (so just running the app from its icon), then the very same file is created and can be accessed from within the plug-in! So this means that StoreKit does not write the receipt when a purchase is done from within the host.

iPadOS 16.1.1

appStoreReceiptURL not found in AUv3 app extension
 
 
Q