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
432
32
An Objective C app did something strange. It terminated with an alert exit(173) API no longer supported use Transaction.all or AppTransaction.shared instead. In the receipt validation code exit(173) is called if there is no App Store receipt. The program would terminate, download a valid receipt from the store and relaunch the app. This made it possible to debug the receipt validation code. This shouldn't have happened because the app has a valid receipt.

Reading the developer documentation for Transaction and AppTransaction I only see APIs these objects use for in-app purchases but not for receipt validation.

How can I use the Store Kit for receipt validation and is the Store Kit swift only?

Reading the documentation here:


I'm doing what it says but I don't see how to fetch a valid test receipt from the store for debugging.

Update: I’ll probably use the method here:


to use the procedure in Swift here:


I’m just wondering if calling refresh() will get a receipt in the development environment with Xcode.

I really want to make sure that everything is ok before I distribute the app and exit(173) did this.
 
Last edited:
Those instructions for importing Swift into Objective C are as clear as mud. For one thing I don't know what a product module is and searching for it with the developer documentation and the XCode Help yields no results.
 
I've made some progress on this. I found the product module in the build settings and added my product name. I added a header file to my project with the name product-Swift.h and #imported it into my .m file. Now XCode will build my project with the objective C types for swift types. For example it will build with NSPersistentHistoryTransaction *myTransaction. The problem is that the product-Swift.h header is empty and to use it I would have to be able to read the objective C declarations of the types. How can I read these? The developer documentation is in Swift only.
 
Theoretically I could validate the receipt with a few lines of code. I have given up on trying to import the Swift types into Objective-C. I don't think that you can really do it. Instead I took A Swift playground with the code to Validate the receipt using the older method where you get the data from the Bundle.main.appStoreReceiptURL?.path. XCode won't build the code that's in the developer documentation:
Code:
do {
        let verificationResult = try await AppTransaction.shared

        switch verificationResult {
        case .verified(let appTransaction):
            //do something here
        case .unverified(let appTransaction, let verificationError):
            // Do something here
        }
    }

The first line won't build because "Cannot find 'AppTransaction' in scope"

XCode has a big problem with AppTransaction.
 
There's a thread abut this on the Apple developers forum:


I used it to implement receipt verification with the Store Kit (Swift only) in an Objective-C project. The store Kit is available in macOS 10.13 and the older and the methods used to verify receipts using Common Crypto/ Security Frame work are deprecated. According to Apple they made it easy to begin to migrate development to Swift by creating a method to mix Swift and Objective-C easily. This is baloney. The documentation is terrible and there are a lot of catches. Reading this thread will explain a lot of this and direct you to helpful documentation.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.