feat: Swift Package Manager dependency support for Flutter iOS/macOS SDK#804
feat: Swift Package Manager dependency support for Flutter iOS/macOS SDK#804NandanPrabhu wants to merge 16 commits into
Conversation
29e7c3d to
4128680
Compare
fd7f369 to
d3b8c46
Compare
d3b8c46 to
035c772
Compare
✅ Action performedFull review finished. |
✅ Action performedFull review finished. |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
| ../../../darwin/Classes/MethodHandler.swift |
There was a problem hiding this comment.
I would revert all the path-related changes across all files. There are a lot of them, and I'd remove those changes from this PR.
There was a problem hiding this comment.
The path/symlink restructuring is required for this PR: SPM needs a single canonical source tree (darwin/auth0_flutter/Sources/auth0_flutter/), and CocoaPods (ios/, macos/, darwin/Classes/) needs to keep working off the same files without duplication, so the symlinks are what let both dependency managers point at one source of truth. What you were hitting was a real bug though — scripts/generate-symlinks.sh miscalculated the ../ depth and left ~185 symlinks dangling across darwin/ios/macos. That's fixed in 4dc9e76: the depth is now computed relative to Classes/ instead of the full repo path, and I re-ran the script and verified every symlink resolves (0 dangling). I also added a post-generation check to the script itself so this can't silently regress again. Given the alternative (duplicating ~60 Swift files three times, or dropping CocoaPods support entirely) I'd like to keep the symlink approach — let me know if you still see broken links after pulling 4dc9e76.
| @@ -1 +1 @@ | |||
| ../../../darwin/Classes/MyAccountAPI/MyAccountEnrollPasskeyMethodHandler.swift No newline at end of file | |||
| ../../../../darwin/Classes/MyAccountAPI/MyAccountEnrollPasskeyMethodHandler.swift No newline at end of file | |||
There was a problem hiding this comment.
Could we also verify if these symlink changes are intended. it seems to be broken currently as per my testing
There was a problem hiding this comment.
Confirmed intended and now verified working — this was the same depth-calculation bug reported by @utkrishtsahu on scripts/generate-symlinks.sh, fixed in 4dc9e76. I re-ran scripts/generate-symlinks.sh against current main-rebased HEAD and confirmed 0 dangling symlinks across darwin/Classes/, ios/Classes/, and macos/Classes/ (including this file). Could you re-pull and re-test? If it's still broken for you I'd like to see the specific symlink/error so I can repro.
flutter config --enable-swift-package-manager must run after Flutter is installed and before flutter pub get so that SPM-based dependencies (Auth0.swift resolved via Package.swift) are properly set up when building and running native iOS/macOS unit tests.
The FlutterGeneratedPluginSwiftPackage (created during flutter pub get) picks up the iOS deployment target from the Xcode toolchain. When Xcode was configured after pub get, the generated Package.swift defaulted to iOS 13.0 instead of reading the project's IPHONEOS_DEPLOYMENT_TARGET of 14.0, causing: error: The package product 'auth0-flutter' requires minimum platform version 14.0 for the iOS platform, but this target supports 13.0 Fix: move "Setup Xcode" and "Save Xcode version" steps before "Enable Swift Package Manager" and "flutter pub get".
- Restores darwin/Classes/ with ObjC stubs (Auth0FlutterPlugin.h/.m), SwiftAuth0FlutterPlugin.swift, and symlinks for all Swift source files pointing to darwin/auth0_flutter/Sources/auth0_flutter/ - Restores ios/ and macos/ top-level: .gitignore, Assets/.gitkeep (symlink), and auth0_flutter.podspec (Classes/**/* source_files, v2.2.0, Auth0 2.21.2, PASSKEYS_PLATFORM xcconfig) - Restores ios/Classes/ and macos/Classes/ symlinks for all source files pointing through darwin/Classes/ - All darwin/ios/macos files now match main branch structure
Auth0FlutterPlugin.swift is the SPM entry point and belongs only in darwin/auth0_flutter/Sources/auth0_flutter/. CocoaPods uses SwiftAuth0FlutterPlugin.swift instead.
- Updates Package.swift to require Auth0.swift >= 2.21.2 (adds updateAuthenticationMethod and other newer APIs used by source files) - Adds PASSKEYS_PLATFORM Swift define to SPM target so passkey source files and test assertions compile correctly under SPM - Adds explicit Flutter import (#if os(iOS)) to 15 test files that use FlutterError without importing Flutter — needed under SPM where types are not transitively available from @testable import auth0_flutter - Updates unit-tests-darwin action to use -workspace (includes Pods.xcodeproj so Pods_Runner.framework is built as part of the test build) - Updates Package.resolved to pin Auth0.swift 2.22.0 for iOS and macOS - Updates Xcode project files to reflect pod install with SPM enabled
…x CI sed replacement
- Bump auth0_flutter SPM package to .upToNextMajor(from: "2.21.2") since useDPoP()
and updateAuthenticationMethod() require 2.21.2+
- Add swiftSettings: [.define("PASSKEYS_PLATFORM")] so passkey types compile under SPM
- Fix sed replacement in setup-darwin action: remove escaped dot in replacement string
to prevent generating invalid Package.swift with \.iOS/\.macOS syntax
- Fixes broken darwin/ios/macos symlinks in generate-symlinks.sh: depth was computed from the full repo-relative path instead of the path relative to Classes/, producing one extra "../" and leaving 185 symlinks dangling - Adds a post-generation check that verifies every symlink resolves - Normalizes platform comparison in setup-darwin/action.yml to use the lowercased step output, avoiding a case-sensitivity mismatch - Trims darwin/auth0_flutter.podspec source_files/public_header_files to Swift-only, since the ObjC shim (.h/.m) no longer exists - Pins xcresultparser to 2.0.1 in CI instead of installing latest - Relaxes Auth0.swift pin in all three podspecs to '~> 2.21' to match Package.swift's .upToNextMajor(from: "2.21.2") - Reverts the .env pubspec asset to commented-out, since it turns a missing .env into a hard build failure for contributors
- Package.swift now uses exact: "2.22.0" instead of .upToNextMajor(from: "2.21.2") - All three podspecs now pin '2.22.0' exactly instead of '~> 2.21' - Matches the version already locked in the checked-in Package.resolved files under example/ios and example/macos, so SPM and CocoaPods consumers resolve to the same Auth0.swift release
- Package.swift and all three podspecs now pin exact: "2.24.1" - Updates the checked-in Package.resolved files under example/ios and example/macos to the matching revision so SPM resolves without re-fetching
📋 Changes
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.21.2, JWTDecode.swift 3.3.0, and SimpleKeychain 1.3.0.sharedDarwinSource: trueinpubspec.yamlso Flutter resolves iOS and macOS from a single source tree underdarwin/auth0_flutter/Sources/auth0_flutter/.PASSKEYS_PLATFORMSwift compilation condition viaswiftSettingsinPackage.swift(previously only provided by the CocoaPods podspec).CocoaPods fallback (retained)
auth0_flutter/darwin/auth0_flutter.podspecupdated to pointsource_filesatSources/auth0_flutter/— the canonical location shared with SPM.ios/andmacos/podspecs kept for CocoaPods consumers; theirClasses/directories contain symlinks intodarwin/Classes/, which in turn symlink toSources/auth0_flutter/.scripts/generate-symlinks.shscript regenerates the full symlink chain (darwin/Classes/ → Sources/,ios/Classes/ → darwin/Classes/,macos/Classes/ → darwin/Classes/) and is enforced by theSymlinksCI job on every PR.Plugin entry point
Auth0FlutterPlugin.h/.m) and renamesSwiftAuth0FlutterPlugin→Auth0FlutterPluginto match thepluginClassdeclared inpubspec.yaml. No public Dart API change.CI
setup-darwin: sets up Xcode beforeflutter pub get, enables SPM (flutter config --enable-swift-package-manager), caches and installs CocoaPods, then patches the Flutter-generatedFlutterGeneratedPluginSwiftPackage/Package.swiftdeployment targets to 14.0 (iOS) / 11.0 (macOS).unit-tests-darwin: runsxcodebuild testagainstRunner.xcworkspace(CocoaPods workspace, which includes the SPM-resolved plugin)..xcresultto Cobertura XML viaxcresultparserbefore the Codecov upload..github/workflows/check-symlinks.ymlCI job that runsscripts/generate-symlinks.shand fails if any symlink is out of sync.Tests
Auth0FlutterPluginTests.credentialsManager.store(credentials:)instead of hand-builtNSKeyedArchiverfixtures.📎 References
🎯 Testing
xcodebuildagainstRunner.xcworkspace(Xcode 26.2); Android and Windows unit suites unchanged.SymlinksCI job validates thatdarwin/Classes/,ios/Classes/, andmacos/Classes/symlinks are consistent withSources/auth0_flutter/on every PR.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.