Skip to content

feat: Swift Package Manager dependency support for Flutter iOS/macOS SDK#893

Open
NandanPrabhu wants to merge 7 commits into
mainfrom
feat/flutter-swift-package-manager
Open

feat: Swift Package Manager dependency support for Flutter iOS/macOS SDK#893
NandanPrabhu wants to merge 7 commits into
mainfrom
feat/flutter-swift-package-manager

Conversation

@NandanPrabhu

@NandanPrabhu NandanPrabhu commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

📋 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 to main automatically 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

  • Adds auth0_flutter/darwin/auth0_flutter/Package.swift declaring the auth0_flutter SPM 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_PLATFORM Swift compilation condition is set via swiftSettings in Package.swift, mirroring the podspecs' SWIFT_ACTIVE_COMPILATION_CONDITIONS.
  • pubspec.yaml's sharedDarwinSource: true (already on main) is what tells Flutter to resolve iOS/macOS from the single Sources/auth0_flutter/ tree that refactor: Move darwin native sources into a canonical Sources/ tree #894 establishes.

Test/source SPM-compatibility fixes

  • Adds explicit Flutter/UIKit imports to test files and WebAuthModels.swift that use FlutterError/UIModalPresentationStyle without importing them directly — needed under SPM, where these types aren't transitively visible from @testable import auth0_flutter the way CocoaPods' module map provides them.
  • Switches CredentialsManager test fixtures from hand-built NSKeyedArchiver payloads to credentialsManager.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) before flutter pub get, then patches the Flutter-generated FlutterGeneratedPluginSwiftPackage/Package.swift deployment 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-time flutter pub get resolves consistently.
  • Drops the Ruby/slather toolchain from CI; iOS coverage is now .xcresult → Cobertura XML via xcresultparser (pinned to 2.0.1) uploaded to Codecov.
  • Removes the now-unused example/ios/Gemfile(.lock).

Example app

  • Podfiles: drop use_modular_headers! and the RunnerUITests CocoaPods target (no longer needed once the plugin builds under SPM); RunnerUITests keeps its Xcode target.
  • macOS AppDelegate: @NSApplicationMain@main, adds applicationSupportsSecureRestorableState for current Xcode/macOS AppKit expectations.
  • Adds the generated Package.resolved/.xcscheme files 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 match Package.swift.
  • Case-sensitive inputs.platform comparison in setup-darwin skips the deployment-target patch for lowercase ios/macos — both Fix … deployment target for SPM steps now gate on the normalized steps.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.
  • public_header_files/.{h,m} glob entries pointing at a nonexistent include/ dir — the ObjC shim removal is now owned by refactor: Move darwin native sources into a canonical Sources/ tree #894; this PR's podspec only globs **/*.swift.
  • xcresultparser installed unpinned from a third-party tap — pinned to a7ex/homebrew-formulae/xcresultparser@2.0.1.
  • Uncommented .env pubspec asset turning a missing .env into a hard build failure — reverted; stays commented out.
  • SPM .upToNextMajor vs. podspecs' exact pin could drift — both now pin Auth0.swift 2.24.1 exactly.

Found while re-splitting the diff

  • The example iOS AppDelegate.swift had lost import Auth0 and the application(_:open:options:) override calling WebAuthentication.resume(with: url) — without it, the OAuth redirect callback wouldn't complete login. Restored to match main.
  • example/ios/Podfile's commented # platform :ios, '13.0' didn't match the actual 14.0 deployment target set in the Xcode project; corrected the comment to 14.0.

🎯 Testing

  • iOS and macOS native unit tests pass in CI via xcodebuild against Runner.xcworkspace (Xcode 26.2); Android and Windows unit suites unchanged.
  • pod ipc spec and swift package dump-package both validate cleanly against the updated podspecs/Package.swift.
  • Manual verification: from auth0_flutter/example, run flutter config --enable-swift-package-manager then flutter run on an iOS simulator or device; exercise login/logout, credentials manager, and DPoP flows.
  • CocoaPods fallback can be verified by running flutter config --no-enable-swift-package-manager and building the example app.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The 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 xcresultparser.

