feat: add Swift Package Manager support for iOS plugin#1131
Merged
fadi-george merged 17 commits intomainfrom Apr 1, 2026
Merged
Conversation
18 tasks
| @@ -0,0 +1,7 @@ | |||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | |||
There was a problem hiding this comment.
why do you need seperate a demo_spm example? is it to maintain backward compatibility?
Collaborator
Author
There was a problem hiding this comment.
The demo folder has:
config:
enable-swift-package-manager: false
so its to test the pods install flow
Migrate iOS plugin source files from ios/Classes/ to the SPM-compatible directory structure at ios/onesignal_flutter/Sources/onesignal_flutter/. Add Package.swift targeting OneSignal-iOS-SDK 5.5.0 via SPM. Update podspec paths so CocoaPods continues to work alongside SPM. Scaffold demo_spm example app for SPM build verification. Made-with: Cursor
6a6917f to
e2fe35c
Compare
and set examples/demo to not use spm
Git doesn't follow symlinked .gitignore files, so replace with a real copy. Add missing flutter_dotenv dependency and .env asset needed by the shared main.dart. Made-with: Cursor
691cd80 to
c0b631d
Compare
abdulraqeeb33
approved these changes
Apr 1, 2026
1 task
nan-li
reviewed
Apr 1, 2026
ios/onesignal_flutter/Package.swift
Outdated
| .library(name: "onesignal-flutter", targets: ["onesignal_flutter"]) | ||
| ], | ||
| dependencies: [ | ||
| .package(url: "https://github.com/OneSignal/OneSignal-iOS-SDK", exact: "5.5.0"), |
Contributor
There was a problem hiding this comment.
What do you think about using https://github.com/OneSignal/OneSignal-XCFramework? I know for native iOS we recommend people to use that repository when using SPM rather than https://github.com/OneSignal/OneSignal-XCFramework for size
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Add Swift Package Manager (SPM) support for the iOS plugin while maintaining full CocoaPods compatibility.
Details
Motivation
Flutter is gradually adopting Swift Package Manager as the default dependency manager for iOS. Plugins that don't support SPM can cause build problems for projects that have migrated to SPM. This change ensures the OneSignal Flutter plugin works with both CocoaPods and SPM, following Flutter's official migration guide.
Scope
Plugin iOS source restructure (
ios/):The core change restructures the iOS plugin source files from
ios/Classes/to the SPM-compatible directory layout atios/onesignal_flutter/:Key details:
Package.swift— Declares the SPM package targeting iOS 11.0, depending onOneSignal-iOS-SDKexact version5.5.0via SPM. Library name isonesignal-flutter(underscores to hyphens per Flutter convention). Depends onOneSignalFramework,OneSignalInAppMessages,OneSignalLocation, andOneSignalExtensionproducts.ios/Classes/*.h→ios/onesignal_flutter/Sources/onesignal_flutter/include/onesignal_flutter/(SPM public headers directory).ios/Classes/*.m→ios/onesignal_flutter/Sources/onesignal_flutter/.#importstatements in all.mfiles updated to use relative paths (./include/onesignal_flutter/HeaderName.h) since headers are now in a subdirectory.onesignal_flutter.podspecupdatedsource_filesandpublic_header_filesto point to new paths — CocoaPods continues to work with the same files.ios/Classes/andios/Assets/(empty) directories removed.What is NOT changed:
OneSignalXCFramework 5.5.0)demoexample app (remains CocoaPods-based)examples/demo_spm/— SPM example app:Scaffolded the existing
demo_spmstub into a full example app withios/andandroid/platform folders. This app uses SPM for iOS dependency resolution (no Podfile). Includes aOneSignalNotificationServiceExtensiontarget configured with theOneSignalExtensionSPM product for push notification processing.Testing
Prerequisites
Enable Swift Package Manager in Flutter (one-time setup):
1. CocoaPods build (
examples/demo/)demohasenable-swift-package-manager: falsein itspubspec.yamlto ensure CocoaPods is used.flutter runon iOS simulator2. SPM build (
examples/demo_spm/)Wiped simulator, then ran
flutter runon iOS simulator.3. CocoaPods → SPM migration (
examples/demo/)Wiped simulator, then tested migrating
demofrom CocoaPods to SPM:pubspec.yaml:PodfileandPods/directoryios/Flutter/Debug.xcconfigandios/Flutter/Release.xcconfig:flutter run— Flutter adds SPM integration and builds successfullyNotes
Affected code checklist
None of the above are affected. This is a build system change only — source files are moved but their content is unchanged (only
#importpaths updated).Checklist
Overview
Testing
Final pass
Made with Cursor