Skip to content

Commit 51e9568

Browse files
karclaude
andauthored
Migrate Adapty SDK to 4.0 (Paywall → Flow) + iOS Swift-package pipeline (#1214)
* ios: consume the Flutter module as a Swift package (build swift-package) flutter build ios-framework forces CocoaPods and skips podspec-less plugins, so it cannot build SwiftPM-only plugins like adapty_flutter 4.x. Switch the module build to `flutter build swift-package` and the host project from 12 hardcoded xcframework refs to one local FlutterNativeIntegration package dependency (per-target product + Flutter Assemble build phase; per-scheme prebuild pre-action flips the Debug/Release symlink). The mocked simulator flow builds the same package with its dart-defines. sign-ios-frameworks now signs the prebuilt third-party xcframeworks under the package's Frameworks/ dirs; plugins vended as source packages no longer need ITMS-91065 origin signatures. Drops the unreferenced legacy common/scripts/build.for.ios.sh. Not buildable standalone: adapty_flutter 3.17.1 ships podspec+Package.swift and the module pods pass collides with the plugin's remote AdaptySDK-iOS targets; resolved by the 4.0.3 bump in the next commit (PR squash-merges). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bwp4PT4b6f87avSxEbgqNH * deps: migrate Adapty SDK to 4.0 (Paywall → Flow) across Dart and Android Coupled bump: adapty_flutter 4.0.3 (pub) + io.adapty:adapty-bom 4.0.1 (gradle) — the Flutter plugin pins the native BOM major internally, so neither can move alone (supersedes #1199/#1201). Dart (adapty.dart): Flow renames; setFallbackPaywalls → setFallback; locale moves from getFlow (deprecated no-op) to createFlowView, else flows silently render English; paywallViewDidFailRendering folds into the mandatory flowViewDidReceiveError (kept log-only); flowViewDidDisappear now drops the cached view — 4.0 releases dismissed views, and swipe-down bypasses closePaymentScreen, so a spent view could otherwise be re-presented. AndroidSystemBackAction handling kept (4.0 stopped dismissing on back by default). Kotlin (six flavor): Flow renames; locale moves to getFlowConfiguration; PaymentBinding now extends AdaptyFlowDefaultEventListener so 4.0's new analytics/app-rate/permission flow actions keep SDK default behaviour; onBackPressed returns false to preserve the 3.x back-dismissal via the dialog fragment; prorate-on-upgrade purchase params unchanged. adapty_flutter is vendored (minus example/) under common/vendor with two patches: a stub podspec — Flutter modules still force a CocoaPods pass (flutter/flutter#184590) whose generated registrant pod hard-depends on every plugin, and 4.x ships no podspec — and a Swift typealias for the pubspec pluginClass, which upstream only exposes as an @objc name so the generated Swift registrant fails to compile (report to Adapty). The fallback-version CI script now also enforces pin == vendored version. Fallback files are still format v9 and MUST be replaced with v10 exports before release: SDK 4.x rejects v9 at cold start (error 2006) and the failure is swallowed into paymentTempUnavailable. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bwp4PT4b6f87avSxEbgqNH * build(ios): sign script tolerates zero prebuilt plugin xcframeworks Since Adapty 4 every plugin is a Swift source package, so the package's Frameworks dir holds only the excluded Flutter/App bundles and the zero-signed case is legitimate, not a broken build. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bwp4PT4b6f87avSxEbgqNH * fix(payment): address code-review findings on the Adapty 4 migration - flowViewDidDisappear now resets the PaymentActor when a dismissal bypassed closePaymentScreen (swipe-down, flow-internal close) — without it _isOpened stayed true and the paywall could never reopen. A dismissing-view marker keeps app-initiated closes reporting their own isError without double-notifying. - closePaymentScreen only invalidates the cached view when it is the one being dismissed, so a fresh preload for another placement survives; cache clearing deduplicated into _dropCachedView(). - Scheme surgery had MOVED each Build entry's BuildableReference into the new pre-action instead of copying it, leaving Build actions empty — restored in all 8 schemes. - sign-ios-frameworks discovers xcframeworks recursively so a prebuilt bundle in a new layout cannot silently skip ITMS-91065 signing. - Fallback-version guard: vendor dir added to the workflow paths filter, stub podspec version pulled into the lockstep check, pubspec pin regex made order/indentation-proof. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bwp4PT4b6f87avSxEbgqNH * test(appium): wait for a stable frame before the paywall golden compare The smoke run on Adapty 4 failed the paywall golden with 12% diff: the screenshot caught the flow mid-presentation (content shifted by the status-bar height, bar transiently hidden during the modal handoff), while the settled frame — visible in the failure screenshot taken moments later — matches the golden exactly. The fixed 4s pause was tuned to the 3.x renderer's timing; the 4.0 flow runtime settles later. Replace it with waitForStableScreen(): consecutive top-masked frames compared until quiescent, so the timing never needs re-tuning. No regold needed — the steady-state render is unchanged. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bwp4PT4b6f87avSxEbgqNH * test(appium): retry the paywall golden compare until the flow settles The stable-frame wait latched onto the wrong state: the Adapty 4 flow holds a stable intermediate layout for several seconds (content shifted by the status-bar height — identical 12.14% diff across runs) before its final reflow, so quiescence cannot distinguish the plateau from the settled screen. compareToGolden gains retries/retryDelayMs and the spec retries the comparison itself; only a frame that never matches fails. Supersedes waitForStableScreen, removed. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bwp4PT4b6f87avSxEbgqNH * fix(payment): pin AdaptySDK-iOS to blokadaorg fork with footer-gate patch The 4.x decorator rewrite dropped the includeBackground opacity gate on static backgrounds, so the paywall's translucent footer scrim (#000000BF, meant to appear only when content scrolls beneath the footer) is painted unconditionally — rgb(57) → rgb(14) on the footer band, breaking the design's scroll-under translucency. No legacy or compat renderer exists in 4.0 (format<4.8 paywalls are decoded into a synthetic single-screen flow), so the vendored plugin's Package.swift now pins blokadaorg/AdaptySDK-iOS @ caf82a13 — tag 4.0.2 plus one commit restoring the gate (branch blokada/4.0.2-footer-include-background-gate). Return to the upstream exact-4.x pin when Adapty ships the fix. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bwp4PT4b6f87avSxEbgqNH * chore(payment): refresh Adapty fallback paywalls to format v10 SDK 4 rejects the bundled v9 fallbacks at cold start (error 2006, swallowed into paymentTempUnavailable), so offline cold-start paywalls were broken until this lands. Fresh dashboard exports (all 7 placements) installed into all three bundled copies via make adapty-paywalls; ADAPTY_VER now matches the 4_0_0 export filenames and the CI guard requires v10. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bwp4PT4b6f87avSxEbgqNH * fix(payment): pass bare language codes to the Adapty 4 localization lookup Device sign-off caught the paywall rendering English on a Spanish device. Adapty 4 resolves the view locale client-side with an EXACT dictionary lookup against the dashboard localization ids (bare language codes: en, es, de, ...) — AdaptyUISchema+localization.swift has no language-prefix fallback, unlike the lenient 3.x fetch-time matching. Our region-tagged values (Dart I18n.localeStr = es_es, Android toLanguageTag = es-ES) therefore missed and silently fell back to the default (English). Pass I18n.languageOnly on the Dart path and the language subtag on the native Android path. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bwp4PT4b6f87avSxEbgqNH --------- Co-authored-by: Claude Fable 5 <[email protected]>
1 parent 9ea9932 commit 51e9568

175 files changed

Lines changed: 11074 additions & 601 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/check-adapty-fallback.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- "android/app/src/main/assets/fallbacks/**"
88
- "common/pubspec.yaml"
99
- "common/pubspec.lock"
10+
- "common/vendor/adapty_flutter/**"
1011
- "scripts/check-adapty-fallback-version.mjs"
1112
- ".github/workflows/check-adapty-fallback.yml"
1213
push:

‎AGENTS.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,12 @@ This commonly fixes generated-signature mismatches after API changes.
178178

179179
### iOS
180180
- Fastlane for automation and deployment. Native dependencies use Swift Package
181-
Manager (Firebase, Factory, CodeScanner); the Flutter module is embedded as
182-
prebuilt xcframeworks from `make -C common build-ios`. No CocoaPods.
181+
Manager (Firebase, Factory, CodeScanner); the Flutter module is consumed as a
182+
local Swift package (`common/build/ios-spm/FlutterNativeIntegration`) from
183+
`make -C common build-ios`. App schemes flip Debug/Release via a
184+
`flutter_integration.sh prebuild` pre-action. The host has no CocoaPods; the
185+
module build still runs a vestigial pods pass (flutter/flutter#184590) served
186+
by the stub podspec in `common/vendor/adapty_flutter`.
183187
- **iOS 14+ Flutter Debug Limitation**: Flutter debug mode apps cannot launch
184188
directly on device without Xcode/Flutter tooling. The `make -C ios run`
185189
target defaults to Release mode to bypass this.

‎BUILDING.md‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,19 @@ fastlane match development
6161
```
6262

6363
iOS native dependencies use Swift Package Manager, resolved by Xcode (Firebase,
64-
Factory, CodeScanner). The Flutter module is consumed as prebuilt xcframeworks:
65-
`make -C common build-ios` produces them under `common/build/ios-framework/`,
66-
which the host project links and embeds. If iOS deps look stale, rebuild with:
64+
Factory, CodeScanner). The Flutter module is consumed as a local Swift package:
65+
`make -C common build-ios` produces `common/build/ios-spm/FlutterNativeIntegration`,
66+
which the host project depends on. Each app scheme runs
67+
`flutter_integration.sh prebuild` as a pre-action to select Debug/Release
68+
artifacts. If iOS deps look stale, rebuild with:
6769
```
6870
$ make -C common build-ios
6971
```
7072

7173
To debug the embedded Flutter engine (`flutter attach`, breakpoints) set the
72-
LLDB init file once, per https://docs.flutter.dev/to/ios-add-to-app-embed-setup
73-
("Use frameworks > Set LLDB Init File").
74+
scheme's LLDB Init File to
75+
`$(FLUTTER_SWIFT_PACKAGE_OUTPUT)/Scripts/flutter_lldbinit`, per
76+
https://docs.flutter.dev/add-to-app/ios/project-setup.
7477

7578
Now see fastlane/README.md for more details on how to build the apps.
7679

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ IOS_PROJECT_FILE := ios/IOS.xcodeproj/project.pbxproj
99
TRANSLATE_SCRIPT := ./scripts/sync-translations.sh
1010

1111
ADAPTY_DIR := ~/Downloads
12-
ADAPTY_VER := 3_8.0
12+
ADAPTY_VER := 4_0_0
1313

1414
# Default target
1515
.DEFAULT_GOAL := build

‎android/app/build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ dependencies {
213213
// consumer must supply them. We don't author Compose — the BOM only pins
214214
// the versions for Adapty's prebuilt paywall UI.
215215
sixImplementation platform('androidx.compose:compose-bom:2026.06.01')
216-
sixImplementation platform('io.adapty:adapty-bom:3.17.2')
216+
sixImplementation platform('io.adapty:adapty-bom:4.0.1')
217217
sixImplementation 'io.adapty:android-sdk'
218218
sixImplementation 'io.adapty:android-ui'
219219

‎android/app/src/main/assets/fallbacks/android.json‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎android/app/src/six/kotlin/binding/PaymentBinding.kt‎

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ import com.adapty.models.AdaptyProfileParameters
2828
import com.adapty.models.AdaptyPurchaseParameters
2929
import com.adapty.models.AdaptyPurchaseResult
3030
import com.adapty.models.AdaptySubscriptionUpdateParameters
31-
import com.adapty.ui.AdaptyPaywallView
31+
import com.adapty.ui.AdaptyFlowView
3232
import com.adapty.ui.AdaptyUI
33-
import com.adapty.ui.listeners.AdaptyUiEventListener
33+
import com.adapty.ui.listeners.AdaptyFlowDefaultEventListener
34+
import com.adapty.ui.listeners.AdaptyFlowEventListener
3435
import com.adapty.utils.AdaptyLogLevel
3536
import com.adapty.utils.AdaptyResult
3637
import com.adapty.utils.FileLocation
@@ -48,7 +49,11 @@ import ui.MainActivity
4849
import ui.shouldUseCenteredAdaptyPaywall
4950
import utils.Intents
5051

51-
object PaymentBinding : PaymentOps, AdaptyUiEventListener {
52+
// Extends the SDK's default listener (not the raw interface) so the callbacks
53+
// we don't care about — 4.0's analytics, app-rate and permission-request flow
54+
// actions — keep Adapty's default behaviour, e.g. the permission callback is
55+
// invoked properly instead of hanging the flow.
56+
object PaymentBinding : PaymentOps, AdaptyFlowDefaultEventListener() {
5257

5358
private val flutter by lazy { FlutterService }
5459
private val context by lazy { ContextService }
@@ -60,7 +65,7 @@ object PaymentBinding : PaymentOps, AdaptyUiEventListener {
6065
private var _retry = true
6166

6267
private var _currentSubscription: CurrentSubscription? = null
63-
private var _currentView: AdaptyPaywallView? = null
68+
private var _currentView: AdaptyFlowView? = null
6469
private var _currentViewForPlacementId: String? = null
6570

6671
private val _scope = CoroutineScope(Dispatchers.Main)
@@ -238,18 +243,25 @@ object PaymentBinding : PaymentOps, AdaptyUiEventListener {
238243
?: callback(Result.failure(Exception("No activity context")))
239244
}
240245

241-
private suspend fun fetchPaywall(placementId: String): AdaptyPaywallView {
246+
private suspend fun fetchPaywall(placementId: String): AdaptyFlowView {
242247
return suspendCoroutine { continuation ->
243-
Adapty.getPaywall(
248+
Adapty.getFlow(
244249
placementId,
245-
locale = translate.getLocale(),
246250
loadTimeout = 10.seconds
247251
) { result ->
248252
when (result) {
249253
is AdaptyResult.Success -> {
250-
val paywall = result.value
251-
// the requested paywall
252-
AdaptyUI.getViewConfiguration(paywall, loadTimeout = 10.seconds) { result ->
254+
val flow = result.value
255+
// Since 4.0 the flow is localized when its configuration is
256+
// built, so the locale moved here from the fetch call. Pass
257+
// the dashboard localization id (bare language code, e.g.
258+
// "es"): 4.0 matches it exactly, so a region tag like
259+
// "es-ES" silently falls back to English.
260+
AdaptyUI.getFlowConfiguration(
261+
flow,
262+
locale = translate.getLocale().substringBefore("-"),
263+
loadTimeout = 10.seconds
264+
) { result ->
253265
when (result) {
254266
is AdaptyResult.Success -> {
255267
if (!context.hasActivityContext()) {
@@ -260,17 +272,17 @@ object PaymentBinding : PaymentOps, AdaptyUiEventListener {
260272
)
261273
)
262274
)
263-
return@getViewConfiguration
275+
return@getFlowConfiguration
264276
}
265277

266278
try {
267279
val activity = context.requireActivity() as MainActivity
268-
val viewConfiguration = result.value
280+
val flowConfiguration = result.value
269281
// use loaded configuration
270282
val view =
271-
AdaptyUI.getPaywallView(
283+
AdaptyUI.getFlowView(
272284
activity,
273-
viewConfiguration,
285+
flowConfiguration,
274286
null,
275287
this,
276288
)
@@ -336,7 +348,7 @@ object PaymentBinding : PaymentOps, AdaptyUiEventListener {
336348
callback(Result.success(Unit))
337349
}
338350

339-
// AdaptyUiEventListener implemented from here downward
351+
// AdaptyFlowEventListener implemented from here downward
340352

341353
override fun onPurchaseFinished(
342354
purchaseResult: AdaptyPurchaseResult,
@@ -384,10 +396,10 @@ object PaymentBinding : PaymentOps, AdaptyUiEventListener {
384396
return retry
385397
}
386398

387-
override fun onPaywallClosed() {
399+
override fun onFlowClosed() {
388400
}
389401

390-
override fun onPaywallShown(context: Context) {
402+
override fun onFlowShown(context: Context) {
391403
}
392404

393405
override fun onPurchaseFailure(
@@ -400,10 +412,20 @@ object PaymentBinding : PaymentOps, AdaptyUiEventListener {
400412
handleFailure(restore = false, temporary = false)
401413
}
402414

403-
override fun onRenderingError(error: AdaptyError, context: Context) {
415+
override fun onError(error: AdaptyError, context: Context) {
416+
// 4.0 folds the old onRenderingError into this callback. Keep the 3.x
417+
// behaviour: log only; purchase/restore/product failures arrive via
418+
// their own callbacks.
404419
logError("Failed rendering adapty", error)
405420
}
406421

422+
override fun onBackPressed(context: Context): Boolean {
423+
// 4.0 consumes the system back press by default so it no longer closes
424+
// the flow. Return false to restore the 3.x behaviour: the press
425+
// propagates to the dialog fragment, which dismisses the paywall.
426+
return false
427+
}
428+
407429
override fun onRestoreFailure(error: AdaptyError, context: Context) {
408430
closePaymentScreen(true)
409431
logError("Failed restore", error)
@@ -421,8 +443,8 @@ object PaymentBinding : PaymentOps, AdaptyUiEventListener {
421443
override fun onAwaitingPurchaseParams(
422444
product: AdaptyPaywallProduct,
423445
context: Context,
424-
onPurchaseParamsReceived: AdaptyUiEventListener.PurchaseParamsCallback
425-
): AdaptyUiEventListener.PurchaseParamsCallback.IveBeenInvoked {
446+
onPurchaseParamsReceived: AdaptyFlowEventListener.PurchaseParamsCallback
447+
): AdaptyFlowEventListener.PurchaseParamsCallback.IveBeenInvoked {
426448
// TODO: no support for downgrading yet
427449
val sub = _currentSubscription
428450
if (sub != null) {
@@ -437,7 +459,7 @@ object PaymentBinding : PaymentOps, AdaptyUiEventListener {
437459
} else {
438460
onPurchaseParamsReceived(AdaptyPurchaseParameters.Empty)
439461
}
440-
return AdaptyUiEventListener.PurchaseParamsCallback.IveBeenInvoked
462+
return AdaptyFlowEventListener.PurchaseParamsCallback.IveBeenInvoked
441463
}
442464

443465
private fun closePaymentScreen(isError: Boolean) {

‎android/app/src/six/kotlin/ui/AdaptyPaymentFragment.kt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ import android.view.ViewGroup
2020
import android.widget.FrameLayout
2121
import android.widget.ProgressBar
2222
import binding.PaymentBinding
23-
import com.adapty.ui.AdaptyPaywallView
23+
import com.adapty.ui.AdaptyFlowView
2424

2525
class AdaptyPaymentFragment : BottomSheetFragment(skipSwipeable = true) {
2626

2727
private val payment by lazy { PaymentBinding }
2828

29-
var adaptyView: AdaptyPaywallView? = null
29+
var adaptyView: AdaptyFlowView? = null
3030
private var didAttachAdaptyView = false
3131

3232
companion object {
3333
private const val PAYWALL_MOUNT_DELAY_MS = 320L
3434
private const val PAYWALL_FADE_DURATION_MS = 450L
3535

36-
fun newInstance(view: AdaptyPaywallView): AdaptyPaymentFragment {
36+
fun newInstance(view: AdaptyFlowView): AdaptyPaymentFragment {
3737
val fragment = AdaptyPaymentFragment()
3838
fragment.adaptyView = view
3939
return fragment

‎android/app/src/six/kotlin/ui/AdaptyPaymentTabletDialogFragment.kt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import android.widget.FrameLayout
2323
import android.widget.ProgressBar
2424
import androidx.fragment.app.DialogFragment
2525
import binding.PaymentBinding
26-
import com.adapty.ui.AdaptyPaywallView
26+
import com.adapty.ui.AdaptyFlowView
2727
import org.blokada.R
2828

2929
/**
@@ -34,14 +34,14 @@ class AdaptyPaymentTabletDialogFragment : DialogFragment() {
3434

3535
private val payment by lazy { PaymentBinding }
3636

37-
var adaptyView: AdaptyPaywallView? = null
37+
var adaptyView: AdaptyFlowView? = null
3838
private var didAttachAdaptyView = false
3939

4040
companion object {
4141
private const val PAYWALL_MOUNT_DELAY_MS = 320L
4242
private const val PAYWALL_FADE_DURATION_MS = 450L
4343

44-
fun newInstance(view: AdaptyPaywallView): AdaptyPaymentTabletDialogFragment {
44+
fun newInstance(view: AdaptyFlowView): AdaptyPaymentTabletDialogFragment {
4545
val fragment = AdaptyPaymentTabletDialogFragment()
4646
fragment.adaptyView = view
4747
return fragment

‎automation/appium/wdio/src/specs/smoke/paywall.spec.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,17 @@ describe("Smoke: paywall on inactive account", () => {
123123
await waitForPaywall();
124124

125125
// Adapty settles the presented view (start.dart sleeps ~3s for non-freemium).
126+
// Since SDK 4 the flow holds a stable intermediate layout for a few seconds
127+
// (content shifted by the status-bar height) before its final reflow, so a
128+
// fixed pause or a wait-for-quiescence both capture the wrong plateau —
129+
// retry the comparison itself until the settled frame matches.
126130
await driver.pause(4000);
127131
await saveScreenshot("paywall.png");
128-
await compareToGolden("paywall.png", { maskTopRatio: 0.06 });
132+
await compareToGolden("paywall.png", {
133+
maskTopRatio: 0.06,
134+
retries: 6,
135+
retryDelayMs: 2000,
136+
});
129137
});
130138

131139
after(async () => {

0 commit comments

Comments
 (0)