Skip to content

Conversation

@okorohelijah
Copy link
Contributor

This PR introduces support for creating Flutter plugins with a single, shared implementation for iOS and macOS. This is enabled by a new darwin platform option in the flutter create command, which simplifies code maintenance and reduces duplication for plugin authors.

List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.
Fixes #161019

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@okorohelijah okorohelijah requested a review from a team as a code owner October 3, 2025 22:41
@github-actions github-actions bot added tool Affects the "flutter" command-line tool. See also t: labels. team-ios Owned by iOS platform team labels Oct 3, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for creating Flutter plugins with a shared darwin implementation for both iOS and macOS. It adds a new darwin platform option to the flutter create command, along with new templates for CocoaPods and Swift Package Manager. The changes also update the project creation logic to handle this new platform, including modifications to pubspec.yaml generation and how platform-specific directories are resolved. Additionally, new tests are added to verify the functionality of the shared Darwin implementation.

@okorohelijah okorohelijah requested a review from jmagman October 3, 2025 23:26
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

Can you also add an integration test?

After this line:

PluginTest('ios', <String>['--platforms=ios,macos'], sharedDarwinSource: true).call,

PluginTest('ios', <String>['--platforms=darwin']).call,

And here:

PluginTest('macos', <String>['--platforms=ios,macos'], sharedDarwinSource: true).call,

 PluginTest('macos', <String>['--platforms=darwin']).call, 

@jmagman
Copy link
Member

jmagman commented Oct 17, 2025

Some test failures:

06:03 +739 ~1 -1: test/commands.shard/permeable/create_test.dart: app does not include ios if disabled in config [E]
  Expected: not a file system entity that exists
    Actual: ErrorHandlingDirectory:<LocalDirectory: '/b/s/w/ir/x/t/flutter_tools.EBRPEX/flutter_tools_create_test.UMYZJU/flutter_project/ios'>
09:15 +874 ~2 -2: test/commands.shard/permeable/create_test.dart: app does not include desktop or web by default [E]
  Expected: not a file system entity that exists
    Actual: ErrorHandlingDirectory:<LocalDirectory: '/b/s/w/ir/x/t/flutter_tools.MRWEKF/flutter_tools_create_test.XRILCZ/flutter_project/macos'>

https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8701985648264674337/+/u/run_test.dart_for_tool_tests_shard_and_subshard_commands/stdout

@okorohelijah okorohelijah requested a review from jmagman October 29, 2025 18:19
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

This LGTM, I'd like @vashworth to also check it out though, particularly the template changes, and SwiftPM specifically.
I'm hoping there's an easy way to not have a separate darwin gitignore as well?

@jmagman jmagman requested a review from vashworth November 4, 2025 22:33
@vashworth
Copy link
Contributor

This LGTM, I'd like @vashworth to also check it out though, particularly the template changes, and SwiftPM specifically. I'm hoping there's an easy way to not have a separate darwin gitignore as well?

Unfortunately, I don't think there's an easy way to have a shared gitignore because it's in a different directory.

Copy link
Contributor

@vashworth vashworth left a comment

Choose a reason for hiding this comment

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

Okay so I checkout out your branch and tried it myself and somethings not right.

When I did flutter create --template plugin --platform darwin darwin_plugin, the structure I got was:

darwin_plugin/
  darwin/
    darwin_plugin/
      Package.swift
      Sources/
  ios/
    darwin_plugin.podspec
    darwin_plugin/
      Package.swift
      Sources/
  macos/
    darwin_plugin.podspec
    darwin_plugin/
      Package.swift
      Sources/
  example/
    ios/
    macos/
  ...

However, if you look at an example plugin that uses the darwin setup, the structure should be like this:

darwin_plugin/
  darwin/
+   darwin_plugin.podspec
    darwin_plugin/
      Package.swift
      Sources/
-  ios/
-    darwin_plugin.podspec
-    darwin_plugin/
-      Package.swift
-      Sources/
-  macos/
-    darwin_plugin.podspec
-    darwin_plugin/
-      Package.swift
-      Sources/
  example/
    ios/
    macos/
  ...

Also, we should have an integration test that would have caught this.

