Skip to content

Commit 74ad8a8

Browse files
authored
Merge pull request #199 from mindbox-cloud/feature/MOBILE-146-SPM
MOBILE-146: SPM support and Example update
2 parents 348e353 + 380e827 commit 74ad8a8

31 files changed

Lines changed: 345 additions & 450 deletions

File tree

.github/workflows/manual-prepare_release_branch.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ jobs:
158158
sed -i "s/cloud.mindbox:mobile-sdk:.*/cloud.mindbox:mobile-sdk:$AND_VER'/" mindbox_android/android/build.gradle
159159
echo " After:" && grep "cloud.mindbox:mobile-sdk" mindbox_android/android/build.gradle || true
160160
161+
# Fail the release if a version substitution didn't land (stale pin).
162+
assert_pin() { grep -qE "$2" "$1" || { echo "ERROR: pattern /$2/ not found in $1 — substitution failed"; exit 1; }; }
163+
161164
echo "→ Bumping iOS native SDK in podspec"
162165
echo " Before s.version:" && grep -E "s\.version" mindbox_ios/ios/mindbox_ios.podspec || true
163166
sed -i -E "s/(s\.version *= *')[^']+(')/\1$IO_VER\2/" mindbox_ios/ios/mindbox_ios.podspec
@@ -166,10 +169,18 @@ jobs:
166169
echo " Before Mindbox dependency:" && grep "s.dependency 'Mindbox'," mindbox_ios/ios/mindbox_ios.podspec || true
167170
sed -i -E "s/(s\.dependency 'Mindbox', *')[^']+(')/\1$IO_VER\2/" mindbox_ios/ios/mindbox_ios.podspec
168171
echo " After Mindbox dependency:" && grep "s.dependency 'Mindbox'," mindbox_ios/ios/mindbox_ios.podspec || true
172+
assert_pin mindbox_ios/ios/mindbox_ios.podspec "s\.dependency 'Mindbox', *'$IO_VER'"
169173
170174
echo " Before Notifications dep:" && grep "MindboxNotifications" mindbox_ios/ios/mindbox_ios.podspec || true
171175
sed -i -E "s/(s\.dependency 'MindboxNotifications', *')[^']+(')/\1$IO_VER\2/" mindbox_ios/ios/mindbox_ios.podspec
172176
echo " After Notifications dep:" && grep "MindboxNotifications" mindbox_ios/ios/mindbox_ios.podspec || true
177+
assert_pin mindbox_ios/ios/mindbox_ios.podspec "s\.dependency 'MindboxNotifications', *'$IO_VER'"
178+
179+
echo "→ Bumping ios-sdk exact pin in SPM manifest"
180+
echo " Before:" && grep "mindbox-cloud/ios-sdk" mindbox_ios/ios/mindbox_ios/Package.swift || true
181+
sed -i "/mindbox-cloud\/ios-sdk/ s/exact: \"[^\"]*\"/exact: \"$IO_VER\"/" mindbox_ios/ios/mindbox_ios/Package.swift
182+
echo " After:" && grep "mindbox-cloud/ios-sdk" mindbox_ios/ios/mindbox_ios/Package.swift || true
183+
assert_pin mindbox_ios/ios/mindbox_ios/Package.swift "exact: *\"$IO_VER\""
173184
174185
echo "→ Now inspect pubspec.yaml versions:"
175186
echo " mindbox/pubspec.yaml:" && grep "^version\|mindbox_" mindbox/pubspec.yaml || true
@@ -207,7 +218,8 @@ jobs:
207218
mindbox_ios/pubspec.yaml \
208219
mindbox_platform_interface/pubspec.yaml \
209220
mindbox_android/android/build.gradle \
210-
mindbox_ios/ios/mindbox_ios.podspec
221+
mindbox_ios/ios/mindbox_ios.podspec \
222+
mindbox_ios/ios/mindbox_ios/Package.swift
211223
212224
git commit -m "Bump SDK versions: Flutter=$VERSION, Android=$AND_VER, iOS=$IO_VER"
213225
echo "release_branch=$REL" >> $GITHUB_OUTPUT

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ flow don't need any code changes.
4242

4343
[flutter-uiscene]: https://docs.flutter.dev/release/breaking-changes/uiscenedelegate
4444

