Skip to content

Conversation

@Spivak-adam
Copy link
Contributor

@Spivak-adam Spivak-adam commented Aug 12, 2025

Added a default +1 build number to the version field in pubspec.yaml.tmpl (line 5). This ensures consistent versioning behavior across iOS and Android for newly created Flutter projects.

Why this change?

  • On iOS, CFBundleShortVersionString (marketing version) must be numeric (major.minor.patch) and does not include the build number unless explicitly set.
  • On Android, the version name and version code can both be set, allowing more flexibility in representing the build number.
  • Without a build number in pubspec.yaml, Android defaults to +1 while iOS omits it, resulting in inconsistent version strings between platforms.

Benefits

  • Consistency: Both iOS and Android builds will start with the same format, e.g., 1.0.0+1.
  • Clarity: New projects have a visible build number by default, reducing confusion for new developers.
  • Best Practice: Aligns with Apple’s numeric marketing version rules while preserving Android’s flexibility.

Developers can still override --build-name and --build-number as needed for custom versioning.
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.

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

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.

…sistency between builds on IOS and Android. Created tests to accomodate.
@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 12, 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 aims to standardize the default build version for new Flutter projects to ensure consistency between iOS and Android by adding a build number to the pubspec.yaml.tmpl for empty applications. My review has two main points: the version in pubspec.yaml.tmpl should be 0.1.0+1 instead of 0.1.0+ to correctly set the default build number to 1, and the new test case should be adjusted to verify the behavior for an empty application (--empty), as the current test covers a standard application, which is not affected by this change.

{{#withEmptyMain}}
publish_to: 'none'
version: 0.1.0
version: 0.1.0+
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The PR description states that the goal is to add a default +1 build number for consistency. However, the change to 0.1.0+ results in an empty build number, which doesn't resolve the inconsistency between Android and iOS platforms. To ensure both platforms default to a build number of 1, this should be 0.1.0+1.

version: 0.1.0+1

Comment on lines 4842 to 4853
testUsingContext('generated pubspec uses default build number (+1) for standard app', () async {
await projectDir.create(recursive: true);

await _createProject(
projectDir,
<String>['--no-pub', '--template=app'],
<String>['lib/main.dart', 'pubspec.yaml'],
);

final String pubspec = await projectDir.childFile('pubspec.yaml').readAsString();
expect(pubspec, contains(RegExp(r'^version:\s*1\.0\.0\+1\s*$', multiLine: true)));
});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This test verifies the version for a standard app, which already had a build number and is not affected by this PR's changes. The change in pubspec.yaml.tmpl is for an empty app (--empty). The test should be updated to validate the version for an empty app to ensure the change is correctly tested.

  testUsingContext('generated pubspec uses default build number (+1) for empty app', () async {
    await projectDir.create(recursive: true);

    await _createProject(
      projectDir,
      <String>['--no-pub', '--template=app', '--empty'],
      <String>['lib/main.dart', 'pubspec.yaml'],
    );

    final String pubspec = await projectDir.childFile('pubspec.yaml').readAsString();
    expect(pubspec, contains(RegExp(r'^version:\s*0\.1\.0\+1\s*$', multiLine: true)));
  });

@Spivak-adam Spivak-adam reopened this Aug 12, 2025
@fluttergithubbot
Copy link
Contributor

An existing Git SHA, 3cd8ed431d9de53e32900910968c569ec18f56f7, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

expect(logger.statusText, isNot(contains(r' $ cd')));
}, overrides: {Logger: () => logger});

