Repository: flutter
Issue: ☂️ Add Swift Package Manager compatibility
Labels: c: new feature,platform-ios,tool,package,P2,team-ios,triaged-ios

# Work items

## Add Swift Package Manager compatibility

* [x] https://github.com/flutter/flutter/issues/126016
* [x] [tool] https://github.com/flutter/flutter/issues/146369
* [x] [tool] https://github.com/flutter/flutter/issues/146371
* [x] [packages] https://github.com/flutter/flutter/issues/146901
* [ ] [tool] Link to website instructions [via tool](https://github.com/flutter/flutter/blob/7d891907e380afa826d2252aeb997c74a1b9292b/packages/flutter_tools/lib/src/migrations/swift_package_manager_integration_migration.dart#L160-L176) once instructions are published 
* [x] [tool][packages] https://github.com/flutter/flutter/issues/148018
* [x] #153448
* [x] #153449
* [x] https://github.com/flutter/flutter/issues/159121
* [ ] https://github.com/flutter/flutter/issues/151567
    * Blocker: update tests that fail if Swift Package Manager is enabled
        * [ ] Update `plugin_lint_mac` test for Swift Package Manager
        * [ ] Update `build_ios_framework_module_test` test for Swift Package Manager 
* [ ] [tool] https://github.com/flutter/flutter/issues/146957
  * [ ] [tool] https://github.com/flutter/flutter/issues/81867 (also macOS)
  * [ ] [too] Ensure `flutter build ios-framework` works as expected on non-modules if SwiftPM is enabled
  * [ ] https://github.com/flutter/flutter/issues/157391
* [ ] [tool] https://github.com/flutter/flutter/issues/151504
* [ ] [tool] Make SwiftPM available on beta/stable
* [ ] [tool] Default SwiftPM opt-in flag to true
* [x] [packages] https://github.com/flutter/flutter/issues/159173
* [ ] [tool] https://github.com/flutter/flutter/issues/144582
* [ ] https://github.com/flutter/flutter/issues/161182

Website docs:
* [x] Document how to migrate a Flutter app to use Swift Package Manager
* [x] Document how to add Swift Package Manager support to a plugin
* [x] https://github.com/flutter/flutter/issues/152276
* [ ] #153792
* [ ] Update https://docs.flutter.dev/packages-and-plugins/developing-packages
  * [ ] Provide instructions on how to get started with writing a Package.swift?
* [ ] Update https://docs.flutter.dev/get-started/flutter-for/uikit-devs#managing-dependencies
* [ ] Update: https://docs.flutter.dev/platform-integration/ios/ios-app-clip#step-8-integrate-plugins
* [ ] Update: https://docs.flutter.dev/platform-integration/ios/app-extensions (see https://github.com/flutter/flutter/issues/142136)

Additional features:
* [ ] [tool] https://github.com/flutter/flutter/issues/146203

## Migrate plugins to Swift Package Manager

* [ ] [packages] https://github.com/flutter/flutter/issues/146922
* [x] Dogfood the migration docs with Google plugin authors
* [x] Ask `flutter-insiders@` to try out the migration docs
* [x] Dogfood the migration docs with the top 5 most popular Flutter iOS/macOS plugins
* [x] Open GitHub issues on the top 100 most popular Flutter iOS/macOS plugins
* [ ] Add a banner to the docs website with a link to the docs: `OS plugin authors: Consider upgrading your iOS plugins to also support Swift Package Manager`
* [ ] [tool] https://github.com/flutter/flutter/issues/147602
* [ ] [tool] https://github.com/flutter/flutter/issues/149855
* [ ] [tool] https://github.com/flutter/flutter/issues/148222
* [ ] https://github.com/flutter/flutter/issues/152038
* [x] https://github.com/dart-lang/pana/issues/1402
* [ ] Deprecate CocoaPods
    * [ ] Add warning in tool if project has CocoaPods plugins 
    * [ ] Announce on [flutter-announce@](https://groups.google.com/g/flutter-announce) and on the #announcements [Discord](https://github.com/flutter/flutter/blob/aed548992a0e8e8eb4d1d5ec5a8ef5af7c89aff2/docs/contributing/Chat.md) channel
* [ ] [tool][packages] Remove CocoaPods support once the ecosystem has migrated to SwiftPM
    * [ ] [packages] Consider re-adding SwiftPM `.modulemaps` (see https://github.com/flutter/flutter/issues/148572#issuecomment-2231296570)
* [ ] Close issues related to CocoaPods
    * [ ] https://github.com/flutter/flutter/issues/40135 
    * [x] https://github.com/flutter/flutter/issues/22998
* [ ] Deduct pub.dev score on iOS plugins that do not support SwiftPM

## macOS
* [ ] [tool] https://github.com/flutter/flutter/issues/144397
  * Common SwiftPM errors are not currently parsed for macOS due to this issue. Once resolved, we should parse for [common errors](https://github.com/flutter/flutter/blob/7d891907e380afa826d2252aeb997c74a1b9292b/packages/flutter_tools/lib/src/ios/mac.dart#L894-L935) same as iOS
* [x] [tool] https://github.com/flutter/flutter/issues/146204
    * Needed to set the correct [`Package.swift` minimum supported platform version](https://github.com/flutter/flutter/blob/7d891907e380afa826d2252aeb997c74a1b9292b/packages/flutter_tools/lib/src/macos/build_macos.dart#L116-L118). Unblocks migrating:
        * [Firebase packages](https://github.com/firebase/firebase-ios-sdk/blob/e42596a75534304da7457394f339f02c72938146/Package.swift#L26)
        * `google_sign_in_ios`
* [ ] [website] https://github.com/flutter/website/issues/7225

## Bugs

- [ ] https://github.com/flutter/flutter/issues/160214
- [ ] https://github.com/flutter/flutter/issues/148424
- [x] [tool] https://github.com/flutter/flutter/issues/144244
- [x] https://github.com/flutter/flutter/issues/148572
- [x] https://github.com/flutter/flutter/issues/148307
- [x] https://github.com/flutter/flutter/issues/147587
- [x] https://github.com/dart-lang/pub/issues/4262
  * Workaround in documentation (using `!.gitkeep` in `.gitignore`)
- [ ] https://github.com/flutter/flutter/issues/162196

# Resources

Design doc: [flutter.dev/go/swift-package-manager-plugins-v2](https://flutter.dev/go/swift-package-manager-plugins-v2)
Original Github Issue: https://github.com/flutter/flutter/issues/33850