Add Swift Package Manager (SPM) support for Flutter-SDK#356
Add Swift Package Manager (SPM) support for Flutter-SDK#356reshab-code wants to merge 13 commits into
Conversation
Release v3.5.3
Release v3.6.0
Release 3.7.0
Release v3.8.0
Flutter SDK Release v3.8.1
Release v4.0.0
…imports with guards
…tion with a Classes symlink
…e clevertap.h and clevertapPlugin.h in AppDelegate, remove locale parameter from StyledToast causing build failure
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
📝 WalkthroughWalkthroughThis PR introduces Swift Package Manager (SwiftPM) support for the CleverTap Flutter plugin by restructuring iOS header management, adding flexible header imports via preprocessor checks, and creating a complete SwiftPM package manifest. The changes maintain backward compatibility while enabling modern package management, and include a minor locale fix in the example application. ChangesSwift Package Manager Integration for CleverTap Flutter Plugin
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ios/clevertap_plugin.podspec`:
- Around line 14-17: The podspec currently pins the CleverTap iOS SDK exactly
(s.dependency 'CleverTap-iOS-SDK', '7.6.0') while Package.swift uses SwiftPM's
from: "7.6.0" range; update the version policy so both package managers
match—either change the podspec dependency to a matching range (e.g., '>= 7.6.0'
or a compatible '~> 7.6.0') to mirror SwiftPM's semantics, or change
Package.swift to pin exactly "7.6.0"; modify the s.dependency line in
ios/clevertap_plugin.podspec or the Package.swift from: entry accordingly so
both use the same constraint.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 377d95db-be1e-42e3-b694-a2d8e0a43aed
📒 Files selected for processing (12)
example/ios/Runner/AppDelegate.mexample/lib/main.dartios/Classes/CleverTapPlugin.mios/Classes/CleverTapPluginCustomTemplates.mios/Classes/include/CleverTapPlugin.hios/Classes/include/CleverTapPluginAppFunctionPresenter.hios/Classes/include/CleverTapPluginCustomTemplates.hios/Classes/include/CleverTapPluginTemplatePresenter.hios/clevertap_plugin.podspecios/clevertap_plugin/Classesios/clevertap_plugin/Package.swiftpubspec.yaml
💤 Files with no reviewable changes (1)
- example/lib/main.dart
| s.exclude_files = 'Classes/include/**/*' | ||
| s.public_header_files = 'Classes/*.h' | ||
| s.dependency 'Flutter' | ||
| s.dependency 'CleverTap-iOS-SDK', '7.6.0' |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== podspec dependency =="
sed -n '13,18p' ios/clevertap_plugin.podspec
echo
echo "== SwiftPM dependency =="
sed -n '1,220p' ios/clevertap_plugin/Package.swift | rg -n "CleverTap|from:|upToNext|exact|branch|revision"
echo
echo "Expected:"
echo "- Both package managers should enforce the same native SDK version policy."
echo "- If SwiftPM uses a 7.x range, CocoaPods should use an equivalent constraint."
echo "- If reproducibility matters more, pin both sides to the same exact version."Repository: CleverTap/clevertap-flutter
Length of output: 821
Align the CleverTap iOS SDK version constraints across CocoaPods and SwiftPM.
ios/clevertap_plugin.podspec pins CleverTap-iOS-SDK to exact 7.6.0, while ios/clevertap_plugin/Package.swift uses SwiftPM from: "7.6.0" for clevertap-ios-sdk—so the same Flutter plugin can build against different CleverTapSDK versions depending on whether CocoaPods or SwiftPM is used. Make both package managers follow the same version policy (pin both sides to the same exact version, or use equivalent ranges).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@ios/clevertap_plugin.podspec` around lines 14 - 17, The podspec currently
pins the CleverTap iOS SDK exactly (s.dependency 'CleverTap-iOS-SDK', '7.6.0')
while Package.swift uses SwiftPM's from: "7.6.0" range; update the version
policy so both package managers match—either change the podspec dependency to a
matching range (e.g., '>= 7.6.0' or a compatible '~> 7.6.0') to mirror SwiftPM's
semantics, or change Package.swift to pin exactly "7.6.0"; modify the
s.dependency line in ios/clevertap_plugin.podspec or the Package.swift from:
entry accordingly so both use the same constraint.
Summary
Adds Swift Package Manager (SPM) support to the CleverTap Flutter plugin iOS layer,
alongside the existing CocoaPods integration. Both package managers are supported
simultaneously — consumers choose based on their project setup.
Changes
pubspec.yaml— AddedswiftPackageName: clevertap_pluginunderios:toenable Flutter's SPM plugin detection
ios/clevertap_plugin/Package.swift— New SPM package manifest declaringCleverTapSDK(≥ 7.6.0) as a dependency with public headers path and search pathsios/clevertap_plugin/Classes/— Symlink pointing to../Classesso the SPMtarget and CocoaPods target share the same source files
ios/Classes/CleverTapPlugin.m— Added__has_includeguards around<CleverTapSDK/CleverTap.h>and<clevertap_plugin/CleverTapPlugin.h>forcompatibility under both build systems
ios/Classes/CleverTapPluginCustomTemplates.m— Same__has_includeguardsfor
CTJsonTemplateProducer.handCTCustomTemplatesManager.hios/clevertap_plugin.podspec— Narrowed public header file patternsNotes
clevertap-ios-sdkat7.7.0(satisfiesfrom: "7.6.0"constraint)below this are auto-promoted with a build log notice
clevertap-ios-sdkdirectly at a future v8 major,SPM will fail with: "Dependencies could not be resolved because root depends on
'clevertap-ios-sdk' 8.0.0..<9.0.0 and 'clevertap_plugin' depends on
'clevertap-ios-sdk' 7.6.0..<8.0.0." — this is expected behavior
Test Results
Build Verification (automated — CI)
flutter build ios --no-codesignsucceedsclevertap-ios-sdk 7.6.0resolved via SPMnmshows no CleverTap duplicatesCleverTapSDK.frameworkpresent in.app/Frameworks/otool -Lconfirms CleverTapSDK dylibIntegration Tests (simulator + staging account)
CleverTap: Initializing...in console, no crashonUserLoginpayload confirmed delivered to dashboardsyncVariables()requires a debug-signed build;syncVariablesinProd(false)unblocks in simulatorCocoaPods Regression (manual)
Podfile.lockshowsCleverTap-iOS-SDK (7.6.0), clean build3.8.1 → 4.0.0viapod update; all existing API calls compile and runSPM Regression (manual)
Package.resolvedshowsclevertap-ios-sdk 7.7.0, clean buildMigration Path Tests (manual)
pod deintegrate+ SPM build succeededpod installrestored CocoaPods build cleanlySummary by CodeRabbit
New Features
Improvements
Chores