Changing StoreKit Configuration for In-App Purchases: Debug to Release - ios

I am currently utilizing StoreKit for testing in-app purchases and have included a store kit configuration file that is synced from the App Store. Do I need to change the 'Edit Scheme' and set the StoreKit configuration to 'None' before releasing on the App Store?

You do not need to edit the scheme. If you will note, the setting for "StoreKit Configuration" is on the Options tab for the "Run - Debug" setup. If you look at the "Archive - Release" setup there is no Options tab and there is no setting for "StoreKit Configuration".
In other words, the "StoreKit Configuration" setting does not apply when you archive your app so you do not need to change it. It only needs to be change if you wish to change the behavior while running the debug version of your app.

Related

In the Sandbox test of StoreKit2 billing process, can I cancel a purchase of a Non-Consumable item?

I have recently started developing an IOS app in xcode.
I am implementing the billing process with Storekit2, but after purchasing a "non-consumable" item with a sandbox account, I am unable to cancel the purchase.
The official site says that this is the case, but in order to test it, we would like to test the purchase process repeatedly in a sandbox environment that is similar to the production environment.
We have the following two tests for Storekit2, and we are aware that Storekit Configuration can be tested over and over again.
Storekit Configuration
Sandbox
1, Is there any way to cancel to buy in order to test billing over and over again?
2, In actual practice, do we try various cases with Storekit Configuration and if it is OK, we release it already?
3, Also, before the advent of Storekit Configuration, how did you test a "non-consumable" product multiple times?
If anyone has more information, please let me know!
TL,DR: learn more about Testing all stages with IAP here
Yes, you could do "Clear the purchase history" as it's listed
Screenshot
Xcode enviroment
When you're running app from your Xcode on simulator or device, just click button Manage Storekit Transactions. Then you could test with any stage, refund or clear purchase history
Manage Storekit Transactions
Sandbox
Just login AppStoreConnect, Users and Access -> Select tab Sandbox Testers -> there is Edit button, just follow it to clear transaction history
Sandbox Testers

How to test IAP with Sandbox User in the Sandbox environment?

