Skip to content

Make ephemeral platform directories editable by default in add-to-app #98077

Open

Description

@blasten

The content of the .android and .ios directories cannot be modified since flutter pub get or any
build command will override the file changes.

This breaks flutter run on Android if a dependency requires to modify AndroidManifest.xml or build.gradle.
For example, adding webview to a module.

My suggestion is to make these directories editable, so there's no this one-off special case.

@jmagman any thoughts?

Activity

  1. added
    platform-androidAndroid applications specifically
    platform-iosiOS applications specifically
    a: existing-appsIntegration with existing apps via the add-to-app flow
    on Feb 8, 2022
  2. jmagman commented on Feb 9, 2022

    @jmagman
    Member

    I think most of the discussion about this happened in #32989, you're suggesting we do @xster's number 3.

    Fully materialize those folders and expect users to potentially edit them and source control them as well

    We decided to keep it ephemeral (number 1), and the make-host-app-editable command was deprecated. There's lots of comments about "gotchas" in that issue.

    See also flutter/website#7774

  3. blasten commented on Feb 9, 2022

    @blasten
    Author

    I think the issue about out-of-date files is fixed by the migration tool that @GaryQian is working on.

    I’m currently only able to test a webview in add-to-app if I modify the tool to avoid regenerating the .android directory. cc @xster

  4. jmagman commented on Feb 9, 2022

    @jmagman
    Member

    From #32989 (comment), we could make the module concept way smaller, and any changes outside the Flutter module and dependencies and would not be in the module.

    Alternatively we could go the opposite way. If we get rid of the ephemeral concept, is there any point to actually having modules? What if we just make any flutter created app "add-to-app"-able embeddable? I actually did this for iOS for Options B and C in PR #70647 but it's not documented anywhere. It wouldn't be that hard (I think) to also support Option A. Maybe modules are adding something more for Android though...

  5. xster commented on Feb 9, 2022

    @xster
    Member

    My vote is moving a bit more towards http://flutter.dev/go/everything-builds-from-a-module. With Emmanuel's case being solved by wrapping the module you're trying to test in a blank wrapper Android app (with the appropriate manifest change).

    Doing the complete opposite works too. But conceptually, someone (the tools team, the platform team, the user) has to make a mental separation between the things in the app that takes effect when embedded (such as dependencies in the gradle files) and things that are ignored when embedded (such as everything under https://developer.android.com/guide/topics/manifest/application-element). I think it's preferable to make this split explicit rather than implicit.

  6. blasten commented on Feb 9, 2022

    @blasten
    Author

    I’d like to use hot reload, or local engine with flutter run.

    Currently this flow breaks as soon as you bring a plugin that requires manual changes to build.Gradle or an Android Manifest.

  7. jmagman commented on Feb 9, 2022

    @jmagman
    Member

    My vote is moving a bit more towards http://flutter.dev/go/everything-builds-from-a-module. With Emmanuel's case being solved by wrapping the module you're trying to test in a blank wrapper Android app (with the appropriate manifest change).

    Just to copy #32989 (comment) @xster's previous thoughts here:

    Currently, the modules have this weird dual role (#32992) where it both acts as a library but also an app project that lets you launch it with minimal bells and whistles.

    Instead, the module should just be an unlaunchable module and the latter role should be accomplished by a flutter create-wrapper-project my_test_launcher --from-module ../my_flutter_module type command.

    In other words, Java classes, firebase configs, keys, AndroidManifest tweaks, gradle tweaks should all not be in the module. The module just makes a platform artifact from Dart inputs. Everything else are in platform wrapper projects whether it's a normal full-Flutter-app case, whether it's in your own existing app or in these 'test wrappers' you're creating to quickly bootstrap modules.

    By contrast though, #37689 (which you also pointed to) is a valid gradle tweak that seems to need to be in the module.

    #32989 was closed because we settled on the current ephemeral model, with the user pretty easily able to make their own little wrapper project (just a new vanilla iOS or Android app, and follow the add-to-app instructions), where they could change whatever Gradle/configs/CocoaPods settings they wanted. Instead of changing the ephemerality we could just document that better, or make the suggested flutter create-wrapper-project/flutter create -t wrapper command do it for them.

  8. xster commented on Feb 9, 2022

    @xster
    Member

    Right. The need is a valid one. We just didn't hear it often enough to make it more convenient. We could make it more convenient in a tool. Otherwise, for the time being, you can manually create a vanilla Android app that consumes the module. You can do any gradle edits needed there. We could create that app through a tool. Your idea about operating against the add-to-app wrapper app with the Flutter tool is an interesting idea too. Flutter running an Android app rather than a Flutter app.

  9. jmagman commented on Feb 10, 2022

    @jmagman
    Member

    Another thought is to get rid of the ephemeral directories, and instead adopt a model like plugins and have an example directory containing non-ephemeral ios and android (plus future platform) directories, and maybe even light-weight host apps that do nothing but consume the module. Then, because it's in example, it would be explicit that this isn't your production code and you shouldn't ship it, but just like plugin examples you can modify it and check it into source control. And then tooling could be updated to handle flutter run from the top-level module directory to run the ios or android example, or flutter attach from the light-weight example host app.

  10. xster commented on Feb 10, 2022

    @xster
    Member

    that SGTM too. If we make it clear that example is explicitly orphaned the moment it's created. Flutter running the parent directory seems a bit magical though, unless we make it a global pattern somehow

  11. blasten commented on Feb 10, 2022

    @blasten
    Author

    I like the idea of an example directory similar to plugins. On Android, this could mean that the template generates examples using FlutterFragment, FlutterActivity + Native activities, FlutterView with other native activities, shared Flutter engine, etc...

    This could help with:

    1. integration tests
    2. troubleshooting issues e.g. plugins being used in one of these scenarios or a new API level.
  12. wangmir commented on Jun 9, 2022

    @wangmir

    @blasten @jmagman Hi, issue related to #104494, can I get current status about this? I need to configure miSdk and compileSdkVersion, targetSdkVersion of aar module, but currently it's not possible.. Are there any method to do this..?

  13. 2 remaining items

  14. chris-rutkowski commented on Nov 3, 2022

    @chris-rutkowski

    @xster According to this document Integrate a Flutter module into your iOS project, using option A - Embed with CocoaPods and the Flutter SDK:

    we have to modify the App's Podfile with the following

    load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
    

    But podhelper.rb is deep inside .ios folder - the folder that doesn't exist 😀.

    CI cloning repository from scratch needs to "trigger" it a bit, so the .ios and .android folders are created. e.g.:

    cd flutter_module
    flutter pub get
    [rest of CI]
    

    The same issue may be faced by other developers working in the same codebase, but specialising in iOS, not Flutter. Even if they have the .ios folder, because it was generated before, it content may be out of date.

  15. jmagman commented on Nov 3, 2022

    @jmagman
    Member

    @chris-rutkowski There is a note under https://docs.flutter.dev/development/add-to-app/ios/project-setup#module-organization

    Do not source control the .ios/ directory since it’s autogenerated. Before building the module on a new machine, run flutter pub get in the my_flutter directory first to regenerate the .ios/ directory before building iOS project using the Flutter module.

  16. added
    team-iosOwned by iOS platform team
    fyi-toolFor the attention of Flutter Tool team
    and removed
    team-toolOwned by Flutter Tool team
    on Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: existing-appsIntegration with existing apps via the add-to-app flowc: proposalA detailed proposal for a change to Flutterplatform-androidAndroid applications specificallyplatform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions