Flutter CodePush using Shorebird

Image Source:

Introduction

It is a nightmare scenario to find a bug in our mobile applications after publishing the apps. We should fix the bug, create new versions, and upload them to Google Play and the App Store. This is not the worst part. We have to wait until the releases are approved by the stores. Sometimes they are rejected, and we create new versions. Almost all of us experience this scenario, and we know how unnecessary it is.

Now we have a solution to fix our app without publishing them to the stores. Shorebird is a code-push solution for Flutter, and it is stable for Android and iOS now.

It was built along with flutter experts :"

Eric Seidel, who is also the Founder of Flutter & former Director of Engineering for Flutter/Dart at Google.

Felix Angelov, who is also the creator of Bloc & Mason,former Principal Engineer at Very Good Ventures.

Bryan Oltman, who is also former architecture lead for Google's internal-facing enterprise Flutter team.

Erick Zanardo, who is also Flutter & Dart GDE. Flame Core member. Previously at Very Good Ventures.

History and Evolution

In the ever-evolving world of mobile app development, the need for rapid updates and seamless deployments has driven innovation in various tools and technologies. One such tool that has significantly impacted the landscape is CodePush. Initially introduced by Microsoft, CodePush has evolved over the years to become a pivotal solution for developers seeking efficient over-the-air updates for their mobile applications. This article delves into the history and evolution of CodePush, exploring its origins, key milestones, and current state.

Origins of CodePush

CodePush was born out of the need to address a common challenge faced by mobile developers: the cumbersome process of distributing updates through app stores. Traditionally, developers had to wait for app store approvals before their updates could reach users, causing delays and hampering the user experience. In response, Microsoft introduced CodePush in 2015 as part of its Visual Studio App Center suite, aiming to simplify the update process and enable real-time deployment of code changes.

Key Milestones in CodePush's Evolution

Initial Launch (2015): CodePush was launched as a cloud service that allowed developers to push updates directly to their mobile apps. It supported React Native and Cordova, providing a seamless experience for developers using these frameworks. This initial release was met with enthusiasm, as it significantly reduced the time and effort required to deliver updates.

Integration with Visual Studio App Center (2017): As part of Microsoft's broader strategy to provide comprehensive mobile development solutions, CodePush was integrated into Visual Studio App Center. This integration brought additional features such as analytics, crash reporting, and automated testing, creating a unified platform for managing the entire app lifecycle.

Support for More Frameworks (2018-2019): Recognizing the diverse needs of mobile developers, CodePush expanded its support to include more frameworks such as Ionic and Xamarin. This move broadened its user base and reinforced its position as a versatile tool for mobile app updates.

Community Contributions and Open Source (2019): Microsoft decided to open source the CodePush client SDKs, fostering community contributions and collaboration. This decision not only enhanced the tool's capabilities but also ensured its continued growth and improvement through collective efforts.

Enhancements and Performance Improvements (2020-2022): Over the years, CodePush underwent several enhancements to improve its performance, security, and usability. These improvements included better rollback mechanisms, enhanced update delivery speed, and more robust error handling, ensuring a smooth experience for both developers and users.

Problem Statement

Detailed Problem Description:

In the fast-paced world of mobile app development, delivering timely updates to users is critical. However, without a tool like CodePush, developers face several significant challenges:

Manual Update Process: Developers must rely on the traditional app store update process, which involves submitting updates to the app stores (Apple App Store and Google Play Store) and waiting for approval. This can be a time-consuming process, often taking several days or even weeks, depending on the app store's review queue and the nature of the update.

Delayed Bug Fixes: In the event of a critical bug or security vulnerability, the delay in app store approval can leave users exposed for an extended period. This can lead to a poor user experience, negative reviews, and potential security risks.

Fragmented User Base: Users tend to update their apps at different times, leading to a fragmented user base with various versions of the app in use simultaneously. This fragmentation complicates support and debugging efforts, as developers must account for multiple versions of the app when diagnosing and resolving issues.

Resource Intensive: The traditional update process requires significant resources, including time and effort from developers and QA teams to ensure that the update is properly packaged, tested, and submitted. Additionally, the need to manage the deployment schedule and coordinate with marketing and support teams adds to the complexity.

Inability to A/B Test: Without a tool like CodePush, implementing A/B testing or phased rollouts of new features is challenging. Developers lack the flexibility to quickly push out updates to a subset of users to gather feedback and make data-driven decisions.

Relevance to the Audience:

This problem is highly relevant to mobile app developers, project managers, and business stakeholders in the mobile app industry. Specifically, it affects:

  • Developers and QA Teams: These teams are directly impacted by the inefficiencies and delays in the traditional update process. They face increased workload and stress when dealing with critical bug fixes and feature releases.
  • Product Managers: Delays in delivering updates can disrupt product roadmaps and hinder the ability to respond quickly to user feedback and market demands. This can negatively impact the app's competitiveness and user satisfaction.
  • Business Stakeholders: The inability to quickly address issues and deliver new features can lead to decreased user retention, lower app ratings, and potential revenue loss. Ensuring a seamless user experience is crucial for maintaining a strong brand reputation and achieving business goals.
  • End Users: Ultimately, the end users suffer from delayed updates, prolonged exposure to bugs and security vulnerabilities, and inconsistent app experiences. This can result in frustration, decreased engagement, and higher churn rates.