Let me know if you need more help figuring this out.

}
if (darwinPlatform) {
platformsForMigrateConfig.add(SupportedPlatform.ios);
platformsForMigrateConfig.add(SupportedPlatform.macos);
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't SupportedPlatform.ios and SupportedPlatform.macos be added twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ios and macos dir was created because of the flag ios and mac(which determines if darwin can be created is set to true). The example app also needs both the flags to be true. I thought it would be best to use those flags. In the new approach, i created a temp flag to store the values so it could be false when creating the plugins and reset after

@okorohelijah okorohelijah requested review from a team and jtmcdole as code owners November 21, 2025 18:28
@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems platform-android Android applications specifically platform-ios iOS applications specifically framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. a: animation Animation APIs f: material design flutter/packages/flutter/material repository. f: cupertino flutter/packages/flutter/cupertino repository platform-windows Building on or for Windows specifically platform-web Web applications specifically platform-linux Building on or for Linux specifically labels Nov 21, 2025
@vashworth
Copy link
Contributor

Btw, you should run the failing tests locally to ensure they pass before pushing a fix to CI:

https://github.com/flutter/flutter/blob/master/dev/devicelab/README.md#running-specific-tests

In your case, you'd want to do

# from the .../flutter/dev/devicelab directory
../../bin/cache/dart-sdk/bin/dart bin/test_runner.dart test -t plugin_test_ios

and 

../../bin/cache/dart-sdk/bin/dart bin/test_runner.dart test -t plugin_test_macos

Copy link
Contributor

@vashworth vashworth left a comment

Choose a reason for hiding this comment

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

LGTM!

@okorohelijah okorohelijah added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Nov 25, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Nov 26, 2025

autosubmit label was removed for flutter/flutter/176495, because Pull request flutter/flutter/176495 is not in a mergeable state.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 26, 2025
@okorohelijah okorohelijah added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 26, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Nov 26, 2025

autosubmit label was removed for flutter/flutter/176495, because - The status or check suite Linux analyze has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 26, 2025
@okorohelijah okorohelijah added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 26, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Nov 26, 2025
Merged via the queue into flutter:master with commit 0b191ba Nov 27, 2025
151 of 152 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 27, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 27, 2025
flutter/flutter@7b98d50...022b155

2025-11-27 [email protected] Make tree green again by fixing lints (flutter/flutter#179186)
2025-11-26 [email protected] Add shared Darwin implementation for plugins (flutter/flutter#176495)
2025-11-26 [email protected] Fixed changing supportedLocales fails to update the locale (flutter/flutter#178526)
2025-11-26 [email protected] [ Tool ] Remove --no-sandbox when launching web apps on Chrome device (flutter/flutter#178670)
2025-11-26 [email protected] Build hooks: Don't require toolchain for unit tests (flutter/flutter#178954)
2025-11-26 [email protected] Fix a small typo in `HandlerCompat.java` docs (flutter/flutter#178595)
2025-11-26 [email protected] Roll Fuchsia Linux SDK from nzuAxCJGeJbkZCTkr... to _e9MNK4nfBOrERVP_... (flutter/flutter#179130)
2025-11-26 [email protected] Make sure that a CupertinoActivityIndicator doesn't crash in 0x0 envi… (flutter/flutter#178565)
2025-11-26 [email protected] [native assets] Bump minimum iOS version from 12 to 13 (flutter/flutter#179079)
2025-11-26 [email protected] Documents and fixes behavior when clipping background filter fragment shader (flutter/flutter#178940)
2025-11-26 [email protected] Replace the hardcoded link with an actual link tag in `PlatformChannel.java‎` docs (flutter/flutter#178588)
2025-11-26 [email protected] Roll Packages from cc3dca6 to 5d8d954 (5 revisions) (flutter/flutter#179140)
2025-11-26 [email protected] Add more templates that the UIScene migrator can match against (flutter/flutter#179044)
2025-11-26 [email protected] Remove deprecated activeColor in `dynamic_content_color.0.dart`‎ example (flutter/flutter#178961)
2025-11-26 [email protected] Remove deprecated `activeColor` in `decorated_sliver.1.dart‎` example (flutter/flutter#178959)
2025-11-26 [email protected] Small refactor in `PlayStoreDeferredComponentManager.java‎` (flutter/flutter#178586)
2025-11-26 [email protected] Roll Dart SDK from 9e605f706cdf to 1d8dc04bd1d7 (4 revisions) (flutter/flutter#179080)
2025-11-26 [email protected] Fix error when generating pt_BR localizations (flutter/flutter#175832)
2025-11-26 [email protected] Roll Fuchsia Test Scripts from JUeFbA8y0E-_pj-bg... to MHF-UAfO6sVKqSEYk... (flutter/flutter#179151)
2025-11-26 [email protected] Add flutter_lints to samples (flutter/flutter#179091)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
This PR introduces support for creating Flutter plugins with a single,
shared implementation for iOS and macOS. This is enabled by a new darwin
platform option in the flutter create command, which simplifies code
maintenance and reduces duplication for plugin authors.

*List which issues are fixed by this PR. You must list at least one
issue. An issue is not required if the PR fixes something trivial like a
typo.*
Fixes flutter#161019 

*If you had to change anything in the [flutter/tests] repo, include a
link to the migration guide as per the [breaking change policy].*

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [X] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
This PR introduces support for creating Flutter plugins with a single,
shared implementation for iOS and macOS. This is enabled by a new darwin
platform option in the flutter create command, which simplifies code
maintenance and reduces duplication for plugin authors.

*List which issues are fixed by this PR. You must list at least one
issue. An issue is not required if the PR fixes something trivial like a
typo.*
Fixes flutter#161019 

*If you had to change anything in the [flutter/tests] repo, include a
link to the migration guide as per the [breaking change policy].*

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [X] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-ios Owned by iOS platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow creating "darwin" (shared codebase for ios/macos) plugins directly in flutter create

3 participants