feat: add iOS Swift Package Manager support#20
Conversation
…retrieval - Updated podspec version to 3.0.0 and improved summary and description. - Added Package.swift for Swift Package Manager support. - Implemented FkUserAgentPlugin in Objective-C to retrieve device user agents. - Enhanced user agent retrieval logic to include WebView user agents. - Updated Dart API to support async property fetching and improved initialization logic. - Updated pubspec.yaml and pubspec.lock for Dart SDK and Flutter version compatibility. - Added comprehensive tests for user agent properties and initialization behavior.
qMalte
left a comment
There was a problem hiding this comment.
Security review notes
Thanks for the SwiftPM migration — the actual plugin logic (ObjC + Dart) is unchanged and looks clean, and switching pubspec.lock to pub.dev with sha256 integrity hashes is a nice improvement. A few generated/ephemeral files got committed that should be removed before merging/publishing:
🟠 Medium — firebase-debug.log committed (information leak)
This file exposes internal details: a developer email (melih.celik@hubx.co), OAuth token validity/expiry timestamps, and internal Google/MCP endpoints. The token value itself is not present, so it's metadata rather than a live credential, but it doesn't belong in the repo. Please remove it and add firebase-debug.log to .gitignore (it's in .pubignore but will still persist in git history).
🟡 Low — Local paths / environment files committed
example/ios/Flutter/ephemeral/flutter_native_integration.envcontains absolute local paths (/Users/melihcelik/Desktop/...). TheDART_DEFINESbase64 decodes to harmless Flutter build metadata (version/channel), so no secrets — but the wholeexample/ios/Flutter/ephemeral/folder is generated and shouldn't be checked in..idea/libraries/Dart_SDK.xml.bakis a stray backup file with local SDK paths and should be dropped.example/ios/Flutter/ephemeral/flutter_lldb_helper.pyis Flutter-generated LLDB tooling (writes to process memory only under the debugger on debug builds) — not malicious, but also ephemeral and shouldn't be committed.
Suggestion: remove these files from the PR and add the patterns to .gitignore (not just .pubignore) so they don't reappear.
- Remove firebase-debug.log (contained developer email and OAuth metadata)
- Remove .idea/libraries/Dart_SDK.xml.bak (stray backup with local SDK paths)
- Remove example/ios/Flutter/ephemeral/ entirely:
flutter_native_integration.env (absolute local paths in DART_DEFINES)
flutter_lldb_helper.py (Flutter-generated LLDB tooling)
flutter_lldbinit (LLDB init file)
Packages/FlutterGeneratedPluginSwiftPackage/* (generated SwiftPM package)
- Add firebase-debug.log, *.bak, .idea/, and
example/ios/Flutter/ephemeral/ to root .gitignore
- Mirror ephemeral/ and firebase-debug.log patterns in example/.gitignore
These files were already listed in .pubignore but were missing from
.gitignore, allowing them to persist in the git index.
|
Thanks for the quick follow-up! The second commit addresses the main security and privacy issues from the first round — good cleanup. Three points worth resolving before merge:
Everything else looks good — the improved test coverage, Dart 3 type annotation fixes, and AppDelegate migration to |
Yes, I can confirm that both FkUserAgent.release() and FkUserAgent.properties are already public APIs in the existing code. That's why the tests compile and pass without needing further changes in lib/fk_user_agent.dart |
Summary
Adds Swift Package Manager support for the iOS side of
fk_user_agentwhile preserving CocoaPods compatibility for the plugin package.This PR also updates the package to a Dart 3 / newer Flutter baseline, migrates the example iOS app to a SwiftPM-only setup, and adds focused unit coverage for the Dart-side caching behavior.
Changes
Package.swiftSources/...layout^3.11.0>=3.41.013.0.pubignoreto keep publish artifacts cleanerFkUserAgentcache/init/release behaviorWhy
Flutter now supports Swift Package Manager for iOS plugins, and plugin consumers are gradually moving away from CocoaPods. This change makes the plugin compatible with SwiftPM-based iOS integration without dropping CocoaPods support for users who still rely on it.
Breaking Changes
This PR should be released as a major version.
^3.11.0>=3.41.013.0Validation
Dart / package
flutter testflutter analyzeExample app
flutter pub getflutter build ios --simulator --debug --no-codesignCocoaPods compatibility
flutter config --no-enable-swift-package-managerpod lib lint ios/fk_user_agent.podspec --configuration=Debug --skip-tests --use-modular-headers --use-librariespod lib lint ios/fk_user_agent.podspec --configuration=Debug --skip-tests --use-modular-headersSwiftPM compatibility
flutter config --enable-swift-package-managerflutter build ios --simulator --debug --no-codesignNotes