flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.12k stars 27.43k forks source link

[tool] New project gitignore still defines rules for Android and iOS folder, instead of placing them in the Android/iOS gitignore file #154163

Open navaronbracke opened 2 months ago

navaronbracke commented 2 months ago

Use case

Users creating a new Flutter project that want to benefit from the starting gitignore.

Proposal

Currently when creating a new Flutter project, most of the Android & iOS specific things are split off into their own gitignores in the Android & iOS directories.

However, this isn't the case for all the rules.

For iOS, we still define **/ios/Flutter/.last_build_id in the root gitignore at https://github.com/flutter/flutter/blob/master/packages/flutter_tools/templates/app_shared/.gitignore.tmpl#L28

For Android, we still define

/android/app/debug
/android/app/profile
/android/app/release

at the bottom of the same template.

We should probably move these gitignore lines into their Android / iOS specific counterparts.

Steps to reproduce:

  1. flutter create sample
  2. cd sample && cat .gitignore
  3. The ios and android folders are still present in rules in that file

Question: I'm not sure if the **/ glob pattern is for add-to-app use cases?

Flutter Doctor ```console [✓] Flutter (Channel stable, 3.24.1, on macOS 14.6.1 23G93 darwin-x64, locale en-BE) • Flutter version 3.24.1 on channel stable at /Users/navaronbracke/Documents/flutter • Upstream repository git@github.com:navaronbracke/flutter.git • FLUTTER_GIT_URL = git@github.com:navaronbracke/flutter.git • Framework revision 5874a72aa4 (6 days ago), 2024-08-20 16:46:00 -0500 • Engine revision c9b9d5780d • Dart version 3.5.1 • DevTools version 2.37.2 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/navaronbracke/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = /Users/navaronbracke/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15F31d • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2023.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160) [✓] VS Code (version 1.92.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.94.0 [✓] Connected device (2 available) • macOS (desktop) • macos • darwin-x64 • macOS 14.6.1 23G93 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 128.0.6613.85 [✓] Network resources • All expected network resources are available. • No issues found! ```
andrewkolos commented 2 months ago

Question: I'm not sure if the **/ glob pattern is for add-to-app use cases?

This is very much possible. Try out flutter create hello_world --template=module and then take a look at the .android and .ios directory.

andrewkolos commented 2 months ago

This might be a legitimate issue report—it would be nice to make sure the logic behind splitting things up into different .gitignores is consistent. However, I'm guessing the risk/reward ratio of fixing this is not very good. cc @jmagman and @reidbaker in case they have differing opinions.

reidbaker commented 2 months ago

I think the risk in new project creation is low but so is the priority. I would leave this open and marked as a p3.

jmagman commented 2 months ago

It would probably take someone sitting down and doing an audit, organizing it, and maybe adding some comments at the top describing what should go where. We could consider reorganizing for just newly created projects, or doing a more complete, but potentially risky, project migration like https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/migrations/swift_package_manager_gitignore_migration.dart

I would leave this open and marked as a p3.

I agree, reopening.