Skip to content

Commit b87e863

Browse files
Spivak-adambkonyi
andauthored
Update pubspec.yaml.tmpl build version tracker on line 5 (flutter#173600)
<!-- 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 <bkonyi@google.com>
1 parent 633d659 commit b87e863

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/flutter_tools/templates/app/pubspec.yaml.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: {{projectName}}
22
description: {{description}}
33
{{#withEmptyMain}}
44
publish_to: 'none'
5-
version: 0.1.0
5+
version: 0.1.0+1
66

77
environment:
88
sdk: {{dartSdkVersionBounds}}

packages/flutter_tools/test/commands.shard/permeable/create_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,6 +4752,19 @@ To keep the default AGP version $templateAndroidGradlePluginVersion, download a
47524752
}, getCurrentDirectory: () => out);
47534753
expect(logger.statusText, isNot(contains(r' $ cd')));
47544754
}, overrides: {Logger: () => logger});
4755+
4756+
testUsingContext('generated pubspec uses default build number (+1) for empty app', () async {
4757+
await projectDir.create(recursive: true);
4758+
4759+
await _createProject(
4760+
projectDir,
4761+
<String>['--no-pub', '--template=app', '--empty'],
4762+
<String>['lib/main.dart', 'pubspec.yaml'],
4763+
);
4764+
4765+
final String pubspec = await projectDir.childFile('pubspec.yaml').readAsString();
4766+
expect(pubspec, contains(RegExp(r'^version:\s*0\.1\.0\+1\s*$', multiLine: true)));
4767+
});
47554768
}
47564769

47574770
Future<void> _createProject(

0 commit comments

Comments
 (0)