appStoreReceiptURL
The file URL for the bundle’s App Store receipt.
Declaration
var appStoreReceiptURL: URL? { get }Discussion
Use this app bundle property to locate the app receipt if it’s present; this property is nil if the receipt isn’t present. In the rare case a receipt is invalid or missing in an app that a user downloads from the App Store, use SKReceiptRefreshRequest to request a new receipt. For information about validating receipts, see Choosing a receipt validation technique.
You can’t use the general best practice of weak linking using the responds(to:) method here; the method’s implementation uses the doesNotRecognizeSelector(_:) method.
Get the receipt in testing environments
Receipts aren’t initially present in iOS and iPadOS apps in the sandbox environment and in Xcode. Apps get a receipt after the tester completes the first in-app purchase. When your app checks appStoreReceiptURL and finds that it’s nil, assume the tester is a new customer and has no access to premium content. For Mac apps running in TestFlight, the receipt is always present.