fix(ios): unwrap paymentId before calling LinkrunnerKit capturePayment [4.1.1] - #40
Merged
Merged
Conversation
The Swift bridge passed an optional String? into LinkrunnerKit's capturePayment, which has taken a non-optional String since LinkrunnerKit 4.0.0. Xcode rejected it outright: Value of optional type 'String?' must be unwrapped to a value of type 'String' — SwiftLinkrunnerPlugin.swift:322:31 This broke every iOS build on 4.0.1, 4.0.2, 4.0.3 and 4.1.0 regardless of the consumer's Dart code, since it is our own source that fails to type-check. Android was never affected — only the Swift bridge has the mismatch. Making paymentId mandatory (LIN-1649) updated the Dart model and the pod pin but not the bridge; ee83237 touched five files and none of them was SwiftLinkrunnerPlugin.swift. Unwrap at the method-channel boundary instead, matching rn-linkrunner's ios/LinkrunnerSDK.swift. LRCapturePayment.paymentId is already required and non-empty validated in Dart, so correct callers see no behaviour change; malformed channel payloads now get an INVALID_ARGUMENT FlutterError. Verified against the playground with a freshly resolved Podfile.lock on LinkrunnerKit 4.1.0: the error reproduces at the exact reported line before this change, and `flutter build ios --no-codesign` succeeds after it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe iOS plugin now requires a non-empty ChangesiOS payment capture release
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every published
4.xrelease of this package fails to compile on iOS.capturePaymentin the Swift bridge passes an optionalString?intoLinkrunnerKit'scapturePayment, which has taken a non-optionalStringsince LinkrunnerKit 4.0.0.This is unconditional — it fails for every consumer regardless of their Dart code, because it is our own source that does not type-check.
Root cause
Making
paymentIdmandatory (LIN-1649) needed three changes in this package. Only two were made:lib/models/lr_capture_payment.dart(final String paymentId, required, non-empty validated)ios/linkrunner.podspecbumped to LinkrunnerKit 4.xios/Classes/SwiftLinkrunnerPlugin.swiftee83237(the 4.0.0 bump) touchedCHANGELOG.md,android/build.gradle,ios/linkrunner.podspec,lib/linkrunner.dartandpubspec.yaml— the bridge was not among them. The native SDK did nothing wrong; 4.0.0 was an intentional major.rn-linkrunneralready handles this correctly atios/LinkrunnerSDK.swift:134, which is why React Native builds fine on the same LinkrunnerKit 4.1.0.Affected versions
Pins read from the published pub.dev tarballs, not from git:
3.10.0 is the last iOS-clean release. Android is unaffected — only the Swift bridge has the mismatch.
4.0.0was never published to pub.dev, so no consumer can be on it.Why it was not caught
Three layers could have caught this; none of them compile Swift against the pinned pod:
flutter pub publishvalidates and archives — it never invokes Xcode orswiftc.flutter analyzeis Dart-only.Podfile.lockwas pinned to LinkrunnerKit 3.7.0 (lastpod install: 2025-12-17), where an optionalpaymentIdis legal. Local iOS builds kept compiling the new bridge against the old API.The fix
Unwrap at the method-channel boundary and make the private helper take a non-optional
String, matching thern-linkrunnerpattern. Dart already guaranteespaymentIdis present and non-empty, so this is a no-op for correct callers; malformed channel payloads now get anINVALID_ARGUMENTFlutterErrorinstead of failing to compile.Verification
Reproduced and fixed against the real playground (
flutter-linkrunner-sandbox,path: ../linkrunner) with a freshly resolvedPodfile.lockon LinkrunnerKit 4.1.0.Before — reproduces the reported error at the exact reported line:
After — same playground, same pod, unchanged
Podfile.lock:flutter analyzereports 0 errors (the 15 remaininginfolints are pre-existingconstant_identifier_nameswarnings inlib/models/lr_consent.dart, unchanged from 4.1.0).Release
Bumps to 4.1.1 across the three places the version lives —
pubspec.yaml,ios/linkrunner.podspec(s.version; theLinkrunnerKitdependency stays pinned at4.1.0) andLinkRunner.packageVersioninlib/linkrunner.dart— plus aCHANGELOG.mdentry. This needs to reach pub.dev promptly: until it does, there is no clean customer-side workaround for iOS on 4.x, and every Flutter customer advised to upgrade to 4.1.0 is blocked.Follow-ups (not in this PR)
flutter build ios --no-codesignagainst the playground. A stalePodfile.lockhid this for four releases; nothing else in the pipeline type-checks the bridge.rn-linkrunneris already correct.LinkrunnerKit 4.0.0is tagged but absent from CocoaPods trunk (trunk goes3.11.0 -> 4.0.1 -> 4.1.0). Harmless today since no published Flutter release pins it, but worth reconciling.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Release