very_good_templates icon indicating copy to clipboard operation
very_good_templates copied to clipboard

fix: When you try to publish your final plugin a lot of undocumented steps are required

Open rekire opened this issue 2 years ago • 6 comments

Description Currently the generated flutter plugin works so far fine while development (except a couple of possible improvements like #42, #43, #44). However when you try to publish it at least as git dependency (as some kind of preview) you will notice quickly that there are a lot of "path: ../xyz" dependencies which simply won't work. This should be mentioned at least or might be some help how to manage this.

Steps To Reproduce

  1. Create the flutter plugin
  2. Add all the features you want
  3. Try to add your plugin as a dependency in a flutter app

Expected Behavior The plugin should work

Actual Behavior The plugin cannot be resolved since the ".." dependencies are unknown.

rekire avatar Feb 23 '24 22:02 rekire

Hi @rekire thanks for opening this issue 🙌

I think you are referring to ".." dependencies as those path dependencies.

How are you adding the plugin into your flutter application?

alestiago avatar Feb 26 '24 12:02 alestiago

Sorry for the late reply, right now I'm adding it as git dependency. But I'm right now on the way to publish it on pub.dev. Since I'm also changing my platform interface before the 1.0.0 I notices that tagging it with a real version makes it also more complicated since you need to keep in mind that the interface it has its own version. Hints for that might be good too

rekire avatar Mar 20 '24 15:03 rekire

When publishing to pub.dev it will most likely complain about path dependencies.

I recommend reading the official documentation for publishing, let me know if such documentation helps out.

I think it wouldn't hurt to include a "Publishing your plugin" section in the generated template within a "CONTRIBUTING" file based on the generation. Would you be interested in writing such documentation?

alestiago avatar Aug 14 '24 10:08 alestiago

I'm working on my first update since the initial release. So I can write here down the steps when I fixed my CI issues, which I want to mention in a new issue.

However I don't have the time right now to extend the documentation itself.

rekire avatar Nov 23 '24 21:11 rekire

I published now my 1.0.1. When you have fixed everything so that dart pub publish --dry-run has no warnings then you need to run those commands:

cd plugin_name_platform_interface
dart pub publish
cd ../plugin_name_android
dart pub publish
cd ../plugin_name_darwin# (or _ios and _macos if you use multiple packages)
dart pub publish
cd ../plugin_name_linux
dart pub publish
cd ../plugin_name_web
dart pub publish
cd ../plugin_name_windows
dart pub publish
cd ../plugin_name
dart pub publish

Keep in mind that you likely need to publish the platform_interface first since the other packages depend on it. Then publish the platform specific plugins and at the end the package which is used by the users.

rekire avatar Nov 24 '24 14:11 rekire

Thanks @rekire for writing your insights down.

I think it might be useful to include documentation within the template CONTRIBUTING and/or a script within the template under a tool directory named publish that would handle the publishing order and updating dependency constraints. Not sure if existing tools like melos are already capable of handling such.

alestiago avatar Jan 02 '25 10:01 alestiago