快速集成 Flutter Shorebird 热更新

简介: Flutter Shorebird 是一种云端代码推送服务,可以让开发者在几分钟内集成,无需修改代码即可将更新推送到任何 Dart 代码,支持所有 Android 和 iOS 设备,并符合 App Store 和 Play Store 的规定。Shorebird 最大的优点是无代码侵入,快速集成,设计优秀。

快速集成 Flutter Shorebird 热更新

flutter shorebird

视频

https://youtu.be/0rBst-AB6_0

https://www.bilibili.com/video/BV1Bt421K7Mf

前言

原文 https://ducafecat.com/blog/flutter-shorebird-push-code-hot-updates-quickstart-guide

Flutter Shorebird 是一种云端代码推送服务,可以让开发者在几分钟内集成,无需修改代码即可将更新推送到任何 Dart 代码,支持所有 Android 和 iOS 设备,并符合 App Store 和 Play Store 的规定。Shorebird 最大的优点是无代码侵入,快速集成,设计优秀。

图片中显示的是手动更新补丁,而不是自动更新。

自动更新用户是无感的。

Flutter, Shorebird, 代码推送, 热更新, Flutter热更新

参考

https://shorebird.dev/

https://docs.shorebird.dev/

知识点

发布与补丁对应

release path

使用顺序

shorebird use

第一步:注册、安装

关联 google 账号

https://console.shorebird.dev/login

管理你的 google , 热更新二进制文件将会上传到 google cloud。

安装 shorebird 命令 cli

macos

curl --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/shorebirdtech/install/main/install.sh -sSf | bash

windows

Set-ExecutionPolicy RemoteSigned -scope CurrentUser # Needed to execute remote scripts
iwr -UseBasicParsing 'https://raw.githubusercontent.com/shorebirdtech/install/main/install.ps1'|iex

检查环境

> shorebird doctor

Shorebird 1.1.6 • git@github.com:shorebirdtech/shorebird.git
Flutter 3.22.0 • revision 6d047e401941206daf11740c523ffa3364a2385b
Engine • revision c600950be82dcdad6a46da46bcc6e73773ca3907

✓ Shorebird is up-to-date (3.6s)
✗ Flutter install is correct (1.1s)
  [!] Shorebird does not respect the FLUTTER_STORAGE_BASE_URL environment variable at this time
✓ Has access to storage.googleapis.com (0.9s)
1 issue detected.

命令行登录

> shorebird login

You are already logged in as <ducafecat@gmail.com>.
Run shorebird logout to log out and try again.

第二步:初始你的项目

环境要求

> flutter --version

Flutter 3.22.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5dcb86f68f (2 周前) • 2024-05-09 07:39:20 -0500
Engine • revision f6344b75dc
Tools • Dart 3.4.0 • DevTools 2.34.3

开发环境需要和 shorebird 一致, flutter sdk 3.22.0

初始你的项目

> shorebird init

✓ No product flavors detected. (4.4s)
? How should we refer to this app? (flutter_application_shorebird) flutter_application_shorebird

 Shorebird initialized successfully!

 A shorebird app has been created.
 A "shorebird.yaml" has been created.
 The "pubspec.yaml" has been updated to include "shorebird.yaml" as an asset.

Reference the following commands to get started:

 To create a new release use: "shorebird release".
 To push an update use: "shorebird patch".
 To preview a release use: "shorebird preview".

For more information about Shorebird, visit https://shorebird.dev
✓ Shorebird is up-to-date (2.9s)
✗ Flutter install is correct (1.0s)
  [!] Shorebird does not respect the FLUTTER_STORAGE_BASE_URL environment variable at this time
✓ AndroidManifest.xml files contain INTERNET permission (1 fix applied) (0.1s)
✓ Has access to storage.googleapis.com (0.7s)
✓ shorebird.yaml found in pubspec.yaml assets (5ms)

第三步:发布、热更新

编译发布版本

编译 android aab 文件,提交 google 后台

shorebird release android

输出

❯ shorebird release android 

✓ Fetching apps (0.9s)
✓ Building app bundle with Flutter 3.22.0 (6d047e4019) (48.6s)
✓ Release version: 1.0.0+1 (0.4s)
✓ Fetching releases (0.8s)

 Ready to create a new release!

 App: flutter_application_shorebird (c204bc07-5755-4e3c-966f-2fcb3f50272f)
 Release Version: 1.0.0+1
  Platform: android
 Flutter Version: 3.22.0 (6d047e4019)

Would you like to continue? (y/N) Yes
✓ Fetching releases (0.8s)
✓ Creating release (1.5s)
✓ Updating release status (0.8s)
✓ Creating artifacts (33.9s)
✓ Updating release status (2.5s)

 Published Release 1.0.0+1!
Your next step is to upload the app bundle to the Play Store:
/Users/ducafecat/Desktop/flutter_application_shorebird/build/app/outputs/bundle/release/app-release.aab

For information on uploading to the Play Store, see:
https://support.google.com/googleplay/android-developer/answer/9859152?hl=en

To create a patch for this release, run shorebird patch --platforms=android --release-version=1.0.0+1

Note: shorebird patch --platforms=android without the --release-version option will patch the current version of the app.

编译 android apk 文件,方便内部测试

shorebird release android --artifact apk
> shorebird release android --artifact apk 

✓ Fetching apps (0.8s)
✓ Building app bundle with Flutter 3.22.0 (6d047e4019) (7.3s)
✓ Building APK with Flutter 3.22.0 (6d047e4019) (8.1s)
✓ Release version: 1.0.0+1 (0.4s)
✓ Fetching releases (0.7s)
It looks like you have an existing android release for version 1.0.0+1.
Please bump your version number and try again.

You can manage this release in the Shorebird Console

编译 ios 文件

shorebird release ios

xcode 配置好证书

用户安装

通过 adb ,或者平台安装

编译补丁

shorebird patch android

输出

❯ shorebird patch android 

✓ Fetching apps (2.0s)
✓ Building patch with Flutter 3.22.0 (6d047e4019) (6.0s)
✓ Fetching releases (0.8s)
✓ Fetching aab artifact (0.8s)
✓ Downloading aab (5.0s)
✓ Verifying patch can be applied to release (38ms)
✓ Fetching release artifacts (2.3s)
✓ Downloading release artifacts (8.2s)
✓ Creating patch artifacts (1.5s)

 Ready to publish a new patch!

 App: flutter_application_shorebird (c204bc07-5755-4e3c-966f-2fcb3f50272f)
 Release Version: 1.0.0+1
  Platform: android [arm32 (130 B), arm64 (126 B), x86_64 (122 B)]
 Track: Production

Would you like to continue? (y/N) Yes
✓ Creating patch (2.5s)
✓ Uploading artifacts (5.5s)
✓ Fetching channels (0.8s)
✓ Promoting patch to stable (0.7s)

 Published Patch 1!

每次都有一个新 patch 编号

自动更新

你重新打开程序后 ,自动更新了程序

第四步:手动热更新(可选)

各种理由我们有时候需要一个选择是否更新的选项,比如测试的时候。

编辑 shorebird.yaml

auto_update: false

设置 false 关闭自动更新

重新编译一个新版本、新补丁 patch

具体参考代码可以看我的 github 代码,我已经跑通,这里就不再详述

https://github.com/ducafecat/flutter_develop_tips/blob/main/flutter_application_shorebird/lib/main.dart

代码

https://github.com/ducafecat/flutter_develop_tips/tree/main/flutter_application_shorebird

小结

Flutter Shorebird 是一个强大的云端代码推送解决方案,可以让开发者在几分钟内集成,无需修改代码即可将更新推送到任何 Dart 代码,支持所有 Android 和 iOS 设备。这种技术不仅能够提高应用的更新效率,还符合 App Store 和 Play Store 的发布要求,是 Flutter 开发者必须了解的重要技术之一。通过结合 Flutter 的跨平台优势和 Shorebird 的云端部署能力,开发者可以更高效地管理和更新他们的应用程序,为用户提供更好的体验。

感谢阅读本文

如果有什么建议,请在评论中让我知道。我很乐意改进。


flutter 学习路径


© 猫哥
ducafecat.com

end

