App store login with sandbox account, and everything else StoreKit

I can't for my life find where to login with sandbox account. Apples instructions says the following:

"To run your app using your Sandbox Apple ID, build and run your app from Xcode. In iOS and iPadOS, the sandbox account appears in Settings > App Store after the first time you use the device to attempt a purchase in a development-signed app. There’s no need to sign out of the non-Sandbox Apple ID. Sign in using a Sandbox Apple ID."

I have added a .storekit file and when I run the app StoreKit actually uses my standard account successfully and the sandbox account never appears in Settings > App Store.

This is not the only problem I have with this horrifying experience of implementing in-app purchase. It seems not possible to verify receipts using https://sandbox.itunes.apple.com/verifyReceipt with purchases from a local .storekit as I'm getting status code 21002. I can't generate in-app purchase products on app store connect because it requires a release and an actual purchase if I'm not misunderstanding something.

How am I supposed to test the whole flow when I can't verify .storekit purchases, can't generate products on app store connect and can't login with sandbox account?

Here's an answer to the part of your question regarding signing in. There are 3 ways of testing in-app purchases, as I understand it: (1) in Xcode; (2) with the Sandbox; and (3) in TestFlight. [I am assuming you are not trying to set up your own server, but are making purchases from an app on your device.'

I think you may be confusing the first two methods. To test in Xcode, you supply a .StoreKit Configuration file and select the file on the Product / Scheme / Edit Scheme page in Xcode. This lets you test locally on the simulator and does not use a sandbox account.

To test with Sandbox you disable the .StoreKit Configuration file by selecting "none" in the Xcode Product / Scheme / Edit Scheme page. Then you must define products in App Store Connect (this will be the "real" data that you previously emulated in the .storekit file) and also create a Sandbox tester account in App store Connect. Now you must test by running from Xcode on your device (I think you can't use the simulator here). When you try to make a purchase you should get prompted to sign in using the Sandbox tester account. Subsequently you can sign in / sign out to Sandbox account on your device by going to Settings / App Store and scrolling way down to the bottom where you will see a section for Sandbox accounts.

Sorry, but I can't answer your question about "https://sandbox.itunes.apple.com/verifyReceipt".

Good luck! Tom

I am actually going to have server support but I need working receipts for the verification, i.e. not xcode generated but sandbox and later production.

Now, as I am trying to do sandbox testing, Apple doesn't provide any information about how to setup products for IAP in the sandbox environment, so I assume you have to create one in App Store Connect.

When trying to define products in App Store Connect. Apple says the following: "After you create an in-app purchase or auto-renewable subscription product in App Store Connect, you submit it to Apple for review. If you are submitting your first in-app purchase, you must submit it with a new version of your app."

How am I supposed to implement and test IAP if I need to submit the app version before it's done? This just seems weird and my assumption of creating IAP products in App Store Connect seems faulty. I just can't find any useful information in the docs of how to actually do the sandbox testing. You say there are three ways of testing, I guess they are listed here. This link as most others only refer to "Create a sandbox tester account", no information about whether sandbox requires some other way of defining IAP products or what steps are necessary to make sandbox environment work.

In-app purchases don’t need to be submitted for review when testing. But yes to use VerifyReceipt then use sandbox which uses real products configured in App Store Connect. Please refer to https://developer.apple.com/documentation/storekit/in-app_purchase/testing_at_all_stages_of_development_with_xcode_and_sandbox

App store login with sandbox account, and everything else StoreKit
 
 
Q