diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 1e9a132..06aeb0d 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -60,3 +60,43 @@ jobs: - name: Build (verify) working-directory: example run: flutter build apk --debug + + # The iOS plugin is built two ways: through its Swift package (Flutter's default + # since 3.44), and through the podspec, which apps with Swift Package Manager + # support turned off still use. Both point at the same sources and the same + # native SDK version, and either can drift on its own. + ios: + if: github.event.pull_request.draft == false + runs-on: macos-latest + strategy: + fail-fast: false + matrix: + swift-package-manager: ['true', 'false'] + + steps: + - uses: actions/checkout@v4 + + - uses: subosito/flutter-action@v2 + with: + flutter-version: '3.44.0' + channel: 'stable' + + # CocoaPods trunk is read-only, so an app building plugins through CocoaPods + # adds the native pod from its repository, as README.md tells it to. The + # example's Podfile cannot keep that line: with Swift Package Manager on it + # would link the SDK a second time. + - name: Take the native pod from its repository + if: matrix.swift-package-manager == 'false' + working-directory: example/ios + run: | + version=$(sed -n "s/^ *s.dependency 'REES46', '\(.*\)'$/\1/p" ../../ios/rees46_sdk.podspec) + line=" pod 'REES46', :git => 'https://github.com/rees46/ios-sdk.git', :tag => 'v$version'" + awk -v line="$line" '{ print } /^target .Runner. do/ { print line }' Podfile > Podfile.new + mv Podfile.new Podfile + grep -n "pod 'REES46'" Podfile + + - name: Build the example for the simulator + working-directory: example + env: + FLUTTER_SWIFT_PACKAGE_MANAGER: ${{ matrix.swift-package-manager }} + run: flutter build ios --simulator --debug diff --git a/README.md b/README.md index b46724b..18c2a23 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ import 'package:rees46_sdk/rees46_sdk.dart'; ``` The native dependencies come with it — `com.github.rees46:android-sdk` from -JitPack and the `REES46` pod from CocoaPods trunk. +JitPack and the [iOS SDK](https://github.com/rees46/ios-sdk) through Swift Package +Manager or CocoaPods. ### Android @@ -50,9 +51,27 @@ maven(url = "https://jitpack.io") ### iOS -Nothing to add: the plugin's podspec pulls the `REES46` pod and declares the -iOS 13.0 minimum itself, `pod install` runs as part of `flutter run`, and the -plugin registers its own application delegate — your `AppDelegate` stays untouched. +The plugin declares the iOS 13.0 minimum itself and registers its own application +delegate — your `AppDelegate` stays untouched. + +**With Swift Package Manager** — the default since Flutter 3.44, and on earlier +versions after `flutter config --enable-swift-package-manager` — there is nothing to +add: the plugin's package pulls the native SDK. + +**With CocoaPods** (Swift Package Manager support turned off, or Flutter older than +3.44 without the setting above) add the native pod to `ios/Podfile`, inside +`target 'Runner'`. CocoaPods trunk is +read-only since 2 December 2026, so the pod is taken straight from its repository. +The tag is the version the plugin requires — the `REES46` dependency in +[`ios/rees46_sdk.podspec`](ios/rees46_sdk.podspec): + +```ruby +pod 'REES46', :git => 'https://github.com/rees46/ios-sdk.git', :tag => 'v3.36.1' +``` + +`pod install` then runs as part of `flutter run`. Update the tag together with the +plugin, and drop the line once Swift Package Manager support is on — the plugin's +package brings the SDK then, and keeping the pod would link it twice. ## Initialize diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 1b01487..f48e06f 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,59 +1,29 @@ PODS: - CocoaAsyncSocket (7.6.5) - Flutter (1.0.0) - - integration_test (0.0.1): - - Flutter - patrol (0.0.1): - CocoaAsyncSocket (~> 7.6) - Flutter - FlutterMacOS - - REES46 (3.35.0) - - rees46_sdk (0.0.1): - - Flutter - - REES46 (= 3.35.0) - - shared_preferences_foundation (0.0.1): - - Flutter - - FlutterMacOS - - video_player_avfoundation (0.0.1): - - Flutter - - FlutterMacOS DEPENDENCIES: - Flutter (from `Flutter`) - - integration_test (from `.symlinks/plugins/integration_test/ios`) - patrol (from `.symlinks/plugins/patrol/darwin`) - - rees46_sdk (from `.symlinks/plugins/rees46_sdk/ios`) - - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`) SPEC REPOS: trunk: - CocoaAsyncSocket - - REES46 EXTERNAL SOURCES: Flutter: :path: Flutter - integration_test: - :path: ".symlinks/plugins/integration_test/ios" patrol: :path: ".symlinks/plugins/patrol/darwin" - rees46_sdk: - :path: ".symlinks/plugins/rees46_sdk/ios" - shared_preferences_foundation: - :path: ".symlinks/plugins/shared_preferences_foundation/darwin" - video_player_avfoundation: - :path: ".symlinks/plugins/video_player_avfoundation/darwin" SPEC CHECKSUMS: CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 - integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e patrol: cea8074f183a2a4232d0ebd10569ae05149ada42 - REES46: a96357df1dbbef9a73d92961069290702334136d - rees46_sdk: 312ba7a8088eb9cd0f5476ae3d6dd9b45c46b8c4 - shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb - video_player_avfoundation: 3453f792138786248960ca029747fcd9f318ef52 PODFILE CHECKSUM: b6e248ac4c1eff5807c8b044b39b8bc326af3f5f diff --git a/ios/.gitignore b/ios/.gitignore index 034771f..e7a7b08 100644 --- a/ios/.gitignore +++ b/ios/.gitignore @@ -36,3 +36,7 @@ Icon? /Flutter/Generated.xcconfig /Flutter/ephemeral/ /Flutter/flutter_export_environment.sh + +# Swift Package Manager +.build/ +.swiftpm/ diff --git a/ios/Assets/.gitkeep b/ios/Assets/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/ios/rees46_sdk.podspec b/ios/rees46_sdk.podspec index 01211c0..296010d 100644 --- a/ios/rees46_sdk.podspec +++ b/ios/rees46_sdk.podspec @@ -12,9 +12,15 @@ Flutter plugin wrapper around REES46 native SDK. s.license = { :file => '../LICENSE' } s.author = { 'REES46' => 'support@rees46.com' } s.source = { :path => '.' } - s.source_files = 'Classes/**/*' + # The sources live where Swift Package Manager expects them (rees46_sdk/Package.swift); + # CocoaPods builds the same files. + s.source_files = 'rees46_sdk/Sources/rees46_sdk/**/*.swift' + s.resource_bundles = {'rees46_sdk_privacy' => ['rees46_sdk/Sources/rees46_sdk/PrivacyInfo.xcprivacy']} s.dependency 'Flutter' - s.dependency 'REES46', '3.35.0' + # Keep in step with the dependency in rees46_sdk/Package.swift. CocoaPods trunk is + # read-only, so a version newer than the last one there resolves only through the + # app's Podfile (see "iOS" in README.md). + s.dependency 'REES46', '3.36.1' s.platform = :ios, '13.0' # Flutter.framework does not contain a i386 slice. diff --git a/ios/rees46_sdk/Package.swift b/ios/rees46_sdk/Package.swift new file mode 100644 index 0000000..ae48507 --- /dev/null +++ b/ios/rees46_sdk/Package.swift @@ -0,0 +1,29 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "rees46_sdk", + platforms: [ + .iOS("13.0") + ], + products: [ + .library(name: "rees46-sdk", targets: ["rees46_sdk"]) + ], + dependencies: [ + // Keep in step with the dependency in ../rees46_sdk.podspec. + .package(url: "https://github.com/rees46/ios-sdk.git", exact: "3.36.1") + ], + targets: [ + .target( + name: "rees46_sdk", + dependencies: [ + .product(name: "REES46", package: "ios-sdk") + ], + resources: [ + .process("PrivacyInfo.xcprivacy") + ] + ) + ] +) diff --git a/ios/Resources/PrivacyInfo.xcprivacy b/ios/rees46_sdk/Sources/rees46_sdk/PrivacyInfo.xcprivacy similarity index 100% rename from ios/Resources/PrivacyInfo.xcprivacy rename to ios/rees46_sdk/Sources/rees46_sdk/PrivacyInfo.xcprivacy diff --git a/ios/Classes/Rees46FlutterSdkPlugin.swift b/ios/rees46_sdk/Sources/rees46_sdk/Rees46FlutterSdkPlugin.swift similarity index 100% rename from ios/Classes/Rees46FlutterSdkPlugin.swift rename to ios/rees46_sdk/Sources/rees46_sdk/Rees46FlutterSdkPlugin.swift diff --git a/ios/Classes/StoriesSupport.swift b/ios/rees46_sdk/Sources/rees46_sdk/StoriesSupport.swift similarity index 100% rename from ios/Classes/StoriesSupport.swift rename to ios/rees46_sdk/Sources/rees46_sdk/StoriesSupport.swift diff --git a/ios/Classes/pigeon/PersonalizationApi.g.swift b/ios/rees46_sdk/Sources/rees46_sdk/pigeon/PersonalizationApi.g.swift similarity index 100% rename from ios/Classes/pigeon/PersonalizationApi.g.swift rename to ios/rees46_sdk/Sources/rees46_sdk/pigeon/PersonalizationApi.g.swift diff --git a/pigeons/personalization_api.dart b/pigeons/personalization_api.dart index 45adef9..ac51e20 100644 --- a/pigeons/personalization_api.dart +++ b/pigeons/personalization_api.dart @@ -12,7 +12,8 @@ import 'package:pigeon/pigeon.dart'; kotlinOptions: KotlinOptions( package: 'com.rees46.rees46_flutter_sdk.pigeon', ), - swiftOut: 'ios/Classes/pigeon/PersonalizationApi.g.swift', + swiftOut: + 'ios/rees46_sdk/Sources/rees46_sdk/pigeon/PersonalizationApi.g.swift', ), ) class InitConfig {