Skip to content

Commit 5162aa7

Browse files
committed
[in_app_purchase_storekit] Warm up StoreKit Testing before native iOS tests
On iOS 27 simulators, the first process to use SKTestSession on a never-used simulator gets its StoreKit connection classified as sandbox before the test configuration has been pushed to the device, so every StoreKit 2 purchase hangs on an Apple Account sign-in and times out (Apple FB24651858 / 186670057, listed as a known issue in the iOS 27.3 release notes). Any later process on the same device works, which is why the tests pass on reused simulators and fail on CI's fresh ones. Add a Test pre-action to the Runner scheme that runs one non-purchase test in a throwaway process before the real test host launches. This is Apple's documented workaround (seed the configuration on the device first), automated for xcodebuild, which ignores the scheme's StoreKit configuration setting that makes it work from the IDE. Fixes flutter/flutter#195494
1 parent 832d5f2 commit 5162aa7

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/xcshareddata/xcschemes

‎packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@
4747
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
4848
shouldUseLaunchSchemeArgsEnv = "YES"
4949
codeCoverageEnabled = "YES">
50+
<PreActions>
51+
<ExecutionAction
52+
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
53+
<ActionContent
54+
title = "Warm up StoreKit Testing on cold simulators"
55+
scriptText = "# Seed the StoreKit test configuration on fresh simulators (Apple FB24651858).&#10;if [ -z &quot;$STOREKIT_WARMUP&quot; ] &amp;&amp; [ &quot;$TARGET_DEVICE_PLATFORM_NAME&quot; = &quot;iphonesimulator&quot; ]; then&#10; env -i HOME=&quot;$HOME&quot; PATH=&quot;$PATH&quot; DEVELOPER_DIR=&quot;$DEVELOPER_DIR&quot; STOREKIT_WARMUP=1 \&#10; xcodebuild test-without-building \&#10; -workspace &quot;$PROJECT_DIR/Runner.xcworkspace&quot; -scheme Runner \&#10; -configuration &quot;$CONFIGURATION&quot; -destination &quot;id=$TARGET_DEVICE_IDENTIFIER&quot; \&#10; -derivedDataPath &quot;$BUILD_DIR/../..&quot; \&#10; -only-testing:RunnerTests/InAppPurchase2PluginTests/testCanMakePayments \&#10; &gt; &quot;$TMPDIR/storekit_warmup.log&quot; 2&gt;&amp;1 || true&#10;fi&#10;">
56+
<EnvironmentBuildable>
57+
<BuildableReference
58+
BuildableIdentifier = "primary"
59+
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
60+
BuildableName = "Runner.app"
61+
BlueprintName = "Runner"
62+
ReferencedContainer = "container:Runner.xcodeproj">
63+
</BuildableReference>
64+
</EnvironmentBuildable>
65+
</ActionContent>
66+
</ExecutionAction>
67+
</PreActions>
5068
<MacroExpansion>
5169
<BuildableReference
5270
BuildableIdentifier = "primary"

0 commit comments

Comments
 (0)