Skip to content

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

Open
reshab-code wants to merge 18 commits into
feat/release_4.2.0from
task/SDK-5694-spm-support-flutter-sdk
Open

Add Swift Package Manager (SPM) support for Flutter-SDK#356
reshab-code wants to merge 18 commits into
feat/release_4.2.0from
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 through Swift Package Manager.
    • Added configuration for identifying the iOS package during Flutter integration.
    • Improved custom template registration with support for explicitly selected resource bundles.
  • Bug Fixes

    • Improved compatibility across CocoaPods and Swift Package Manager setups.
    • Updated the iOS minimum version to 13.0 and the CleverTap iOS SDK to 7.7.1.
  • Documentation

    • Added setup, migration, verification, and troubleshooting guidance for Swift Package Manager integration.

@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.

🗂️ Base branches to auto review (1)
  • develop

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b0f91a8b-5ba0-4999-ba85-c37001c06f30

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 for the CleverTap Flutter iOS plugin. It defines the package manifest, updates CocoaPods and Flutter metadata, adds conditional Objective-C imports, changes custom template registration to accept an explicit bundle, and documents setup and migration procedures.

Changes

Swift Package Manager Integration

Layer / File(s) Summary
Package and plugin build configuration
ios/clevertap_plugin/Package.swift, ios/clevertap_plugin.podspec, pubspec.yaml, ios/.gitignore, .gitignore, example/ios/.gitignore
Defines the SwiftPM package with iOS 13.0 and clevertap-ios-sdk 7.7.1. Updates CocoaPods source and public header paths. Registers swiftPackageName: clevertap_plugin and adds ignore rules for generated or local files.
Conditional SDK and plugin imports
ios/clevertap_plugin/Sources/clevertap_plugin/CleverTapPlugin.m, ios/clevertap_plugin/Sources/clevertap_plugin/CleverTapPluginCustomTemplates.m, example/ios/Runner/AppDelegate.m
Uses __has_include checks to select module headers when available and local fallback headers otherwise.
Custom template bundle API
ios/clevertap_plugin/Sources/clevertap_plugin/CleverTapPluginCustomTemplates.m
Changes custom template registration to accept an explicit NSBundle and passes it to the varargs helper.
SPM integration documentation
doc/Integrate-iOS-SPM.md
Documents requirements, configuration, CocoaPods migration, conditional imports, verification, comparisons, and troubleshooting.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant FlutterProject
  participant SwiftPackageManager
  participant CleverTapPlugin
  participant CleverTapSDK

  FlutterProject->>SwiftPackageManager: Resolve clevertap_plugin
  SwiftPackageManager->>CleverTapSDK: Resolve exact 7.7.1
  SwiftPackageManager-->>CleverTapPlugin: Provide package headers and sources
  CleverTapPlugin->>CleverTapSDK: Import available SDK headers
Loading

Possibly related issues

Possibly related PRs

Suggested reviewers: nishant-clevertap, piyush-kukadiya, ctlalit

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding Swift Package Manager support for the Flutter SDK.
✨ 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 Outdated
Comment thread doc/Integrate-iOS-SPM.md Outdated
…ps and adding migration and troubleshooting guidance.

@akashvercetti akashvercetti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@reshab-code we have a new ios sdk version released now, and by the time this release goes out, more versions might have been released. Change the base CT ios sdk version at the time of release

@akashvercetti

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 5, 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: 2

🤖 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 121: Update the manual migration instructions for
FlutterGeneratedPluginSwiftPackage to include adding it under the Runner
target’s Frameworks, Libraries, and Embedded Content and configuring it as a
target dependency before creating the Scheme Pre-action Run Script.
- Line 123: Update the “Build fails with missing headers” troubleshooting entry
in Integrate-iOS-SPM.md to focus on verifying SPM linkage and header locations.
Move deployment-target guidance into a separate troubleshooting entry,
preserving the 13.0-or-higher requirement there.
🪄 Autofix

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 Plus

Run ID: 6806c806-82c7-4ece-8248-584cd5dae537

📥 Commits

Reviewing files that changed from the base of the PR and between 74ecaa9 and 8922ed1.

📒 Files selected for processing (4)
  • .gitignore
  • doc/Integrate-iOS-SPM.md
  • example/ios/.gitignore
  • pubspec.yaml