I can test in the Xcode environment.
I can test with TestFlight which uses a REAL Apple Id to make purchases in the Sandbox Environment.
But how do I test with a Sandbox User in the Sandbox Environment? Because I need to be able to clear out my Sandbox user purchase history so that I can test first purchases again.
I've been reading through the documents and I feel like each particular doc jumps over the piece of info that I need. It explains how to create a Sandbox Test User and I've done that. I did plenty of IAP work many years ago, but things have changed enough that it's not working as I expect. When I read the docs, I feel like I can't find the missing piece.
When I test in a simulator with Xcode, it does my IAP transactions in the Xcode environment. That makes sense.
https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_with_sandbox
This page says:
To run your app using your Sandbox Apple ID, build and run your app
from Xcode.
But when I test on a physical device installing directly from Xcode, it also does my IAP transactions in the Xcode environment. I thought this would put me in the Sandbox environment, but it didn't. The Xcode transactions manager shows the transactions. The initial purchase view controller didn't reference the Sandbox at all and the "You're All Set" alert shows Environment: Xcode instead of Environment: Sandbox.
When I put a test build into TestFlight and test using that version, my IAP transactions are happening in production using my real Apple Id (but I'm not actually charged for any transactions).
I assumed that testing in TestFlight would give me the Sandbox environment, but it happens in the Production environment. (The purchase view controller doesn't show Sandbox and the "You're All Set" alert doesn't show Sandbox.)
So, how do I test in the Sandbox? Every way I try to test either puts me in the Xcode environment or the Production Environment.
What am I missing?
I've logged out of my real Apple id on my phone and then logged in with the Sandbox User credentials I created in AppStore Connect. But when I tried to test the app, by installing from Xcode it still says I'm in the Xcode test environment. When I create transactions, those transactions show up in the Xcode Transaction Manager.
How do I test in the Sandbox environment?
The difference between IAP being in "Xcode" mode versus being in "Sandbox" mode is whether you setup a StoreKit Configuration or not on your target's scheme.
In Xcode select the Product menu and go to Scheme, then "Edit Scheme...". Select Run on the left side and then go to the Options tab.
For the "StoreKit Configuration" setting you will get Xcode mode if you select a specific configuration. You will get Sandbox mode if you set this option to None even when running the app from Xcode.
None of this applies when running from TestFlight. In TestFlight you are in full production mode.
To verify this I logged into a sandbox account in the Settings app under App Store -> SANDBOX ACCOUNT. I then ran my app via Xcode and went through some IAP in my app. When the StoreKit Configuration was set to None the IAP screens showed "Sandbox". When the StoreKit Configuration was set to a specific storekit file the IAP screens showed "Xcode".

Why can't I create an "In-App Purchase Content" target in XCode?

I am adding an in-app purchase to my iOS application that unlocks a feature to render images at a higher resolution. To achieve this, I would like to leverage Apple's Content Hosting feature for in-app purchases.
I found a number of guides on the topic (1), and all indicate the need to create a separate project or target in XCode of type "In-App Purchase Content". However, I am not seeing that as an option when creating a new project or target in XCode.
Here is the "In-App Purchase Content" option I would expect to see:
Here are the only options I see in XCode under the Multiplatform & Other tabs, it is not present in any of the other tabs either:
In App Store Connect, the app is configured with the in-app purchase, Content Hosting is turned on, and I can make a test purchase for that non-consumable product (without the content download). I also am working with the latest version of XCode.
When searching the web, I can't find any indication why that option may be missing for me in XCode. Does anyone see a step I might be missing to enable this in XCode?
(1) Some of the guides I am referencing:
Apple: Unlocking Purchased Content
Techotopia: Configuring and Creating App Store Hosted Content for iOS 11 In-App Purchases
Kitefaster: How to use Content Hosting for In-App Purchase Content
I believe this may have been removed in Xcode 13.3, per the following release note:
Building and uploading nonconsumable in-app purchase content for Apple to host is no longer supported. Existing content that’s hosted by Apple isn’t affected. To enable smaller app bundles, faster downloads, and richer app content, use on-demand resources to host your content on the App Store separately from the app bundle. For details, see On-Demand Resources Essentials. (84121695)
https://developer.apple.com/documentation/Xcode-Release-Notes/xcode-13_3-release-notes

Can I add testers to an app in App Store Connect when my app is in "Prepare for Submission" status?

My app is in "Prepare for Submission" and I'd like to add testers (either internal or external, doesn't matter to me) but I'm not sure how to get that done because a lot of options disappear once the app is in a "Prepare for Submission" state. Are there any known workarounds/fixes for this?
Thanks in advance for any help!
Yes
Now that your app is in that state, head over to the TestFlight tab (at this time, located at near the top of the screen) and set up your testers, groups, etc, and provide export compliance.
Figured out what was wrong - previously, the app was built and uploaded to App Store Connect, then was added to a new version of the iOS app where it said "Prepare for Submission."
The fix was to remove the build from the new version of the app (in my case, 1.2), re-upload it, but before adding it to the new version you can find it in TestFlight > Builds, then it opens up all of the options and you can easily add testers. To add external testers you'll need to submit the beta to review to apple.

iOS: How to upload Apple Hosted content to In-app purchase in itunesconnect

I have Non-Consumable Purchase and want to host it with Apple.
It like a book, that contains from images and manages with JSON. How can I upload it?
What is not clear from Nirav's answer is that to get to the point where you have a valid package, you need to do two additional things after creating the In-App Purchase Content Project in Xcode (i.e. After Xcode -> New Project -> Other -> In-App Purchase)
Once you have added your content files, you must Firstly Archive the Project, then locate the In-App Purchase in the Organizer:
then,
EXPORT the project using the "Export as an Installer Package" option
This exports the archive as a PKG file into a folder on your Desktop. Inside the folder is a .pkg file - this is what you need to add as the "Hosted Package Content"
Apple's documentation on this is scant and not very clear that there is multiple steps in creating the PKG file
With newest XCode (6.x) Application Loader you can manage all your in app purchases from within application loader apart from itunesconnect portal.
Open XCode.
Go to XCode Menu->Open Developer Tools->Application Loader.
Enter credentials for itunesconnect.
(See below image) Select New In-app purchase
On the next screen choose your app (it should have been created from itunesconnect portal.
(See below image) It will show various tabs. It will also show if any in-app purchases have been previously added.
Select Hosted Content tab. Then select the in-app purchase you want to upload your content.
Check the box 'Host Content with Apple'.
You can see the file chooser interface.
Follow the rest of the Application Loader workflow and you are done.

Resources