相关文章
|
5月前
|
移动开发 监控 安全
mPaaS常见问题之Android集成dexPatch热修复运行时候无法正常进行热更新如何解决
mPaaS(移动平台即服务,Mobile Platform as a Service)是阿里巴巴集团提供的一套移动开发解决方案,它包含了一系列移动开发、测试、监控和运营的工具和服务。以下是mPaaS常见问题的汇总,旨在帮助开发者和企业用户解决在使用mPaaS产品过程中遇到的各种挑战
|
2月前
|
数据可视化 Linux Android开发
Flutter相关痛点解决问题之研发链路中的环境配置和打包集成问题如何解决
Flutter相关痛点解决问题之研发链路中的环境配置和打包集成问题如何解决
|
2月前
|
Android开发 Kotlin
Flutter集成fluwx编译出错:compileReleaseKotlin
Flutter集成fluwx编译出错:compileReleaseKotlin
32 2
|
2月前
|
iOS开发 Perl
IOS集成flutter_boost 3.0常见问题
IOS集成flutter_boost 3.0常见问题
39 0
|
4月前
|
安全 定位技术 API
探讨如何在Flutter中集成支付、地图等第三方服务,以及集成过程中需要注意的问题和最佳实践
【6月更文挑战第11天】本文介绍了在Flutter中集成第三方服务,如支付和地图,以增强应用功能和用户体验。开发者可通过官方或社区插件集成服务,注意服务选择、API调用、错误处理和用户体验。支付集成涉及选择服务、获取API密钥、引入插件、调用API及处理结果。地图集成则包括选择地图服务、获取API密钥、初始化地图组件和添加交互功能。集成时要选择稳定插件、仔细阅读文档,处理错误,优化性能并遵循安全规范。随着Flutter生态发展,更多优质服务将可供选择。
84 2
|
5月前
|
Dart 前端开发 开发者
【Flutter前端技术开发专栏】Flutter中的热重载与热更新机制
【4月更文挑战第30天】Flutter框架提供热重载(Hot Reload)和热更新(Hot Restart)功能,加速开发和迭代。热重载在应用运行时实时应用代码更改,保持应用状态,适合快速查看效果;热更新则重新启动应用,适用于更广泛的变化,但仍比冷启动快。开发者可通过`flutter run`命令或快捷键触发这两项功能。然而,应注意代码兼容性、性能影响及不支持的更改。这两机制提升开发效率,优化用户体验。
603 0
【Flutter前端技术开发专栏】Flutter中的热重载与热更新机制
|
5月前
|
前端开发 定位技术 API
【Flutter前端技术开发专栏】Flutter中的第三方服务集成(如支付、地图等)
【4月更文挑战第30天】本文介绍了在Flutter中集成第三方服务,如支付和地图,以增强应用功能和用户体验。开发者可通过官方或社区插件集成服务,关注服务选择、API调用、错误处理和用户体验。支付集成涉及选择服务、获取API密钥、引入插件、调用API及处理结果。地图集成则需选择地图服务、获取API密钥、初始化地图并添加交互功能。集成时注意选择稳定插件、阅读文档、处理异常、优化性能和遵循安全规范。随着Flutter生态发展,更多第三方服务将可供选择。
69 0
【Flutter前端技术开发专栏】Flutter中的第三方服务集成(如支付、地图等)
|
5月前
|
Dart 前端开发 Android开发
【Flutter前端技术开发专栏】Flutter与原生代码的集成与交互
【4月更文挑战第30天】本文探讨了如何在Flutter中集成和交互原生代码,以利用特定平台的API和库。当需要访问如蓝牙、特定支付SDK或复杂动画时,集成原生代码能提升效率和性能。集成方法包括:使用Platform Channel进行通信,借助现有Flutter插件,以及Android和iOS的Embedding。文中通过一个电池信息获取的例子展示了如何使用`MethodChannel`在Dart和原生代码间传递调用。这些技术使开发者能充分利用原生功能,加速开发进程。
89 0
【Flutter前端技术开发专栏】Flutter与原生代码的集成与交互
|
5月前
|
传感器 前端开发 Android开发
【Flutter 前端技术开发专栏】Flutter 中的插件开发与集成
【4月更文挑战第30天】本文探讨了Flutter插件开发的关键技术和实践,包括插件作为连接Flutter与原生功能桥梁的角色,开发流程(定义接口、实现原生代码、打包发布),以及集成方法(添加依赖、初始化)。文中提到了多媒体、传感器和文件系统等常见插件类型,并以相机插件为例说明开发步骤。此外,还强调了版本兼容性、性能优化和错误处理的注意事项,推荐了开发工具和资源。随着Flutter的发展,插件开发将更加重要,未来有望形成更丰富的生态系统。
73 0
【Flutter 前端技术开发专栏】Flutter 中的插件开发与集成
|
5月前
|
运维 监控 安全
应用研发平台EMAS常见问题之sophix ios flutter热更新如何解决
应用研发平台EMAS(Enterprise Mobile Application Service)是阿里云提供的一个全栈移动应用开发平台,集成了应用开发、测试、部署、监控和运营服务;本合集旨在总结EMAS产品在应用开发和运维过程中的常见问题及解决方案,助力开发者和企业高效解决技术难题,加速移动应用的上线和稳定运行。
161 0

热门文章

最新文章

下一篇
无影云桌面