0

I have an iOS/iPadOS app already published and selling in the App Store. Now with the "automatic" port of Xcode 11.1 to MacOS 10.15 Catalina or higher, I just marked the "Mac" checkbox and tried to run the app on my Mac, but I got this compile error:

'transactionReceipt' is unavailable: not available on macCatalyst

How to solve? I'm using StoreKit framework, have to use another one? Is there a way to adapt StoreKit to make it work with macCatalyst?

Heitor
  • 683
  • 2
  • 12
  • 26
  • What does "solve" mean? The meaning of the error message is pretty clear. – matt Oct 09 '19 at 22:12
  • I'm using StoreKit framework, have to use another one? Is there a way to adapt StoreKit to make it work with macCatalyst? – Heitor Oct 09 '19 at 22:24
  • What `transactionReceipt` property are you referring to? The one on `SKPaymentTransaction` which was deprecated back in iOS 7? – rmaddy Oct 09 '19 at 22:27
  • Well, in this Apple page it looks like it's not deprecated, it says Class SKPaymentTransaction is for iOS 3.0+ macOS 10.7+ Mac Catalyst 13.0+ and tvOS 9.0+: [link](https://developer.apple.com/documentation/storekit/skpaymenttransaction) – Heitor Oct 09 '19 at 22:35
  • @Heitor The class, yes. But that's not what you said. You said `transactionReceipt`. https://developer.apple.com/documentation/storekit/skpaymenttransaction/1617722-transactionreceipt – matt Oct 09 '19 at 23:27

1 Answers1

0

It`s all about replacing:

transaction.transactionReceipt

with:

[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];

Found it on this SOF answer. In my case there was no need to convert NSData to NSString.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Heitor
  • 683
  • 2
  • 12
  • 26