Skip to content

Add Swift Package Manager (SPM) support for Flutter-SDK#356

Open
reshab-code wants to merge 13 commits into
developfrom
task/SDK-5694-spm-support-flutter-sdk
Open

Add Swift Package Manager (SPM) support for Flutter-SDK#356
reshab-code wants to merge 13 commits into
developfrom
task/SDK-5694-spm-support-flutter-sdk

Conversation

@reshab-code

@reshab-code reshab-code commented Jun 2, 2026

Copy link
Copy Markdown

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 — Added swiftPackageName: clevertap_plugin under ios: to
    enable Flutter's SPM plugin detection
  • ios/clevertap_plugin/Package.swift — New SPM package manifest declaring
    CleverTapSDK (≥ 7.6.0) as a dependency with public headers path and search paths
  • ios/clevertap_plugin/Classes/ — Symlink pointing to ../Classes so the SPM
    target and CocoaPods target share the same source files
  • ios/Classes/CleverTapPlugin.m — Added __has_include guards around
    <CleverTapSDK/CleverTap.h> and <clevertap_plugin/CleverTapPlugin.h> for
    compatibility under both build systems
  • ios/Classes/CleverTapPluginCustomTemplates.m — Same __has_include guards
    for CTJsonTemplateProducer.h and CTCustomTemplatesManager.h
  • ios/clevertap_plugin.podspec — Narrowed public header file patterns

Notes

  • SPM resolves clevertap-ios-sdk at 7.7.0 (satisfies from: "7.6.0" constraint)
  • Flutter SPM tooling enforces a minimum deployment target of iOS 13.0; projects
    below this are auto-promoted with a build log notice
  • If a consumer app declares clevertap-ios-sdk directly 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)

  • TC-B01 CocoaPods clean build — flutter build ios --no-codesign succeeds
  • TC-B02 SPM clean build — build succeeds, clevertap-ios-sdk 7.6.0 resolved via SPM
  • TC-B03 No duplicate symbols (SPM) — nm shows no CleverTap duplicates
  • TC-B04 Frameworks correctly embedded — CleverTapSDK.framework present in .app/Frameworks/
  • TC-B05 Archive / IPA creation — IPA created, otool -L confirms CleverTapSDK dylib
  • TC-B06 Modular headers build (CocoaPods) — no "non-modular header" errors

Integration Tests (simulator + staging account)

  • TC-I01 SDK initializes without crash — CleverTap: Initializing... in console, no crash
  • TC-I02 User login event — onUserLogin payload confirmed delivered to dashboard
  • TC-I03 Push notification permission prompt — system dialog appeared, no crash
  • TC-I04 In-app notification render — event fired and accepted by server; inapp renders fine
  • TC-I05 App Inbox initialization — works
  • TC-I06 Custom templates registration — not validated
  • TC-I07 CTVar sync — syncVariables() requires a debug-signed build; syncVariablesinProd(false) unblocks in simulator ⚠️

CocoaPods Regression (manual)

  • TC-M01 Fresh install — Podfile.lock shows CleverTap-iOS-SDK (7.6.0), clean build
  • TC-M02 Upgrade from 3.x — upgraded 3.8.1 → 4.0.0 via pod update; all existing API calls compile and run

SPM Regression (manual)

  • TC-S01 Fresh SPM project — Package.resolved shows clevertap-ios-sdk 7.7.0, clean build
  • TC-S02 Single copy of SDK in graph — requires Xcode Package Dependencies pane verification
  • TC-S03 Clean DerivedData rebuild — requires manual Xcode rebuild

Migration Path Tests (manual)

  • TC-E01 CocoaPods → SPM migration — pod deintegrate + SPM build succeeded
  • TC-E02 SPM → CocoaPods rollback — pod install restored CocoaPods build cleanly
  • TC-E03 Deployment target below 12.0 — Flutter auto-promotes to 13.0 with build notice; no error, no crash (amended from original pass criteria)
  • TC-E04 Version conflict from direct v8 dependency — SPM emits clear, readable conflict error (expected failure — documented above)

Summary by CodeRabbit

  • New Features

    • Added support for installing the iOS plugin via Swift Package Manager.
    • Enabled a new configuration option to identify the iOS package during Flutter integration.
  • Bug Fixes

    • Improved compatibility across CocoaPods and Swift Package Manager setups.
    • Updated iOS minimum version requirements to match the new integration flow.
  • Documentation

    • Added step-by-step guidance for setting up the iOS integration with Swift Package Manager, including troubleshooting tips.

@francispereira

francispereira commented Jun 2, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c1257504-e9e4-4a73-a92f-d1fa75ac91cb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds Swift Package Manager support to the CleverTap Flutter iOS plugin. Introduces Package.swift pinning clevertap-ios-sdk to 7.7.1, updates the podspec to use the new Sources directory layout, raises iOS deployment target to 13.0, adds swiftPackageName to pubspec.yaml, replaces unconditional imports with __has_include guards across plugin and example sources, updates registerCustomTemplates to accept an explicit NSBundle, and adds an SPM integration guide.

Changes

Swift Package Manager Integration

