Question

Issue with Xcode 14 beta 4 and iOS 16 Simulator

  • 1 August 2022
  • 5 replies
  • 41 views

Badge

I’ve encountered an issue using Xcode 14 beta 4. Updated to RevenueCat 4.9.0 and still seeing the issue. If I use a StoreKit config file with an iOS 16 simulator, when I attempt to make a purchase, the iOS pay dialog never appears and I get RevenueCat.ErrorCode Code=1 "Purchase was cancelled." If I switch to an iOS 15 simulator, it works fine. If I switch to a different scheme that doesn’t use StoreKit, I get the iOS dialog to sign in. If I try this on my own iOS 16 device, it works fine. It seems to only be an issue while using the simulator with iOS 16. Here is what I get when I print out the error.

Error Domain=RevenueCat.ErrorCode Code=1 "Purchase was cancelled." UserInfo={source_file=RevenueCat/SKError+Extensions.swift:33, source_function=asPurchasesError, readable_error_code=PURCHASE_CANCELLED, NSLocalizedDescription=Purchase was cancelled., NSUnderlyingError=0x7f85d1a9e2e0 {Error Domain=SKErrorDomain Code=2 "(null)" UserInfo={NSUnderlyingError=0x7f85d1a9e260 {Error Domain=ASDErrorDomain Code=907 "Unhandled exception" UserInfo={NSUnderlyingError=0x7f85d1a90340 {Error Domain=AMSErrorDomain Code=6 "Payment Sheet Failed" UserInfo=0x7f85d1a06d40 (not displayed)}, NSLocalizedDescription=Unhandled exception, NSLocalizedFailureReason=An unknown error occurred}}}}}

 


5 replies

Badge

Follow up, I forgot about the debug log level setting and turning that on provided some direction. I updated from the legacy API Key, then updating calling configure with setting “usesStoreKit2IfAvailable” to true.

Now, I no longer am getting the purchase cancelled error. Instead, the iOS purchase sheet still doesn’t appear at all. But, it seems it’s automatically returning a successful transaction, but entitlements are empty. Here are the debug logs for launching the app, navigating to the paywall, then tapping purchase.