Comment thread doc/Integrate-iOS-SPM.md
### Troubleshooting

- **Xcode doesn't resolve the package**: Run `flutter pub get`, then in Xcode go to **File → Packages → Resolve Package Versions**.
- **Automatic migration didn't add the package**: In Xcode, add it manually - **Package Dependencies → Add Local…** → select `ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage` and add it to the `Runner` target. Then under **Product → Scheme → Edit Scheme → Build → Pre-actions**, add a Run Script (with build settings from `Runner`): `"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" prepare`.

@coderabbitai coderabbitai Bot Aug 5, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Flutter Swift Package Manager for-app-developers manual package dependency Verify Frameworks Libraries Embedded Content target dependency

💡 Result:

As of Flutter 3.44, Swift Package Manager (SwiftPM) integration for iOS and macOS is enabled by default [1]. When you run your Flutter app, Flutter automatically manages the necessary SwiftPM dependencies, specifically the FlutterGeneratedPluginSwiftPackage, which handles dependencies for Flutter plugins compatible with SwiftPM [1][2]. Manual integration is generally only required if automatic setup fails or if you are configuring a custom Xcode target [1]. To manually integrate Swift Package Manager for a Flutter app, follow these steps [1]: 1. Add the Package Dependency: In Xcode, navigate to your project and locate the FlutterGeneratedPluginSwiftPackage at the following path: ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage [1]. Add this package to your project [1]. 2. Configure Target Dependency: Ensure that the FlutterGeneratedPluginSwiftPackage is correctly added to your desired target (e.g., the Runner target) [1]. 3. Frameworks, Libraries, and Embedded Content: In your Xcode project, go to the General tab for your target and verify that the FlutterGeneratedPluginSwiftPackage appears under the Frameworks, Libraries, and Embedded Content section [1]. If it is missing, add it manually [1]. 4. Pre-action Script: Ensure the Run Prepare Flutter Framework script is configured to run as a pre-action in your Xcode scheme [1]. Verify that the FlutterGeneratedPluginSwiftPackage is set as a target dependency in this process [1]. For "Add-to-App" scenarios where you are embedding a Flutter module into an existing native iOS or macOS application, you should instead use the command line to generate the Swift package: - Run flutter build swift-package --platform ios (or macos) [3][4]. - Add the resulting generated package to your Xcode project and include it in the Frameworks, Libraries, and Embedded Content section of your target [3][4]. - Configure the FLUTTER_SWIFT_PACKAGE_OUTPUT build setting to point to the location of the generated Swift package output [3][4]. If you encounter issues with automatic SwiftPM integration, you can disable it by adding enable-swift-package-manager: false under the flutter section in your pubspec.yaml file, or by running flutter config --no-enable-swift-package-manager [5].

Citations:


🌐 Web query:

site:docs.flutter.dev packages-and-plugins swift-package-manager for-app-developers Manual Swift Package Manager migration Run Script target dependency

💡 Result:

When migrating to or configuring Swift Package Manager (SwiftPM) for Flutter applications, handling Run Script dependencies is a critical step to ensure that Flutter-specific build processes (such as assembling assets and framework generation) are correctly integrated into the Xcode build pipeline [1][2][3]. If you are manually setting up or migrating an iOS or macOS project to use SwiftPM for Flutter, you must configure two specific types of Run Script actions to maintain build integrity [2][3]. 1. Pre-action Run Script (Scheme Level) You must define a pre-action script in your Xcode Scheme to ensure the Flutter framework is prepared before the main build begins [1][2]. - Navigate to Product > Scheme > Edit Scheme... in Xcode [2][3]. - Select Build (in the left sidebar) and expand Pre-actions [2][3]. - Click the + button and select New Run Script Action [2][3]. - In the Provide build settings from dropdown, select your main Runner target [1][2]. - Use the following command (adjusting the path as necessary for your project setup): /bin/sh $FLUTTER_SWIFT_PACKAGE_OUTPUT/Scripts/flutter_integration.sh prebuild 2. Run Script Build Phase (Target Level) To handle assembly during the build process, add a Run Script Phase to your project's target [2][3]. - Navigate to your target's Build Phases tab [2][3]. - Click the + button and select New Run Script Phase [2][3]. - Set the script content to: /bin/sh $FLUTTER_SWIFT_PACKAGE_OUTPUT/Scripts/flutter_integration.sh assemble - Uncheck the Based on dependency analysis option [2][3]. - Add the following to Input File Lists to ensure correct incremental build behavior: $(FLUTTER_SWIFT_PACKAGE_OUTPUT)/Scripts/FlutterAssembleInputs.xcfilelist If you are using the FlutterGeneratedPluginSwiftPackage, ensure that this package is added as a target dependency in the Runner target [1]. This ensures that the generated plugin code is available to your application at compile time [1]. For developers migrating existing projects, always ensure you have removed previous integration methods (such as legacy CocoaPods configurations) if they conflict with the new SwiftPM setup [3]. For more complex plugin-level configurations, such as handling dynamic libraries or native XCTests, consult the official Flutter documentation on Swift Package Manager integration for plugin authors [4].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Target file:"
fd -a 'Integrate-iOS-SPM\.md$' . || true