testUsingContext('generated pubspec uses default build number (+1) for empty app', () async {
Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to add a test that also ensures the build number is present when using the default template (e.g. without the --empty flag).

Copy link
Contributor Author

@Spivak-adam Spivak-adam Aug 12, 2025

Choose a reason for hiding this comment

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

I believe I tried running "Create Flutter test-app" withouth --empty, and it did not show up. What showed up instead was the other version number. If I understand correctly, it creates different templates with different flags, and this version number that I created a PR for specifically was for the --empty flag. The other version number already had a +1, and I was creating a pull request to make it more consistent.

The following defines the version and build number for your application. A version number is three numbers separated by dots, like 1.2.43 followed by an optional build number separated by a +. Both the version and the builder number may be overridden in flutter build by specifying --build-name and --build-number, respectively. In Android, build-name is used as versionName while build-number used as versionCode. Read more about Android versioning at https://developer.android.com/studio/publish/versioning In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. Read more about iOS versioning at https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html In Windows, build-name is used as the major, minor, and patch parts of the product and file versions while build-number is used as the build suffix. version: 1.0.0+1 {{/withPlatformChannelPluginHook}}

P.S. I apolgize, I'm not good with Github text formatting

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup understood!

I just meant if there wasn't already an existing test we should add one to make sure the default template doesn't get out of sync in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked for that when making the PR, but I wasn't able to find one. But, if anyone does, that would be great!

@Piinks Piinks added the team-devexp Owned by the Developer Experience team label Oct 20, 2025
@Piinks Piinks requested a review from bkonyi October 20, 2025 22:03
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 29, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 29, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 29, 2025

autosubmit label was removed for flutter/flutter/173600, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 3, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Nov 3, 2025
Merged via the queue into flutter:master with commit b87e863 Nov 3, 2025
148 of 149 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 3, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 4, 2025
Roll Flutter from 027f2e410241 to e5d5c01850f2 (73 revisions)

flutter/flutter@027f2e4...e5d5c01

2025-11-04 [email protected] [web] Upgrade Chrome to 141 (for engine tests) (flutter/flutter#177743)
2025-11-04 [email protected] Replace deprecated withOpacity in `chip_animation_style.0.dart‎`  example (flutter/flutter#177834)
2025-11-04 [email protected] Roll Skia from 03612114a36d to c89b6118266b (1 revision) (flutter/flutter#177991)
2025-11-04 [email protected] [web] Delete unused futurize util (flutter/flutter#177861)
2025-11-04 [email protected] Roll Skia from 1a179581af75 to 03612114a36d (1 revision) (flutter/flutter#177984)
2025-11-04 [email protected] Roll Skia from 150f844e83fb to 1a179581af75 (3 revisions) (flutter/flutter#177979)
2025-11-04 [email protected] Roll Dart SDK from 6f1bd8d05b1d to 156bf665dba4 (2 revisions) (flutter/flutter#177976)
2025-11-04 [email protected] Roll Skia from 3990fc40acdf to 150f844e83fb (1 revision) (flutter/flutter#177964)
2025-11-04 [email protected] Roll Skia from 85adfd3b8e75 to 3990fc40acdf (1 revision) (flutter/flutter#177962)
2025-11-04 [email protected] Fix `isHeif` crash (flutter/flutter#177944)
2025-11-04 [email protected] Roll Dart SDK from ac065fcd782e to 6f1bd8d05b1d (1 revision) (flutter/flutter#177955)
2025-11-04 [email protected] Roll Skia from 001516d132f0 to 85adfd3b8e75 (4 revisions) (flutter/flutter#177958)
2025-11-04 [email protected] [ Widget Preview ] Add analytic event that's reported when the previewer is opened (flutter/flutter#177949)
2025-11-04 [email protected] Marks Linux_pixel_7pro dynamic_path_stroke_tessellation_perf__timeline_summary to be unflaky (flutter/flutter#171144)
2025-11-03 [email protected] Roll Skia from da9b8fb01101 to 001516d132f0 (6 revisions) (flutter/flutter#177951)
2025-11-03 [email protected] Add FAQ entry about our attempts to remove Skia image codecs. (flutter/flutter#177947)
2025-11-03 [email protected] Add blockAccessibilityFocus flag (flutter/flutter#175551)
2025-11-03 [email protected] Make sure that a SnackBarAction doesn't crash in 0x0 environment (flutter/flutter#177899)
2025-11-03 [email protected] Make sure that a SelectionArea doesn't crash in 0x0 environment (flutter/flutter#177876)
2025-11-03 [email protected] Speculative fix for android_verified_input_test (flutter/flutter#177937)
2025-11-03 [email protected] [skia] Explicitly disable XPS backend (flutter/flutter#177050)
2025-11-03 [email protected] Roll Dart SDK from 2d3aa1d5cb9f to ac065fcd782e (2 revisions) (flutter/flutter#177927)
2025-11-03 [email protected] Improve Impeller's docs in the top-level docs folder (flutter/flutter#177848)
2025-11-03 [email protected] Make sure that GridTile doesn't crash in 0x0 environment (flutter/flutter#175321)
2025-11-03 [email protected] Make sure that a Slider doesn't crash in 0x0 environment (flutter/flutter#177882)
2025-11-03 [email protected] fix(impeller): fix params to glDiscardFrameBufferEXT (flutter/flutter#175589)
2025-11-03 [email protected] Roll Skia from 56a10bf56ee0 to da9b8fb01101 (5 revisions) (flutter/flutter#177928)
2025-11-03 [email protected] wires up set application locale to web engine (flutter/flutter#177284)
2025-11-03 [email protected] [Android 16] Update `linux_android_emu_unstable` to use avd rev 7 (flutter/flutter#177854)
2025-11-03 [email protected] Make sure that a CheckedPopupMenuItem doesn't crash in 0x0 environment (flutter/flutter#177545)
2025-11-03 [email protected] Roll Fuchsia Linux SDK from Ynp3qiXocK8WLTjlb... to vxK5obzfr1X9P2kSh... (flutter/flutter#177917)
2025-11-03 [email protected] Update pubspec.yaml.tmpl build version tracker on line 5 (flutter/flutter#173600)
2025-11-03 [email protected] [Impeller] Fix the source rectangle used when rendering an AtlasContents with the strict mode for nine-patch images (flutter/flutter#177860)
2025-11-03 [email protected] docs: Default Splash / Loading screen for web app in index.html (flutter/flutter#177084)
2025-11-03 [email protected] Roll Skia from 25e1e4e96980 to 56a10bf56ee0 (6 revisions) (flutter/flutter#177910)
2025-11-03 [email protected] Make sure that a PopupMenuItem doesn't crash in 0x0 environment (flutter/flutter#177533)
2025-11-03 [email protected] Make sure that a RefreshProgressIndicator doesn't crash in 0x0 enviro… (flutter/flutter#177556)
2025-11-03 [email protected] Make sure that a PopupMenuButton doesn't crash in 0x0 environment (flutter/flutter#177493)
2025-11-03 [email protected] Make sure that a CircularProgressIndicator doesn't crash in 0x0 envir… (flutter/flutter#177555)
2025-11-02 [email protected] Make sure that a Radio doesn't crash in 0x0 environment (flutter/flutter#177580)
2025-11-02 [email protected] Make sure that a RadioListTile doesn't crash in 0x0 environment (flutter/flutter#177576)
2025-11-02 [email protected] Make sure that an ExpandIcon doesn't crash in 0x0 envrionment (flutter/flutter#175042)
2025-11-02 [email protected] Make sure that a RangeSlider doesn't crash in 0x0 environment (flutter/flutter#177642)
2025-11-02 [email protected] Make sure that a GridTileBar doesn't crash in 0x0 environment (flutter/flutter#177546)
2025-11-02 [email protected] Make sure that a LinearProgressIndicator doesn't crash in 0x0 environ… (flutter/flutter#177553)
2025-11-02 [email protected] Make sure that a PopupMenuDivider doesn't crash in 0x0 environment (flutter/flutter#177445)
...
IvoneDjaja pushed a commit to IvoneDjaja/flutter that referenced this pull request Nov 22, 2025
)

<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

Added a default +1 build number to the version field in
pubspec.yaml.tmpl (line 5). This ensures consistent versioning behavior
across iOS and Android for newly created Flutter projects.

Why this change?
- On iOS, CFBundleShortVersionString (marketing version) must be numeric
(major.minor.patch) and does not include the build number unless
explicitly set.
- On Android, the version name and version code can both be set,
allowing more flexibility in representing the build number.
- Without a build number in pubspec.yaml, Android defaults to +1 while
iOS omits it, resulting in inconsistent version strings between
platforms.

Benefits
- Consistency: Both iOS and Android builds will start with the same
format, e.g., 1.0.0+1.
- Clarity: New projects have a visible build number by default, reducing
confusion for new developers.
- Best Practice: Aligns with Apple’s numeric marketing version rules
while preserving Android’s flexibility.

Developers can still override --build-name and --build-number as needed
for custom versioning.
*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.*

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

## 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

---------

Co-authored-by: Ben Konyi <[email protected]>
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
)

<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

Added a default +1 build number to the version field in
pubspec.yaml.tmpl (line 5). This ensures consistent versioning behavior
across iOS and Android for newly created Flutter projects.

Why this change?
- On iOS, CFBundleShortVersionString (marketing version) must be numeric
(major.minor.patch) and does not include the build number unless
explicitly set.
- On Android, the version name and version code can both be set,
allowing more flexibility in representing the build number.
- Without a build number in pubspec.yaml, Android defaults to +1 while
iOS omits it, resulting in inconsistent version strings between
platforms.

Benefits
- Consistency: Both iOS and Android builds will start with the same
format, e.g., 1.0.0+1.
- Clarity: New projects have a visible build number by default, reducing
confusion for new developers.
- Best Practice: Aligns with Apple’s numeric marketing version rules
while preserving Android’s flexibility.

Developers can still override --build-name and --build-number as needed
for custom versioning.
*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.*

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

## 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

---------

Co-authored-by: Ben Konyi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-devexp Owned by the Developer Experience 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.

[Proposal] Include build number in pubspec.yaml version when using flutter create

5 participants