flutter 元数据
Flutter is a next-generation cross-platform (Android, iOS, Web, Desktop, etc) app framework from Google with native performance (unlike React Native which has a JS bridge).
Flutter是Google提供的具有本机性能的下一代跨平台(Android,iOS,Web,桌面等)应用程序框架(不同于具有JS桥的React Native)。
Fastlane is a framework that helps automate uploading app package, changelog, screenshot, and many more useful items to marketplaces (e.g. Apple Appstore, Google Play Store).
Fastlane是一个框架,可帮助自动将应用程序包,更改日志,屏幕截图以及更多有用的项目上载到市场(例如Apple Appstore,Google Play商店)。
As Fastlane started before Flutter, Flutter was not part of its plan.
当Fastlane在Flutter之前开始时,Flutter并不是其计划的一部分。
Fortunately, Fastlane and Flutter play well together except a few metadata syncing issues.
幸运的是,除了一些元数据同步问题之外,Fastlane和Flutter可以很好地协同工作。
A typical Flutter project looks like the following:
一个典型的Flutter项目如下所示:
To add Fastlane to a Flutter project, we need to add Fastlane to each individual sub-project:
要将Fastlane添加到Flutter项目中,我们需要将Fastlane添加到每个单独的子项目中:
Although this approach works, it introduces an issue:
尽管此方法有效,但它引入了一个问题:
To make sure all platform has the same metadata (e.g. versioning information), Flutter defines all the metadata on the Flutter project level and pass down to sub-project level at compile time. 为了确保所有平台具有相同的元数据(例如版本信息),Flutter在Flutter项目级别定义了所有元数据,并在编译时传递给子项目级别。 Fastlane, as part of a sub-project, has no direct access to the metadata defined on the Flutter project which is one level up. 作为子项目的一部分,Fastlane无法直接访问Flutter项目(上一级)上定义的元数据。For example, Fastlane requires a version code to identify the corresponding metadata (e.g. changelog, screenshot, etc) to upload, but it won’t have access to it due to the issue:
例如,Fastlane需要一个版本代码来标识要上传的相应元数据(例如,变更日志,屏幕截图等),但由于该问题,它无法访问它:
As a result, many projects have to hard code a version in Fastlane script and manually sync with the Flutter project.
结果,许多项目必须使用Fastlane脚本对版本进行硬编码,并手动与Flutter项目同步。
Many experienced developers might have smelled danger already: when a number exists in two places, they will mismatch at some point, and the consequence is releasing an outdated app to the users. Whoops :(
许多经验丰富的开发人员可能已经闻到了危险:当两个地方存在一个数字时,它们有时会不匹配,结果是向用户发布了过时的应用程序。 哎呀:(
When I suddenly realize that I forgot to bump the version number right after merging a change :( 当我突然意识到合并变更后忘记了版本号时,:(The resolution to the issue is straightforward: grant Fastlane access to Flutter project metadata.
解决问题的方法很简单:授予Fastlane访问Flutter项目元数据的权限。
Thanks to the flutter_version Fastlane plugin, we can achieve this within a couple of lines of code.
感谢flutter_version Fastlane插件,我们可以在几行代码中实现这一目标。
As a Fastlane convention, to add a plugin, we need to define it in a Pluginfile:
作为Fastlane约定,要添加插件,我们需要在Pluginfile定义它:
To make sure the plugin is functional, run bundle install after making the change in Pluginfile.
为确保插件正常运行, bundle install在Pluginfile进行更改后运行bundle install 。
After the plugin finishes installing, we can use futter_version in the Fastfile to access Flutter project metadata. For example, version information:
插件安装完成后,我们可以使用futter_version中的Fastfile访问Flutter项目元数据。 例如,版本信息:
Note: flutter_version supports an optional input pubspec_location that defines a custom location of Flutter project metadata file if not in a conventional Flutter project setup. Currently, flutter_version returns the version code and version name. If the version defined in pubspec.yaml is 1.0.6+15 , then the version_code is 15 and the version_name is 1.0.6.
注意: flutter_version支持可选的pubspec_location输入,如果不是在传统的Flutter项目设置中,则该输入定义了Flutter项目元数据文件的自定义位置。 当前, flutter_version返回版本代码和版本名称。 如果pubspec.yaml定义的版本为1.0.6+15 ,则version_code为15, version_name为1.0.6 。
Since downloading packages from GitHub registry in CI/CD is a non-trivial setup, please use the following GitHub Action script as a starting point:
由于从CI / CD中的GitHub注册表中下载软件包是不平凡的设置,因此请使用以下GitHub Action脚本作为起点:
Thanks for reading and happy hacking!
感谢您的阅读和愉快的黑客入侵!
All kinds of contributions to the repository are appreciated. Let’s make cross-platform app developing experience better, together ;)
感谢对存储库的各种贡献。 让我们一起来改善跨平台应用程序的开发体验;)
翻译自: https://levelup.gitconnected.com/flutter-fastlane-tips-centralized-project-metadata-management-6de3fec21d37
flutter 元数据
相关资源:微信小程序源码-合集6.rar