file="$(fd 'Integrate-iOS-SPM\.md$' . | head -n1 || true)"
if [ -n "${file:-}" ]; then
  echo
  echo "Relevant lines around 115-130:"
  sed -n '115,130p' "$file" | nl -ba -v115
fi

echo
echo "Search for SwiftPM instruction terms in repository:"
rg -n "Framework.?Libraries.?Embedded|Target Dependency|target dependency|FlutterGeneratedPluginSwiftPackage|Run Script|Pre-actions|xcode_backend\.sh prepare" .

Repository: CleverTap/clevertap-flutter

Length of output: 295


🏁 Script executed:

#!/bin/sh
set -eu

file="doc/Integrate-iOS-SPM.md"
printf 'Target file: %s\n' "$file"
echo
printf 'Relevant lines around 115-130:\n'
awk 'NR>=115 && NR<=130 { printf "%4d  %s\n", NR, $0 }' "$file"
echo
printf 'SwiftPM instruction terms in repository:\n'
rg -n "Framework.?Libraries.?Embedded|Target Dependency|target dependency|FlutterGeneratedPluginSwiftPackage|Run Script|Pre-actions|xcode_backend\.sh prepare" . || true

Repository: CleverTap/clevertap-flutter

Length of output: 2778


Complete the manual SwiftPM linkage steps.

If FlutterGeneratedPluginSwiftPackage must be added manually, also make sure it is present in Frameworks, Libraries, and Embedded Content and configured as a target dependency before adding the Scheme Pre-action Run Script.

🤖 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 121, Update the manual migration
instructions for FlutterGeneratedPluginSwiftPackage to include adding it under
the Runner target’s Frameworks, Libraries, and Embedded Content and configuring
it as a target dependency before creating the Scheme Pre-action Run Script.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@reshab-code check this comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

talked to akash regarding this, no change needed was our conclusion after discussion

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Comment thread doc/Integrate-iOS-SPM.md
- **Xcode doesn't resolve the package**: Run `flutter pub get`, then in Xcode go to **File → Packages → Resolve Package Versions**.
- **Automatic migration didn't add the package**: In Xcode, add it manually - **Package Dependencies → Add Local…** → select `ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage` and add it to the `Runner` target. Then under **Product → Scheme → Edit Scheme → Build → Pre-actions**, add a Run Script (with build settings from `Runner`): `"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" prepare`.
- **Duplicate symbol errors**: Don't use both CocoaPods and SPM for the same plugin at once. If a `Podfile` exists and SPM is enabled, Flutter prefers SPM for plugins that support it.
- **Build fails with missing headers**: Verify your deployment target is `13.0` or higher in both your Xcode project and `Podfile`/`Package.swift`.

@coderabbitai coderabbitai Bot Aug 5, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Repository files matching Integrate-iOS-SPM:\n'
fd -a 'Integrate-iOS-SPM\.md$|Package\.swift$|Podfile' . || true

printf '\nRelevant doc snippet:\n'
if [ -f doc/Integrate-iOS-SPM.md ]; then
  nl -ba doc/Integrate-iOS-SPM.md | sed -n '100,145p'
fi

printf '\nSearch for missing-header/deployment-target mentions:\n'
rg -n "missing header|header|deployment target|deployment-target|13\.0|FlutterGeneratedPluginSwiftPackage|conditional import|conditional imports" .

Repository: CleverTap/clevertap-flutter

Length of output: 454


🌐 Web query:

Flutter SPM App developers minimum platform support iOS 13 missing headers FlutterGeneratedPluginSwiftPackage

💡 Result:

When experiencing build issues with FlutterGeneratedPluginSwiftPackage related to minimum platform versions (e.g., iOS 13) or missing headers, it is typically due to the way Flutter generates the ephemeral Package.swift file for Swift Package Manager (SPM) [1][2][3]. ### Minimum Platform Version Mismatches Flutter's SPM integration sometimes defaults the FlutterGeneratedPluginSwiftPackage platform version to 13.0, ignoring your project's higher deployment target requirements [4][5][3]. This causes build errors if your app or its dependencies require a higher version (e.g., iOS 15.0) [5][3]. To resolve this: 1. Ensure your Xcode project's Minimum Deployment target is set to the required version (e.g., 15.0) in your project settings and Podfile (if still used for other dependencies) [4][5]. 2. Run a Flutter CLI command such as flutter build ios --config-only or flutter run [1][6][3]. These commands trigger the Flutter tool to update the generated Package.swift file to match your project's deployment target [3][7]. 3. Note that building directly from Xcode without running the Flutter CLI first can cause failures because Xcode may use a stale, cached, or default version of the generated Package.swift [2][3]. ### Missing Headers If you encounter missing header errors (often in plugins migrating from CocoaPods to SPM), it is usually because SPM has strict requirements for header directory structure [8][9][10]. To fix header issues: 1. Directory Structure: Ensure your public headers are located in a specific nested path: Sources/<plugin_name>/include/<plugin_name>/YourHeader.h [9][10]. 2. Header Search Paths: If using Objective-C, you may need to explicitly define headerSearchPath in your Package.swift to ensure the compiler can locate these headers [9]. 3. Module Maps: If you are maintaining compatibility with both CocoaPods and SPM, ensure your Package.swift correctly excludes the CocoaPods-specific module map and umbrella header, as SPM manages these automatically [8]. 4. FFI Plugins: If building an FFI plugin, ensure an include folder exists (even if empty, sometimes requiring a .gitkeep file) to satisfy SPM's expectation for public headers [11]. If these issues persist and prevent builds, you can temporarily disable Flutter's SPM integration by adding "disable-swift-package-manager: true" to your pubspec.yaml under the flutter section, or globally via flutter config --no-enable-swift-package-manager [6][11].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Relevant doc snippet:\n'
awk 'NR>=110 && NR<=130 {printf "%6d\t%s\n", NR, $0}' doc/Integrate-iOS-SPM.md

printf '\nPackage.swift header/public headers section:\n'
awk '{printf "%6d\t%s\n", NR, $0}' ios/clevertap_plugin/Package.swift

printf '\nPodfile platform/deployment settings and generated package mentions:\n'
awk '{printf "%6d\t%s\n", NR, $0}' example/ios/Podfile | rg -n "platform|ios|FlutterGeneratedPluginSwiftPackage|package" || true

printf '\nDoc mentions of FlutterGeneratedPluginSwiftPackage and missing headers:\n'
rg -n "FlutterGeneratedPluginSwiftPackage|missing header|header|deployment target|13\.0" doc/Integrate-iOS-SPM.md || true

printf '\nSearch for conditional import mentions in doc and plugin source headers package config:\n'
rg -n "conditional import|conditional imports|import.*conditional|Swift\(`#if`" doc ios example -S || true

Repository: CleverTap/clevertap-flutter

Length of output: 4741


Separate missing-header and deployment-target troubleshooting.

Deployment target errors are handled separately. Missing-header errors need SPM linkage and header-location checks, not just a 13.0 deployment target.

Suggested documentation update
-- **Build fails with missing headers**: Verify your deployment target is `13.0` or higher in both your Xcode project and `Podfile`/`Package.swift`.
+- **Build reports an iOS deployment-target error**: Verify that your Xcode project and `Podfile`/`Package.swift` use an iOS deployment target of `13.0` or higher.
+- **Build fails with missing headers**: Verify that `FlutterGeneratedPluginSwiftPackage` is linked to the `Runner` target and that the conditional imports match the selected package manager.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- **Build fails with missing headers**: Verify your deployment target is `13.0` or higher in both your Xcode project and `Podfile`/`Package.swift`.
- **Build reports an iOS deployment-target error**: Verify that your Xcode project and `Podfile`/`Package.swift` use an iOS deployment target of `13.0` or higher.
- **Build fails with missing headers**: Verify that `FlutterGeneratedPluginSwiftPackage` is linked to the `Runner` target and that the conditional imports match the selected package manager.
🤖 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 123, Update the “Build fails with missing
headers” troubleshooting entry in Integrate-iOS-SPM.md to focus on verifying SPM
linkage and header locations. Move deployment-target guidance into a separate
troubleshooting entry, preserving the 13.0-or-higher requirement there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@reshab-code check this comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

talked to akash regarding this, no change needed was our conclusion after discussion

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Comment thread ios/clevertap_plugin.podspec Outdated
Comment thread ios/clevertap_plugin/Package.swift
Comment thread ios/clevertap_plugin/Package.swift Outdated
Comment thread doc/Integrate-iOS-SPM.md
### Troubleshooting

- **Xcode doesn't resolve the package**: Run `flutter pub get`, then in Xcode go to **File → Packages → Resolve Package Versions**.
- **Automatic migration didn't add the package**: In Xcode, add it manually - **Package Dependencies → Add Local…** → select `ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage` and add it to the `Runner` target. Then under **Product → Scheme → Edit Scheme → Build → Pre-actions**, add a Run Script (with build settings from `Runner`): `"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" prepare`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@reshab-code check this comment

Comment thread doc/Integrate-iOS-SPM.md
- **Xcode doesn't resolve the package**: Run `flutter pub get`, then in Xcode go to **File → Packages → Resolve Package Versions**.
- **Automatic migration didn't add the package**: In Xcode, add it manually - **Package Dependencies → Add Local…** → select `ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage` and add it to the `Runner` target. Then under **Product → Scheme → Edit Scheme → Build → Pre-actions**, add a Run Script (with build settings from `Runner`): `"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" prepare`.
- **Duplicate symbol errors**: Don't use both CocoaPods and SPM for the same plugin at once. If a `Podfile` exists and SPM is enabled, Flutter prefers SPM for plugins that support it.
- **Build fails with missing headers**: Verify your deployment target is `13.0` or higher in both your Xcode project and `Podfile`/`Package.swift`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@reshab-code check this comment

…te as per docs, adds spm builds to gitignore
@reshab-code
reshab-code changed the base branch from develop to feat/release_4.2.0 August 17, 2026 07:36
Comment thread doc/Integrate-iOS-SPM.md Outdated
Comment thread doc/Integrate-iOS-SPM.md Outdated
Comment thread doc/Integrate-iOS-SPM.md Outdated
.product(name: "FlutterFramework", package: "FlutterFramework"),
.product(name: "CleverTapSDK", package: "clevertap-ios-sdk")
],
publicHeadersPath: "include/clevertap_plugin",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why is publicHeadersPath added even if not stated in flutter docs? Is it needed? Have you tested this on sample app?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

publicHeadersPath is required for Objective-C targets in SPM as iit tells the package manager where the public headers are so it can generate a module map. The headers physically live at Sources/clevertap_plugin/include/clevertap_plugin/ and the path "include/clevertap_plugin" is relative to that sources dir. Without it, ObjC imports would break. It was tested and verified in the example app with SPM enabled.

Comment thread doc/Integrate-iOS-SPM.md
Flutter introduced Swift Package Manager support as an **opt-in** feature in Flutter 3.24, and it became the **default** package manager in Flutter 3.44. The CleverTap Flutter plugin from v4.2.0 ships a `Package.swift` alongside its podspec, so both package managers resolve the same native SDK version (`CleverTap-iOS-SDK 7.8.1`).

> **Minimum requirements for SPM integration**
> - Flutter 3.24+ (opt-in) - enabled by default from Flutter 3.44

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we have mentioned on doc it is supported from 3.24, have you tested on lower versions with this package, like 3.35 version?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Testing was done on Flutter 3.41.9 with SPM opt-in enabled - which is in the 3.24-3.43 range. Flutter 3.24 and 3.35 were not tested specifically. We can either mention in the docs that it was tested on 3.41.9 and enabled by default from Flutter 3.44 or explicitly test on lower version whatever you suggest

@nishant-clevertap nishant-clevertap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

resolve merge conflict on this PR

@nishant-clevertap nishant-clevertap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Check for debug and release build on iPhone device, and then try to archive the app after migrating to SPM, on latest flutter version and lower versions also

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