2022-08-01 12:19:16.622998-0400 FourSix[17479:13155618] [Purchases] - DEBUG: 👤 Identifying App User ID
2022-08-01 12:19:16.653065-0400 FourSix[17479:13155618] [Purchases] - DEBUG: ℹ️ Debug logging enabled
2022-08-01 12:19:16.653406-0400 FourSix[17479:13155618] [Purchases] - INFO: ℹ️ StoreKit 2 support enabled
2022-08-01 12:19:16.653761-0400 FourSix[17479:13155618] [Purchases] - DEBUG: ℹ️ SDK Version - 4.9.0
2022-08-01 12:19:16.654072-0400 FourSix[17479:13155618] [Purchases] - DEBUG: 👤 No initial App User ID
2022-08-01 12:19:18.158162-0400 FourSix[17479:13155618] [Purchases] - DEBUG: ℹ️ CustomerInfo cache is stale, updating from network in foreground.
2022-08-01 12:19:18.162149-0400 FourSix[17479:13155775] [Purchases] - DEBUG: ℹ️ GetCustomerInfoOperation: Started
2022-08-01 12:19:18.162603-0400 FourSix[17479:13155775] [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request GET subscribers/$RCAnonymousID%3A2b6997bc509e4e4d85ad1de4bbfa0e37
2022-08-01 12:19:18.168668-0400 FourSix[17479:13155618] [Purchases] - DEBUG: ℹ️ CustomerInfo cache is stale, updating from network in foreground.
2022-08-01 12:19:18.173056-0400 FourSix[17479:13155775] [Purchases] - DEBUG: ℹ️ API request started: GET /v1/subscribers/$RCAnonymousID:2b6997bc509e4e4d85ad1de4bbfa0e37
2022-08-01 12:19:18.198414-0400 FourSix[17479:13155618] [Purchases] - DEBUG: ℹ️ applicationDidBecomeActive
2022-08-01 12:19:18.198947-0400 FourSix[17479:13155618] [Purchases] - DEBUG: ℹ️ CustomerInfo cache is stale, updating from network in foreground.
2022-08-01 12:19:18.201373-0400 FourSix[17479:13155618] [Purchases] - DEBUG: ℹ️ Offerings cache is stale, updating caches
2022-08-01 12:19:19.107686-0400 FourSix[17479:13155776] [Purchases] - DEBUG: ℹ️ API request completed: GET /v1/subscribers/$RCAnonymousID:2b6997bc509e4e4d85ad1de4bbfa0e37 201
2022-08-01 12:19:19.175477-0400 FourSix[17479:13155776] [Purchases] - DEBUG: ℹ️ Sending latest CustomerInfo to delegate.
2022-08-01 12:19:19.175763-0400 FourSix[17479:13155776] [Purchases] - DEBUG: 😻 CustomerInfo updated from network.
2022-08-01 12:19:19.177741-0400 FourSix[17479:13155776] [Purchases] - DEBUG: 😻 CustomerInfo updated from network.
2022-08-01 12:19:19.179409-0400 FourSix[17479:13155776] [Purchases] - DEBUG: 😻 CustomerInfo updated from network.
2022-08-01 12:19:19.179666-0400 FourSix[17479:13155776] [Purchases] - DEBUG: ℹ️ GetCustomerInfoOperation: Finished
2022-08-01 12:19:19.180084-0400 FourSix[17479:13155776] [Purchases] - DEBUG: ℹ️ Serial request done: GET subscribers/$RCAnonymousID%3A2b6997bc509e4e4d85ad1de4bbfa0e37, 0 requests left in the queue
2022-08-01 12:19:19.180130-0400 FourSix[17479:13155778] [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Started
2022-08-01 12:19:19.180470-0400 FourSix[17479:13155778] [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request GET subscribers/$RCAnonymousID%3A2b6997bc509e4e4d85ad1de4bbfa0e37/offerings
2022-08-01 12:19:19.182035-0400 FourSix[17479:13155778] [Purchases] - DEBUG: ℹ️ API request started: GET /v1/subscribers/$RCAnonymousID:2b6997bc509e4e4d85ad1de4bbfa0e37/offerings
2022-08-01 12:19:19.212960-0400 FourSix[17479:13155771] [Purchases] - DEBUG: ℹ️ API request completed: GET /v1/subscribers/$RCAnonymousID:2b6997bc509e4e4d85ad1de4bbfa0e37/offerings 200
2022-08-01 12:19:19.216936-0400 FourSix[17479:13155771] [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Finished
2022-08-01 12:19:19.217353-0400 FourSix[17479:13155771] [Purchases] - DEBUG: ℹ️ Serial request done: GET subscribers/$RCAnonymousID%3A2b6997bc509e4e4d85ad1de4bbfa0e37/offerings, 0 requests left in the queue
2022-08-01 12:19:25.741569-0400 FourSix[17479:13155739] [Purchases] - DEBUG: ℹ️ Vending Offerings from cache
2022-08-01 12:19:28.046850-0400 FourSix[17479:13155739] [Purchases] - INFO: 💰 Purchasing Product 'com.jonduenas.FourSixCoffeeTimer.FourSixPro' from package in Offering 'default'
2022-08-01 12:19:28.074930-0400 FourSix[17479:13155775] [Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple.
2022-08-01 12:19:28.117665-0400 FourSix[17479:13155775] [Purchases] - DEBUG: ℹ️ Loaded receipt from url file:///Users/jonduenas/Library/Developer/CoreSimulator/Devices/C117174B-312A-4572-B93D-10F6A6888C48/data/Containers/Data/Application/ACFFE8B2-5C64-4726-903D-21FB27DC90DD/StoreKit/receipt
2022-08-01 12:19:28.118389-0400 FourSix[17479:13155739] [Purchases] - DEBUG: ℹ️ Skipping products request because products were already cached. products: ["com.jonduenas.FourSixCoffeeTimer.FourSixPro"]
2022-08-01 12:19:28.119635-0400 FourSix[17479:13155618] [Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: $RCAnonymousID:2b6997bc509e4e4d85ad1de4bbfa0e37
2022-08-01 12:19:28.130069-0400 FourSix[17479:13155775] [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Started
2022-08-01 12:19:28.130340-0400 FourSix[17479:13155775] [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request POST receipts
2022-08-01 12:19:28.133944-0400 FourSix[17479:13155775] [Purchases] - DEBUG: ℹ️ API request started: POST /v1/receipts
2022-08-01 12:19:28.419311-0400 FourSix[17479:13155775] [Purchases] - DEBUG: ℹ️ API request completed: POST /v1/receipts 200
2022-08-01 12:19:28.422726-0400 FourSix[17479:13155775] [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Finished
2022-08-01 12:19:28.423191-0400 FourSix[17479:13155775] [Purchases] - DEBUG: ℹ️ Serial request done: POST receipts, 0 requests left in the queue
2022-08-01 12:19:28.425492-0400 FourSix[17479:13155618] [Purchases] - DEBUG: ℹ️ Sending updated CustomerInfo to delegate.
2022-08-01 12:19:28.425899-0400 FourSix[17479:13156021] [Purchases] - INFO: 😻💰 Purchased product - 'com.jonduenas.FourSixCoffeeTimer.FourSixPro'

 

Userlevel 4
Badge +7

Hi! 👋🏻 Thanks for reporting!

These are definitely unexpected. 

Just to clarify, this doesn’t happen on Xcode 13, right? 

Have you tried a physical device _without_ using storekit configuration files? 

The fact that there’s a difference in behavior between StoreKit 1 and StoreKit 2 suggests a bug in StoreKit. I haven’t been able to reproduce this so far, though, but the logs do represent what you described - the purchase started and was confirmed right away on Sk2. 

I wonder if in StoreKit 2, the default value for disableDialogs is getting set to true by default. 

Could you try doing: 

let testSession = try SKTestSession(configurationFileNamed “myConfig.storekit”)

testSession.disableDialogs = false

 

And seeing if that makes a difference? 

Badge

Just to clarify, this doesn’t happen on Xcode 13, right? 

Correct. And even in Xcode 14, it’s only on iOS 16 simulators.

Have you tried a physical device _without_ using storekit configuration files?

Interesting thing happens when I try it on my iOS 16 physical device from a Test Flight build. Usually, on a new install (delete the app and reinstall), if I tap to purchase I get the pay sheet. Currently, if I tap purchase, the pay sheet doesn’t show, but my app acts as if the payment was completed successfully (entitlements all activate). My code calls func purchase(package: Package) async throws -> PurchaseResultData and then checks if userCancelled, then the customerInfo for the expected entitlement. In the simulator currently, userCancelled is returning true. On Test Flight it must be not showing up as cancelled or getting an error, and the entitlement is being found even without the payment sheet ever showing. Not sure if it’s treating it like a restore or not because the device has made the purchase in the past? Either way, this is an entirely different behavior than I’ve noticed in the past.

Speaking of in the past, all of this used to work just fine, even on iOS 16. Not sure if it’s Xcode 14 beta 4 and/or iOS 16 beta 4 that started this or not, but I’m 100% positive some previous beta builds were working fine.

I wonder if in StoreKit 2, the default value for disableDialogs is getting set to true by default. 

Could you try doing: 

let testSession = try SKTestSession(configurationFileNamed “myConfig.storekit”)

testSession.disableDialogs = false

 

And seeing if that makes a difference? 

I’m not familiar with using SKTestSession. Trying to get it to work on my project and failing. Is this for running with XCTest? I’m a bit confused how I would get that code to work when testing manually with the simulator, not running automated tests.

Another detail to add, usually for the StoreKit config file, I can do things from the Edit menu like set it to fail transactions with specific errors, enable ask to buy, etc. Normally I see these reflected when making purchases in the simulator. These are getting bypassed entirely as well. It does work when I change the default storefront though (currency changes), but simulating App Store transactions doesn’t seem to reflect any changes to the config file.

Badge

Tried one more thing this morning. I switched back to Xcode 14 beta 3 and tried it and the payment sheet showed up just fine. I’ve tried searching anyone else posting about this issue online and not seeing it, but clearly the same code works fine on beta 3. I think I’ll just submit a radar with Apple.

Userlevel 4
Badge +7

@jonduenas thank you for the detailed responses! 

That makes sense. About the XCTest thing, that’s my bad - I’m so used to using SKTestSession for testing that I forgot that it requires importing StoreKitTest and XCTest. 

Please keep us posted if you get a reply to the radar! We’ll continue to test this on every beta

Reply