feat: Swift Package Manager dependency support for Flutter iOS/macOS SDK#893
feat: Swift Package Manager dependency support for Flutter iOS/macOS SDK#893NandanPrabhu wants to merge 7 commits into
Conversation
WalkthroughThe PR adds Swift Package Manager support for Darwin platforms, removes Ruby setup from CI, patches generated deployment targets, introduces a Swift package manifest, updates Auth0 pod versions, and changes iOS coverage conversion to ChangesSwift Package Manager migration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
3e96372 to
4b4156b
Compare
f535c46 to
873ef63
Compare
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 @.github/actions/setup-darwin/action.yml:
- Around line 70-80: Restrict both deployment-target sed patterns to match only
characters within the version quotes: update the iOS substitution at
.github/actions/setup-darwin/action.yml lines 70-80 to use [^"]* instead of .*,
and make the same change to the macOS substitution at lines 81-91 while
preserving their existing target versions.
In @.github/workflows/main.yml:
- Around line 152-160: Update the Homebrew install command in the “Convert
xcresult to Cobertura coverage” workflow step to install the tap’s unversioned
xcresultparser formula, using the formula name exposed by the tap while
retaining its pinned 2.0.1 metadata.
In `@auth0_flutter/darwin/auth0_flutter/Package.swift`:
- Around line 13-17: Replace the exact dependency constraints in Package.swift
for Auth0.swift, JWTDecode.swift, and SimpleKeychain with .upToNextMajor(from:)
ranges. In auth0_flutter/darwin/auth0_flutter.podspec,
auth0_flutter/ios/auth0_flutter.podspec, and
auth0_flutter/macos/auth0_flutter.podspec, prefix each corresponding CocoaPods
version with ~> while preserving the current version numbers.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 9159c207-221e-4b1e-945e-faba09116c38
⛔ Files ignored due to path filters (15)
auth0_flutter/example/ios/.gitignoreis excluded by!**/example/**auth0_flutter/example/ios/Gemfileis excluded by!**/example/**auth0_flutter/example/ios/Gemfile.lockis excluded by!**/*.lock,!**/example/**,!**/*.lockauth0_flutter/example/ios/Podfileis excluded by!**/example/**auth0_flutter/example/ios/Runner.xcodeproj/project.pbxprojis excluded by!**/example/**auth0_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolvedis excluded by!**/Package.resolved,!**/example/**auth0_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcschemeis excluded by!**/example/**auth0_flutter/example/ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolvedis excluded by!**/Package.resolved,!**/example/**auth0_flutter/example/macos/.gitignoreis excluded by!**/example/**auth0_flutter/example/macos/Podfileis excluded by!**/example/**auth0_flutter/example/macos/Runner.xcodeproj/project.pbxprojis excluded by!**/example/**auth0_flutter/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolvedis excluded by!**/Package.resolved,!**/example/**auth0_flutter/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcschemeis excluded by!**/example/**auth0_flutter/example/macos/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolvedis excluded by!**/Package.resolved,!**/example/**auth0_flutter/example/macos/Runner/AppDelegate.swiftis excluded by!**/example/**
📒 Files selected for processing (12)
.github/actions/setup-darwin/action.yml.github/actions/setup-publish/action.yml.github/workflows/main.yml.gitignoreauth0_flutter/README.mdauth0_flutter/darwin/.gitignoreauth0_flutter/darwin/auth0_flutter.podspecauth0_flutter/darwin/auth0_flutter/Package.swiftauth0_flutter/ios/.gitignoreauth0_flutter/ios/auth0_flutter.podspecauth0_flutter/macos/.gitignoreauth0_flutter/macos/auth0_flutter.podspec
Relocates auth0_flutter/darwin/Classes/*.swift into auth0_flutter/darwin/auth0_flutter/Sources/auth0_flutter/, turning the old Classes/ location (and the ios/ and macos/ CocoaPods dirs) into symlinks generated by scripts/generate-symlinks.sh. This gives CocoaPods and a future SPM target a single canonical source location instead of duplicated/symlinked per-platform trees. Also renames SwiftAuth0FlutterPlugin -> Auth0FlutterPlugin and drops the Objective-C shim (Auth0FlutterPlugin.h/.m), since the class name can now match the pluginClass declared in pubspec.yaml directly without an ObjC bridge. Pure move: every relocated file is byte-identical to its previous location.
…rename Dropping the ObjC shim (Auth0FlutterPlugin.h/.m) in the previous commit removed the only source of a transitive Flutter import for Swift test files: main's Auth0FlutterPlugin.h did `#import <Flutter/Flutter.h>`, which the umbrella header re-exported to any `@testable import auth0_flutter` consumer. Without it, 18 test files that use FlutterError/UIModalPresentationStyle without importing Flutter/UIKit directly fail to compile. Adds the explicit imports, verified by a full xcodebuild test run on both iOS and macOS. Also fixes the macOS Xcode project, which still referenced the pre-rename SwiftAuth0FlutterPluginTests.swift filename after the test file was renamed to Auth0FlutterPluginTests.swift — this broke the macOS test target build (the iOS project was already fixed in the previous commit).
main added MfaAPI test files that use FlutterError without importing Flutter directly, relying on the transitive import that Auth0FlutterPlugin.h's #import <Flutter/Flutter.h> used to provide. That header was removed when this branch dropped the ObjC shim, so these 7 files (added by main after this branch was cut) need the same explicit Flutter/FlutterMacOS import already applied to the other test files in a previous commit. Verified with a full xcodebuild test run on both iOS (361 tests) and macOS.
873ef63 to
9b6cc63
Compare
Declares an SPM target for auth0_flutter (auth0_flutter/darwin/auth0_flutter/Package.swift) alongside the existing CocoaPods podspecs, pinning Auth0.swift, JWTDecode.swift, and SimpleKeychain to the same versions the podspecs already depend on. PASSKEYS_PLATFORM is set via swiftSettings so passkey source files compile under SPM the same way the podspec's SWIFT_ACTIVE_COMPILATION_CONDITIONS does for CocoaPods. CocoaPods remains a fully supported fallback: consumers who haven't run `flutter config --enable-swift-package-manager` see no change.
df00f11 to
ba12521
Compare
- setup-darwin: runs `flutter config --enable-swift-package-manager` before `flutter pub get` so Flutter resolves the plugin via SPM, then patches the generated FlutterGeneratedPluginSwiftPackage/Package.swift deployment targets to 14.0 (iOS) / 11.0 (macOS) — Flutter's default targets are lower than this plugin's minimum and would otherwise fail to build. - setup-publish: also enables SPM so `flutter pub get` during publishing resolves the same way local/CI builds do. - main.yml: removes the Ruby setup step and `env.ruby`, no longer needed now that iOS coverage is converted from .xcresult to Cobertura XML via xcresultparser (pinned to 2.0.1) instead of `bundle exec slather`.
- Podfiles: remove use_modular_headers! and the RunnerUITests pod target now that the plugin builds under SPM; RunnerUITests keeps its Xcode target but no longer needs a CocoaPods target of its own. - Adds the generated Package.resolved and xcscheme files SPM produces when resolving the plugin, and pbxproj entries for the SwiftPM package reference/product dependency. - macOS AppDelegate: switches @NSApplicationMain to @main and adds applicationSupportsSecureRestorableState, matching current Xcode/macOS expectations for AppKit lifecycle and state restoration. - Removes example/ios/Gemfile(.lock) — only used by slather, which CI no longer runs. - Adds *.xcresult/ to the example iOS/macOS .gitignore for the test result bundles xcodebuild now produces.
- DEVELOPMENT_TEAM was accidentally baked into the iOS pbxproj as a personal Apple Developer Team ID (79ZXKC573P) instead of the empty string main uses, after regenerating the project locally. Reverted to "" so CI and other contributors aren't stuck with someone else's signing team. - enableGPUValidationMode="1" in the macOS Runner scheme was an Xcode-inserted local debug preference, unrelated to SPM. Dropped.
ba12521 to
4b98b74
Compare
9b6cc63 to
744fa89
Compare
📋 Changes
Replaces #804, split into a cascading pair of PRs so the pure file-move (#894) can be reviewed separately from the actual SPM work. Stacked on #894 — this PR's diff is scoped to just the SPM-specific delta; once #894 merges into
main, this PR will retarget tomainautomatically and the diff will shrink to what's shown below.Adds Swift Package Manager (SPM) support to the iOS/macOS (
darwin) native plugin, addressing #793. CocoaPods support is retained as a fallback, so this is non-breaking for existing consumers.SPM packaging
auth0_flutter/darwin/auth0_flutter/Package.swiftdeclaring theauth0_flutterSPM target (iOS 14 / macOS 11), depending on Auth0.swift 2.24.1, JWTDecode.swift 3.3.0, and SimpleKeychain 1.3.0 — the same versions already pinned in the three podspecs.PASSKEYS_PLATFORMSwift compilation condition is set viaswiftSettingsinPackage.swift, mirroring the podspecs'SWIFT_ACTIVE_COMPILATION_CONDITIONS.pubspec.yaml'ssharedDarwinSource: true(already onmain) is what tells Flutter to resolve iOS/macOS from the singleSources/auth0_flutter/tree that refactor: Move darwin native sources into a canonical Sources/ tree #894 establishes.Test/source SPM-compatibility fixes
Flutter/UIKitimports to test files andWebAuthModels.swiftthat useFlutterError/UIModalPresentationStylewithout importing them directly — needed under SPM, where these types aren't transitively visible from@testable import auth0_flutterthe way CocoaPods' module map provides them.NSKeyedArchiverpayloads tocredentialsManager.store(credentials:), exercising the real storage path instead of duplicating its serialization format in test code.CI
setup-darwin: enables SPM (flutter config --enable-swift-package-manager) beforeflutter pub get, then patches the Flutter-generatedFlutterGeneratedPluginSwiftPackage/Package.swiftdeployment targets to 14.0 (iOS) / 11.0 (macOS) since Flutter's defaults are lower than this plugin's minimum.setup-publish: also enables SPM so publish-timeflutter pub getresolves consistently.slathertoolchain from CI; iOS coverage is now.xcresult→ Cobertura XML viaxcresultparser(pinned to2.0.1) uploaded to Codecov.example/ios/Gemfile(.lock).Example app
use_modular_headers!and theRunnerUITestsCocoaPods target (no longer needed once the plugin builds under SPM);RunnerUITestskeeps its Xcode target.AppDelegate:@NSApplicationMain→@main, addsapplicationSupportsSecureRestorableStatefor current Xcode/macOS AppKit expectations.Package.resolved/.xcschemefiles and pbxproj SPM package-reference entries produced by resolving the plugin via SPM.📎 References
Review feedback from #804 addressed here
Podspec version (2.1.0) lagging pubspec.yaml (2.2.0)— versions now tracked consistently; podspecs pin Auth0.swift 2.24.1 to matchPackage.swift.Case-sensitive— bothinputs.platformcomparison insetup-darwinskips the deployment-target patch for lowercaseios/macosFix … deployment target for SPMsteps now gate on the normalizedsteps.lowercase-platform.outputs.platform.generate-symlinks.sh../depth miscalculation leaving ~185 dangling symlinks~~ — the symlink-generation logic itself is now owned by refactor: Move darwin native sources into a canonical Sources/ tree #894 (the move PR), which includes a post-generation resolution check.— the ObjC shim removal is now owned by refactor: Move darwin native sources into a canonical Sources/ tree #894; this PR's podspec only globspublic_header_files/.{h,m}glob entries pointing at a nonexistentinclude/dir**/*.swift.— pinned toxcresultparserinstalled unpinned from a third-party tapa7ex/homebrew-formulae/xcresultparser@2.0.1.Uncommented— reverted; stays commented out..envpubspec asset turning a missing.envinto a hard build failureSPM— both now pin Auth0.swift.upToNextMajorvs. podspecs' exact pin could drift2.24.1exactly.Found while re-splitting the diff
AppDelegate.swifthad lostimport Auth0and theapplication(_:open:options:)override callingWebAuthentication.resume(with: url)— without it, the OAuth redirect callback wouldn't complete login. Restored to matchmain.example/ios/Podfile's commented# platform :ios, '13.0'didn't match the actual14.0deployment target set in the Xcode project; corrected the comment to14.0.🎯 Testing
xcodebuildagainstRunner.xcworkspace(Xcode 26.2); Android and Windows unit suites unchanged.pod ipc specandswift package dump-packageboth validate cleanly against the updated podspecs/Package.swift.auth0_flutter/example, runflutter config --enable-swift-package-managerthenflutter runon an iOS simulator or device; exercise login/logout, credentials manager, and DPoP flows.flutter config --no-enable-swift-package-managerand building the example app.