45+
### iOS Swift Package Manager
46+
47+
The plugin supports Swift Package Manager alongside CocoaPods. In SPM mode the
48+
main app gets Mindbox automatically; notification extensions need a one-time
49+
Xcode wiring step. See [SPM_MIGRATION.md](SPM_MIGRATION.md). CocoaPods users
50+
need no changes.
51+
4552
## Troubleshooting
4653

4754
Refer to the [Example of integration(IOS)](https://github.com/mindbox-cloud/flutter-sdk/tree/develop/mindbox_ios/example) or [Example of integration(Android)](https://github.com/mindbox-cloud/flutter-sdk/tree/develop/mindbox_android/example) in case of any issues.

SPM_MIGRATION.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Mindbox Flutter SDK with Swift Package Manager
2+
3+
The plugin ships SPM alongside CocoaPods. **Flutter 3.44+ enables SPM by
4+
default** ([flutter#184495][spm-pr]); older releases need
5+
`flutter config --enable-swift-package-manager` (SPM needs Flutter ≥ 3.29; the
6+
per-project `config:` block in `pubspec.yaml` needs ≥ 3.35). The `Runner` gets
7+
`Mindbox` automatically through the plugin — only two Mindbox-specific steps are
8+
manual.
9+
10+
> ⚠️ **Don't load Mindbox through both managers.** On 3.44+ SPM is on by default,
11+
> so leaving `pod 'Mindbox'` in your `Podfile` links Mindbox twice → launch
12+
> crash `Fatal error: ... Expected CDEvent but found CDEvent`. To stay on
13+
> CocoaPods, opt out: `enable-swift-package-manager: false` (pubspec) or
14+
> `flutter config --no-enable-swift-package-manager`.
15+
16+
## 1. Notification extensions
17+
18+
`Runner` project → **Package Dependencies****+**
19+
`https://github.com/mindbox-cloud/ios-sdk`, rule **Up to Next Major** from your
20+
SDK version (e.g. `2.15.1` — a range, not "Exact"). Add the products:
21+
22+
| Product | Add to target |
23+
|---|---|
24+
| `MindboxNotificationsService` | Notification **Service** Extension |
25+
| `MindboxNotificationsContent` | Notification **Content** Extension |
26+
| `Mindbox` | **None**`Runner` already gets it via the plugin |
27+
28+
## 2. Remove the Mindbox pods
29+
30+
Delete `pod 'Mindbox'` (`Runner`) and `pod 'MindboxNotifications'` (each
31+
extension) from the `Podfile`, then `flutter run`. If every plugin you use
32+
supports SPM, drop CocoaPods entirely — delete the `Podfile` and
33+
`pod deintegrate` (see [`example/flutter_example`][example]).
34+
35+
## Notes
36+
37+
- ObjC `MindboxFlutterAppDelegateObjc` is CocoaPods-only and deprecated; SPM
38+
apps use the Swift `MindboxFlutterAppDelegate`.
39+
- Project-level `ios-sdk` and the plugin's copy are the same package (same URL)
40+
→ one resolved version. Keep your range inclusive of the plugin's pin; don't
41+
pin a different "Exact".
42+
43+
[spm-pr]: https://github.com/flutter/flutter/pull/184495
44+
[example]: https://github.com/mindbox-cloud/flutter-sdk/tree/develop/example/flutter_example

example/flutter_example/.gitignore

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ migrate_working_dir/
3333
.pub/
3434
/build/
3535

36+
# Local pub overrides (dev-only, wires example to local packages)
37+
pubspec_overrides.yaml
38+
39+
# Xcode/Flutter SwiftPM workspace dir. Ignore the per-machine scratch
40+
# (configuration/) but COMMIT Package.resolved — this is an app, so its SPM
41+
# lockfile is checked in for reproducible native-SDK resolution.
42+
**/xcshareddata/swiftpm/*
43+
!**/xcshareddata/swiftpm/Package.resolved
44+
3645
# Symbolication related
3746
app.*.symbols
3847

@@ -47,9 +56,5 @@ app.*.map.json
4756
/android/app/google-services.json
4857
/android/app/agconnect-services.json
4958

50-
# iOS
51-
/ios/Pods/
52-
/ios/Podfile.lock
53-
5459
# FVM Version Cache
5560
.fvm/
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
21
#include "Generated.xcconfig"
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
21
#include "Generated.xcconfig"

example/flutter_example/ios/Podfile

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)