Changes

Swift Package Manager migration

Layer / File(s) Summary
Package and dependency contracts
.gitignore, auth0_flutter/README.md, auth0_flutter/{darwin,ios,macos}/...
Adds the Swift package manifest, documents SPM and CocoaPods resolution, updates Auth0 dependencies to 2.24.1, and ignores generated SPM artifacts.
Darwin SPM setup
.github/actions/setup-darwin/action.yml, .github/actions/setup-publish/action.yml
Removes Ruby setup, enables Swift Package Manager, fetches Flutter dependencies, and patches generated iOS/macOS package deployment targets.
Workflow and coverage migration
.github/workflows/main.yml
Removes Ruby inputs and replaces Slather coverage conversion with xcresultparser Cobertura output.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: utkrishtsahu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding Swift Package Manager support for the Flutter iOS/macOS SDK.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/flutter-swift-package-manager

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread auth0_flutter/example/ios/Runner.xcodeproj/project.pbxproj Outdated
Comment thread auth0_flutter/darwin/auth0_flutter/Package.swift
Comment thread .github/workflows/main.yml
@NandanPrabhu

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 873ef63 and 4b4156b.

⛔ Files ignored due to path filters (15)
  • auth0_flutter/example/ios/.gitignore is excluded by !**/example/**
  • auth0_flutter/example/ios/Gemfile is excluded by !**/example/**
  • auth0_flutter/example/ios/Gemfile.lock is excluded by !**/*.lock, !**/example/**, !**/*.lock
  • auth0_flutter/example/ios/Podfile is excluded by !**/example/**
  • auth0_flutter/example/ios/Runner.xcodeproj/project.pbxproj is excluded by !**/example/**
  • auth0_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved is excluded by !**/Package.resolved, !**/example/**
  • auth0_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme is excluded by !**/example/**
  • auth0_flutter/example/ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved is excluded by !**/Package.resolved, !**/example/**
  • auth0_flutter/example/macos/.gitignore is excluded by !**/example/**
  • auth0_flutter/example/macos/Podfile is excluded by !**/example/**
  • auth0_flutter/example/macos/Runner.xcodeproj/project.pbxproj is excluded by !**/example/**
  • auth0_flutter/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved is excluded by !**/Package.resolved, !**/example/**
  • auth0_flutter/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme is excluded by !**/example/**
  • auth0_flutter/example/macos/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved is excluded by !**/Package.resolved, !**/example/**
  • auth0_flutter/example/macos/Runner/AppDelegate.swift is excluded by !**/example/**
📒 Files selected for processing (12)
  • .github/actions/setup-darwin/action.yml
  • .github/actions/setup-publish/action.yml
  • .github/workflows/main.yml
  • .gitignore
  • auth0_flutter/README.md
  • auth0_flutter/darwin/.gitignore
  • auth0_flutter/darwin/auth0_flutter.podspec
  • auth0_flutter/darwin/auth0_flutter/Package.swift
  • auth0_flutter/ios/.gitignore
  • auth0_flutter/ios/auth0_flutter.podspec
  • auth0_flutter/macos/.gitignore
  • auth0_flutter/macos/auth0_flutter.podspec

Comment thread .github/actions/setup-darwin/action.yml
Comment thread .github/workflows/main.yml
Comment thread auth0_flutter/darwin/auth0_flutter/Package.swift
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.
@NandanPrabhu NandanPrabhu force-pushed the refactor/move-darwin-sources-to-shared-tree branch from 873ef63 to 9b6cc63 Compare July 14, 2026 13:19
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.
- 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.
@NandanPrabhu NandanPrabhu force-pushed the feat/flutter-swift-package-manager branch from ba12521 to 4b98b74 Compare July 14, 2026 14:40
@NandanPrabhu NandanPrabhu force-pushed the refactor/move-darwin-sources-to-shared-tree branch from 9b6cc63 to 744fa89 Compare July 14, 2026 14:43
Base automatically changed from refactor/move-darwin-sources-to-shared-tree to main July 14, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Swift Package Manager support

2 participants