Skip to content

feat: add iOS Swift Package Manager support#20

Open
melihcelik-hubx wants to merge 3 commits into
flutter-fast-kit:masterfrom
melihcelik-hubx:feature/spm-migration
Open

feat: add iOS Swift Package Manager support#20
melihcelik-hubx wants to merge 3 commits into
flutter-fast-kit:masterfrom
melihcelik-hubx:feature/spm-migration

Conversation

@melihcelik-hubx

Copy link
Copy Markdown

Summary

Adds Swift Package Manager support for the iOS side of fk_user_agent while 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

  • Added iOS Swift Package Manager support with Package.swift
  • Moved iOS plugin sources into the SwiftPM-compatible Sources/... layout
  • Updated the iOS podspec to reference the new source/header paths
  • Kept CocoaPods support for the published plugin package
  • Raised minimum support to:
    • Dart ^3.11.0
    • Flutter >=3.41.0
    • iOS 13.0
  • Updated example iOS project to use SwiftPM-only integration
  • Removed stale CocoaPods integration from the example app
  • Added .pubignore to keep publish artifacts cleaner
  • Added unit tests for FkUserAgent cache/init/release behavior
  • Fixed Dart 3 compatibility issues in the package/test code
  • Updated README and CHANGELOG for the breaking release

Why

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.

  • Minimum Dart version is now ^3.11.0
  • Minimum Flutter version is now >=3.41.0
  • Minimum iOS version is now 13.0

Validation

Dart / package

  • flutter test
  • flutter analyze

Example app

  • flutter pub get
  • flutter build ios --simulator --debug --no-codesign

CocoaPods compatibility

  • flutter config --no-enable-swift-package-manager
  • pod lib lint ios/fk_user_agent.podspec --configuration=Debug --skip-tests --use-modular-headers --use-libraries
  • pod lib lint ios/fk_user_agent.podspec --configuration=Debug --skip-tests --use-modular-headers

SwiftPM compatibility

  • flutter config --enable-swift-package-manager
  • flutter build ios --simulator --debug --no-codesign

Notes

  • The Dart API remains unchanged.
  • Objective-C iOS implementation was kept as-is; this PR only changes packaging/layout.
  • The example app was fully cleaned up to remove lingering CocoaPods integration warnings once SwiftPM support was in place.

…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 qMalte 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.

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.env contains absolute local paths (/Users/melihcelik/Desktop/...). The DART_DEFINES base64 decodes to harmless Flutter build metadata (version/channel), so no secrets — but the whole example/ios/Flutter/ephemeral/ folder is generated and shouldn't be checked in.
  • .idea/libraries/Dart_SDK.xml.bak is a stray backup file with local SDK paths and should be dropped.
  • example/ios/Flutter/ephemeral/flutter_lldb_helper.py is 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.
@melihcelik-hubx melihcelik-hubx requested a review from qMalte July 5, 2026 23:28
@qMalte

qMalte commented Jul 6, 2026

Copy link
Copy Markdown

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:

  1. .idea/ still git-tracked: .gitignore now correctly excludes .idea/, but Dart_SDK.xml remains in the git index. A git rm --cached .idea/libraries/Dart_SDK.xml is needed to actually remove it from tracking.

  2. fk_user_agent.iml missing from .gitignore: .pubignore already excludes *.iml.gitignore should too.

  3. FkUserAgent.release() and FkUserAgent.properties in the tests: The diff for lib/fk_user_agent.dart only shows 2 changed lines, so these must already be public API in the existing code. Could you confirm? If they aren't, the tests won't compile.

Everything else looks good — the improved test coverage, Dart 3 type annotation fixes, and AppDelegate migration to FlutterImplicitEngineBridge are all correct.

@melihcelik-hubx

Copy link
Copy Markdown
Author

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:

  1. .idea/ still git-tracked: .gitignore now correctly excludes .idea/, but Dart_SDK.xml remains in the git index. A git rm --cached .idea/libraries/Dart_SDK.xml is needed to actually remove it from tracking.
  2. fk_user_agent.iml missing from .gitignore: .pubignore already excludes *.iml.gitignore should too.
  3. FkUserAgent.release() and FkUserAgent.properties in the tests: The diff for lib/fk_user_agent.dart only shows 2 changed lines, so these must already be public API in the existing code. Could you confirm? If they aren't, the tests won't compile.

Everything else looks good — the improved test coverage, Dart 3 type annotation fixes, and AppDelegate migration to FlutterImplicitEngineBridge are all correct.

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

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.

2 participants