In summary, the absence of a tool like CodePush creates significant challenges for all stakeholders involved in mobile app development and maintenance. Addressing these challenges is crucial for improving efficiency, enhancing user satisfaction, and maintaining a competitive edge in the market.

CodePush Concept

An explanation of the concepts used in Shorebird’s code push product.

Code Push

Code push, also referred to as “over the air updates” (OTA) is a cloud service enabling Flutter developers to deploy updates to their apps in production. Shorebird currently works on Android and iOS and will eventually work everywhere Flutter works.

”Code Push” is a reference to the name of a deploy feature used by the React Native community from Microsoft and Expo, neither of which support Flutter.

Patching

Patching is the process of updating an application’s code without requiring the user to download a new version from the App Store or Play Store. This is done by creating a patch, which is a set of changes to the application’s code that can be applied over-the-air.

What types of changes can be included in a patch?

Patches can change any Dart code in your application. This includes:

  • App code
  • Generated code
  • Dependencies in pubspec.yaml, as long as they don’t include native code changes.


This does not include:

  • Asset files (images, fonts, etc.), although we have plans to support this in the near future (see https://github.com/).
  • Native code (e.g. Java/Kotlin on Android or Objective-C/Swift on iOS).
  • Flutter engine changes (i.e., changes the Flutter version of your app).

Glossary

Application

An application is what is created by running "flutter create [app_name]" and corresponds to a listing in the App Store or Play Store.

Each application has a unique "app_id" that is assigned when you run "shorebird init". You can find your application’s id in the "shorebird.yaml" file at the root of your project.

An application can have zero or more releases.

Note

Applications that use build flavors will have a unique "app_id" for each flavor.

Release

A release is a specific version of an application, identified by a version and build number (e.g. 1.0.0+1). Although code push works for apps distributed outside of the App.


Store and Play Store, a release most often corresponds with a specific version of your app that is published to the App Store or Play Store.

Releases are created by running "shorebird release [platform]", where "platform" is "android", "aar", or "ios".

Patch

A patch is a change to a specific release, applied as an over-the-air update. For example, a patch could be a bug fix or a new feature. Multiple patches can be published for a given release, although only one patch can be active at a time. Patches are identified by their associated release version and a patch number, which is an auto-incrementing integer.

When your application starts, it checks for available patches and applies the latest one. This patch will be visible the next time your application launches.

Patches are created by running "shorebird release [platform]", where  "platform" is "android", "aar", or "ios".

Artifact

An artifact is the output of a build or patch operation. For example:

"shorebird release android" generates and uploads several architecture-specific "libapp.so" files and an Android archive (.aab) file. These are release artifacts.

"shorebird patch android" generates and uploads diff files that capture differences between your Dart code at patch time and the code in the associated release. These are patch artifacts.


Limitations

  • Asset files (images, fonts, etc.), although we have plans to support this in the near future (see https://github.com/).
  • Native code (e.g. Java/Kotlin on Android or Objective-C/Swift on iOS).
  • Flutter engine changes (i.e., changes the Flutter version of your app).

Future Outlook

Shorebird is available on Android and iOS, with ~1000 apps using Shorebird on the App Store and Play Store.

Link Percentage (iOS)

As part of complying with the the App Store guidelines, Shorebird uses an interpreter on iOS to run any changed Dart code in your patch. This interpreter runs Dart about 100x slower than running on the CPU. To make patches run fast, Shorebird has modified the Dart compiler and runtime to make it possible to only run changed code on the interpreter and run any unchanged code on the CPU. This determination is done at a per-function level.

The program that decides which code runs on the CPU vs the interpreter is called the “linker” and we call this percentage the “link percentage”.

Most of the time this system works very well, and Shorebird is able to run 90%+ of your Dart code on the CPU. However there are still a few types of changes which can confuse the “linker” into running more code on the interpreter than necessary.

Known linker issues include: IOS possible low link percentage

Conclusion

In conclusion, the combination of Flutter's powerful development framework and Shorebird's continuous deployment capabilities provides a comprehensive solution to the traditional challenges of mobile app updates. By embracing these tools, developers can ensure a seamless, efficient, and user-centric approach to app development and maintenance, ultimately driving success in the competitive mobile app market.

References

[1]
[2]
[3]
[4]
[5]
[6]
[7]

Contents

Share

Written By

James Mathew

Flutter Developer

Versatile Flutter developer skilled in creating exceptional user experiences for web, mobile applications, and cross-platform development. My proficiency spans the spectrum, ensuring cohesive and polished results across diverse platforms. Crafting seamless and engaging interfaces isn't just a job for me – it's my dedication and passion

Contact Us

We specialize in product development, launching new ventures, and providing Digital Transformation (DX) support. Feel free to contact us to start a conversation.