Layer / File(s) Summary
Package.swift manifest and build config
ios/clevertap_plugin/Package.swift, ios/clevertap_plugin.podspec, pubspec.yaml, ios/.gitignore
Introduces the SwiftPM package manifest (Swift tools 5.9, iOS 13.0, clevertap-ios-sdk 7.7.1); updates podspec source/header globs and deployment target to 13.0; adds swiftPackageName: clevertap_plugin and raises Flutter SDK minimum to >=3.41.0; ignores .swiftpm/.
Conditional header imports in plugin sources
ios/clevertap_plugin/Sources/clevertap_plugin/CleverTapPlugin.m, ios/clevertap_plugin/Sources/clevertap_plugin/CleverTapPluginCustomTemplates.m, example/ios/Runner/AppDelegate.m
Replaces unconditional #import statements with __has_include guards across all three Objective-C files, selecting <CleverTapSDK/...> module headers when available and falling back to local headers otherwise.
Bundle parameter added to registerCustomTemplates
ios/clevertap_plugin/Sources/clevertap_plugin/CleverTapPluginCustomTemplates.m
Changes the public varargs API to accept an explicit NSBundle instead of implicitly using [NSBundle mainBundle], forwarding it to the internal varargs helper.
iOS SPM integration guide
doc/Integrate-iOS-SPM.md
New doc covering requirements, opt-in steps, conditional AppDelegate import examples for ObjC and Swift, CocoaPods vs SPM comparison table, and troubleshooting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested reviewers

  • nishant-clevertap
  • akashvercetti
  • CTLalit

Poem

🐇 Hop hop, the packages align,
__has_include guards make headers shine.
SPM and Pods both get their due,
Package.swift pins the SDK true.
The bundles pass without a fuss—
Flutter on iOS, no more muss! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding Swift Package Manager support for the Flutter iOS plugin.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/SDK-5694-spm-support-flutter-sdk

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@akashvercetti

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between d716be5 and dfd2cf9.

📒 Files selected for processing (12)
  • example/ios/Runner/AppDelegate.m
  • example/lib/main.dart
  • ios/Classes/CleverTapPlugin.m
  • ios/Classes/CleverTapPluginCustomTemplates.m
  • ios/Classes/include/CleverTapPlugin.h
  • ios/Classes/include/CleverTapPluginAppFunctionPresenter.h
  • ios/Classes/include/CleverTapPluginCustomTemplates.h
  • ios/Classes/include/CleverTapPluginTemplatePresenter.h
  • ios/clevertap_plugin.podspec
  • ios/clevertap_plugin/Classes
  • ios/clevertap_plugin/Package.swift
  • pubspec.yaml
💤 Files with no reviewable changes (1)
  • example/lib/main.dart

Comment thread ios/clevertap_plugin.podspec Outdated
@reshab-code

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@reshab-code reshab-code self-assigned this Jun 23, 2026
@nishant-clevertap

Copy link
Copy Markdown
Contributor

@reshab-code https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-plugin-authors, check for this official docs if our changes follows folder and files structures and names

@reshab-code

Copy link
Copy Markdown
Author

@coedrabbitai review

@nishant-clevertap

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 `@doc/Integrate-iOS-SPM.md`:
- Line 60: The Markdown headings for the Objective-C and Swift sections are
skipping levels, which breaks the document hierarchy. Update the section
headings identified by Objective-C and Swift to use a consistent intermediate
heading level so they follow the prior subsections instead of jumping from h3 to
h6. This should be applied to both occurrences mentioned in the diff to satisfy
linting and keep the structure readable.
🪄 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: 25d4ee61-a799-4855-a661-995eefb1b010

📥 Commits

Reviewing files that changed from the base of the PR and between 52d2d8e and 74ecaa9.

📒 Files selected for processing (13)
  • doc/Integrate-iOS-SPM.md
  • ios/.gitignore
  • ios/clevertap_plugin.podspec
  • ios/clevertap_plugin/Package.swift
  • ios/clevertap_plugin/Sources/clevertap_plugin/CleverTapPlugin.m
  • ios/clevertap_plugin/Sources/clevertap_plugin/CleverTapPluginAppFunctionPresenter.m
  • ios/clevertap_plugin/Sources/clevertap_plugin/CleverTapPluginCustomTemplates.m
  • ios/clevertap_plugin/Sources/clevertap_plugin/CleverTapPluginTemplatePresenter.m
  • ios/clevertap_plugin/Sources/clevertap_plugin/include/clevertap_plugin/CleverTapPlugin.h
  • ios/clevertap_plugin/Sources/clevertap_plugin/include/clevertap_plugin/CleverTapPluginAppFunctionPresenter.h
  • ios/clevertap_plugin/Sources/clevertap_plugin/include/clevertap_plugin/CleverTapPluginCustomTemplates.h
  • ios/clevertap_plugin/Sources/clevertap_plugin/include/clevertap_plugin/CleverTapPluginTemplatePresenter.h
  • pubspec.yaml
💤 Files with no reviewable changes (1)
  • ios/clevertap_plugin/Sources/clevertap_plugin/CleverTapPluginCustomTemplates.m
✅ Files skipped from review due to trivial changes (1)
  • ios/.gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • pubspec.yaml

Comment thread doc/Integrate-iOS-SPM.md

When Flutter resolves the plugin via SPM, the module name changes. Use conditional imports in your `AppDelegate` to support both CocoaPods and SPM builds:

###### Objective-C

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix heading level increment.

Both ###### Objective-C and ###### Swift skip levels (h3 → h6). Change to #### Objective-C and #### Swift to satisfy Markdown linting and improve document structure.

📝 Proposed fix
- ###### Objective-C
+ #### Objective-C
- ###### Swift
+ #### Swift

Also applies to: 76-76

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 60-60: Heading levels should only increment by one level at a time
Expected: h4; Actual: h6

(MD001, heading-increment)

🤖 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 `@doc/Integrate-iOS-SPM.md` at line 60, The Markdown headings for the
Objective-C and Swift sections are skipping levels, which breaks the document
hierarchy. Update the section headings identified by Objective-C and Swift to
use a consistent intermediate heading level so they follow the prior subsections
instead of jumping from h3 to h6. This should be applied to both occurrences
mentioned in the diff to satisfy linting and keep the structure readable.

Source: Linters/SAST tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants