Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b3d30e8
Create Package.swift file for spm support
reshab-code May 7, 2026
2a7a415
Create symlinks for spm
reshab-code May 7, 2026
5d96862
Add guard to obj c imports in ClevertapPlugin.m
reshab-code May 7, 2026
203c1e3
wrapped both CTJsonTemplateProducer.h and CTCustomTemplatesManager.h …
reshab-code May 7, 2026
b91d176
Narrowed header files in podspec
reshab-code May 7, 2026
c0b7ecf
Relocate Package.swift to ios/clevertap_plugin/ for Flutter SPM detec…
reshab-code May 8, 2026
dfd2cf9
Add swift package name under ios in pubspec.yaml, added guards for th…
reshab-code May 19, 2026
52d2d8e
Fix Package.swift to use same version as podspec to ensure no drift
reshab-code Jun 23, 2026
a7c16ee
Restructure folders and files as per the official flutter docs
reshab-code Jun 23, 2026
8751ec8
Merge branch 'develop' into task/SDK-5694-spm-support-flutter-sdk
reshab-code Jun 25, 2026
9e9fdf6
Fix version in package.swift to match podspec for correct version res…
reshab-code Jun 25, 2026
74ecaa9
Add spm integration doc for flutter
reshab-code Jun 25, 2026
c22b0dc
Fix flutter version in pubspec to 1.1.7 and enable spm for supported …
reshab-code Jun 30, 2026
8230f92
correct and trim the ios spm integration doc, fixing the enabling ste…
akashvercetti Aug 4, 2026
8922ed1
ignore flutter ephemeral, local claude settings, and generated sdk re…
akashvercetti Aug 4, 2026
7fa5ea4
Fix pr comments and add flutter framework dependency for swift pm rou…
reshab-code Aug 15, 2026
25a953a
update integration doc for ct plugin v4.2.0 and core ios sdk verison …
reshab-code Aug 20, 2026
c021559
merge feat/release_4.2.0, resolve usnotifications import conflict in …
reshab-code Aug 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ example/pubspec.lock
pubspec.lock
example/android/app/property*

# Local Claude Code settings
.claude/settings.local.json

# Generated SDK review reports
sdk-review-*.html

# SPM build artifacts
.build/
.swiftpm/

124 changes: 124 additions & 0 deletions doc/Integrate-iOS-SPM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
## 📦 iOS Integration via Swift Package Manager (SPM)

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

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.

Can you test once on 3.35 or lower 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.

Okay sure

> - Xcode 15+ (required for `swift-tools-version: 5.9`)
> - iOS deployment target: 13.0+
>
> If you are on Flutter < 3.24, the plugin continues to work via CocoaPods - no action required.

---

### How it works

The plugin ships a Swift package that pins `CleverTap-iOS-SDK 7.8.1`. When your app is built with SPM enabled, Flutter resolves it automatically - you don't add anything to your app's own `Package.swift` or edit any plugin files.

---

### Enabling SPM in your Flutter app

SPM is opt-in on Flutter 3.24–3.43 (and on by default from 3.44). There is **no** `flutter run`/`flutter build` flag and **no** `Info.plist` key for this - you enable it through Flutter configuration.

**Per project (recommended for testing)** - add to your app's `pubspec.yaml`:

```yaml
flutter:
config:
enable-swift-package-manager: true
```

**Globally for your machine:**

```bash
flutter config --enable-swift-package-manager
```

To turn it back off, use `enable-swift-package-manager: false` in `pubspec.yaml`, or `flutter config --no-enable-swift-package-manager` globally.

---

### Migrating an existing CocoaPods app to SPM

Once SPM is enabled, Flutter migrates the Xcode project automatically the next time you build or run. To migrate cleanly on an app that already uses CocoaPods:

**1. Enable SPM** (per-project block above, or global flag).

**2. Clear the existing CocoaPods state** (run from your app root):

```bash
flutter clean
cd ios
rm -rf Pods Podfile.lock .symlinks build
rm -rf ~/Library/Developer/Xcode/DerivedData/Runner-*
cd ..
```

**3. Re-resolve and trigger the migration:**

```bash
flutter pub get
flutter build ios --config-only # or: flutter run
```

On this build Flutter adds a `FlutterGeneratedPluginSwiftPackage` to the Xcode project and resolves every plugin that ships a `Package.swift` (including `clevertap_plugin`) via SPM. Plugins that only ship a podspec stay on CocoaPods - a hybrid setup is expected.

**4. Verify SPM took over.** Open `ios/Runner.xcworkspace` and confirm:
- **Package Dependencies** lists `clevertap_plugin` and, transitively, `clevertap-ios-sdk` at `7.8.1`.
- The regenerated `Podfile.lock` no longer contains a `clevertap_plugin` pod entry.

**5. Build and run** on a simulator/device and smoke-test CleverTap initialization plus a `recordEvent` to confirm native symbols link.

---

### AppDelegate changes when using SPM

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**

```objc
#if __has_include(<CleverTapSDK/CleverTap.h>)
#import <CleverTapSDK/CleverTap.h>
#else
#import "CleverTap.h"
#endif

#if __has_include(<clevertap_plugin/CleverTapPlugin.h>)
#import <clevertap_plugin/CleverTapPlugin.h>
#else
#import "CleverTapPlugin.h"
#endif
```

**Swift**

```swift
import CleverTapSDK
import clevertap_plugin
```

These guards ensure your app compiles correctly regardless of which package manager resolved the dependency.

---

### CocoaPods vs SPM

| | CocoaPods | SPM |
|---|---|---|
| SDK version pinned | `7.8.1` | `7.8.1` |
| Deployment target | `9.0` | `13.0` |
| Opt-in required | No | Yes on Flutter 3.24–3.43; default from 3.44 |

Both package managers resolve the same CleverTap iOS SDK version to ensure no drift between the two integration paths.

---

### 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!

- **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!

- **Stale CocoaPods references after migrating**: If the build still runs `[CP]` Pods build phases (or duplicate-embeds a framework) for a plugin that has moved to SPM, run `pod deintegrate` in your app's `ios/` directory, then `flutter clean && flutter build ios` so Flutter re-integrates cleanly. Use this only as a recovery step - it is not part of the normal migration flow. Flutter regenerates the CocoaPods integration on every build, so a manual `pod deintegrate` is otherwise undone on the next build.
1 change: 1 addition & 0 deletions example/ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Flutter/app.flx
Flutter/app.zip
Flutter/flutter_assets/
Flutter/flutter_export_environment.sh
Flutter/ephemeral/
ServiceDefinitions.json
Runner/GeneratedPluginRegistrant.*

Expand Down
9 changes: 9 additions & 0 deletions example/ios/Runner/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@
#import "GeneratedPluginRegistrant.h"
#import <UserNotifications/UserNotifications.h>

#if __has_include(<CleverTapSDK/CleverTap.h>)
#import <CleverTapSDK/CleverTap.h>
#else
#import "CleverTap.h"
#endif
#if __has_include(<clevertap_plugin/CleverTapPlugin.h>)
#import <clevertap_plugin/CleverTapPlugin.h>
#import <clevertap_plugin/CleverTapPluginCustomTemplates.h>
#else
#import "CleverTapPlugin.h"
#import "CleverTapPluginCustomTemplates.h"
#endif

@implementation AppDelegate

Expand Down
4 changes: 3 additions & 1 deletion ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ Icon?
.tags*

/Flutter/Generated.xcconfig
/Flutter/flutter_export_environment.sh
/Flutter/flutter_export_environment.sh

.swiftpm/
Empty file removed ios/Assets/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions ios/clevertap_plugin.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Pod::Spec.new do |s|
s.license = { :file => '../LICENSE' }
s.author = { "CleverTap" => "http://www.clevertap.com" }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.source_files = 'clevertap_plugin/Sources/clevertap_plugin/**/*.{h,m}'
s.public_header_files = 'clevertap_plugin/Sources/clevertap_plugin/include/clevertap_plugin/*.h'
s.dependency 'Flutter'
s.dependency 'CleverTap-iOS-SDK', '7.7.1'
s.ios.deployment_target = '9.0'
Expand Down
32 changes: 32 additions & 0 deletions ios/clevertap_plugin/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// swift-tools-version: 5.9
import PackageDescription

let package = Package(
name: "clevertap_plugin",
platforms: [
.iOS("13.0")
],
products: [
.library(name: "clevertap-plugin", targets: ["clevertap_plugin"])
],
dependencies: [
.package(name: "FlutterFramework", path: "../FlutterFramework"),
.package(
url: "https://github.com/CleverTap/clevertap-ios-sdk",
exact: "7.8.1"
)
],
targets: [
.target(
name: "clevertap_plugin",
dependencies: [
.product(name: "FlutterFramework", package: "FlutterFramework"),
.product(name: "CleverTapSDK", package: "clevertap-ios-sdk")
],
publicHeadersPath: "include/clevertap_plugin",
Comment thread
reshab-code marked this conversation as resolved.

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.

cSettings: [
.headerSearchPath("include/clevertap_plugin")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -1,21 +1,101 @@

#if __has_include(<CleverTapSDK/CleverTap.h>)
#import <CleverTapSDK/CleverTap.h>
#else
#import "CleverTap.h"
#endif

#import "CleverTapPlugin.h"

#if __has_include(<CleverTapSDK/CleverTap+Inbox.h>)
#import <CleverTapSDK/CleverTap+Inbox.h>
#else
#import "CleverTap+Inbox.h"
#endif

#if __has_include(<CleverTapSDK/CleverTapUTMDetail.h>)
#import <CleverTapSDK/CleverTapUTMDetail.h>
#else
#import "CleverTapUTMDetail.h"
#endif

#if __has_include(<CleverTapSDK/CleverTapEventDetail.h>)
#import <CleverTapSDK/CleverTapEventDetail.h>
#else
#import "CleverTapEventDetail.h"
#endif

#if __has_include(<CleverTapSDK/CleverTapSyncDelegate.h>)
#import <CleverTapSDK/CleverTapSyncDelegate.h>
#else
#import "CleverTapSyncDelegate.h"
#endif

#if __has_include(<CleverTapSDK/CleverTap+DisplayUnit.h>)
#import <CleverTapSDK/CleverTap+DisplayUnit.h>
#else
#import "CleverTap+DisplayUnit.h"
#endif

#if __has_include(<CleverTapSDK/CleverTap+FeatureFlags.h>)
#import <CleverTapSDK/CleverTap+FeatureFlags.h>
#else
#import "CleverTap+FeatureFlags.h"
#endif

#if __has_include(<CleverTapSDK/CleverTap+ProductConfig.h>)
#import <CleverTapSDK/CleverTap+ProductConfig.h>
#else
#import "CleverTap+ProductConfig.h"
#endif

#if __has_include(<CleverTapSDK/CleverTapPushNotificationDelegate.h>)
#import <CleverTapSDK/CleverTapPushNotificationDelegate.h>
#else
#import "CleverTapPushNotificationDelegate.h"
#endif

#if __has_include(<CleverTapSDK/CleverTapInAppNotificationDelegate.h>)
#import <CleverTapSDK/CleverTapInAppNotificationDelegate.h>
#else
#import "CleverTapInAppNotificationDelegate.h"
#endif

#if __has_include(<CleverTapSDK/CleverTap+InAppNotifications.h>)
#import <CleverTapSDK/CleverTap+InAppNotifications.h>
#else
#import "CleverTap+InAppNotifications.h"
#endif

#if __has_include(<CleverTapSDK/CleverTap+PushPermission.h>)
#import <CleverTapSDK/CleverTap+PushPermission.h>
#else
#import "CleverTap+PushPermission.h"
#endif

#if __has_include(<CleverTapSDK/CTLocalInApp.h>)
#import <CleverTapSDK/CTLocalInApp.h>
#else
#import "CTLocalInApp.h"
#endif

#if __has_include(<CleverTapSDK/CleverTap+CTVar.h>)
#import <CleverTapSDK/CleverTap+CTVar.h>
#else
#import "CleverTap+CTVar.h"
#endif

#if __has_include(<CleverTapSDK/CTVar.h>)
#import <CleverTapSDK/CTVar.h>
#else
#import "CTVar.h"
#endif

#if __has_include(<CleverTapSDK/CTTemplateContext.h>)
#import <CleverTapSDK/CTTemplateContext.h>
#else
#import "CTTemplateContext.h"
#endif

@interface CleverTapPlugin () <CleverTapSyncDelegate, CleverTapInAppNotificationDelegate, CleverTapDisplayUnitDelegate, CleverTapInboxViewControllerDelegate, CleverTapProductConfigDelegate, CleverTapFeatureFlagsDelegate, CleverTapPushNotificationDelegate, CleverTapPushPermissionDelegate>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@
#import "CleverTapPluginCustomTemplates.h"
#import "CleverTapPluginTemplatePresenter.h"
#import "CleverTapPluginAppFunctionPresenter.h"

#if __has_include(<CleverTapSDK/CTJsonTemplateProducer.h>)
#import <CleverTapSDK/CTJsonTemplateProducer.h>
#else
#import "CTJsonTemplateProducer.h"
#endif

#if __has_include(<CleverTapSDK/CTCustomTemplatesManager.h>)
#import <CleverTapSDK/CTCustomTemplatesManager.h>
#else
#import "CTCustomTemplatesManager.h"
#endif

@implementation CleverTapPluginCustomTemplates

Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ flutter:
pluginClass: CleverTapPlugin
ios:
pluginClass: CleverTapPlugin
swiftPackageName: clevertap_plugin
web:
pluginClass: CleverTapPluginWeb
fileName: clevertap_plugin_web.dart