Reader small image

You're reading from  Flutter Cookbook, Second Edition - Second Edition

Product typeBook
Published inMay 2023
Reading LevelIntermediate
PublisherPackt
ISBN-139781803245430
Edition2nd Edition
Languages
Tools
Right arrow
Author (1)
Simone Alessandria
Simone Alessandria
author image
Simone Alessandria

Simone Alessandria wrote his first program when he was 12. It was a text-based fantasy game for the Commodore 64. Now, he is a trainer (MCT), author, speaker, passionate software architect, and always a proud coder. He is the founder and owner of Softwarehouseit. His mission is to help developers achieve more through training and mentoring. He has authored several books on Flutter, including Flutter Projects, published by Packt, and web courses on Pluralsight and Udemy.
Read more about Simone Alessandria

Right arrow

Distributing Your Mobile App

In this chapter, you will explore how to publish your app in the main mobile stores: Google Play and the Apple App Store. There are many small tasks that app developers need to perform when distributing their apps. Thankfully, some of these tasks can be automated. This includes code signing, writing metadata, incrementing build numbers, and creating icons.

We will be using the platform portals and fastlane, a tool currently owned by Google. At its core, fastlane is a set of scripts that automates the deployment of iOS and Android apps. Some scripts are only available for iOS, but it’s still a great tool that can save you a lot of time.

The main fastlane tools you can leverage for your app’s deployment include the following:

  • cert to create and maintain signing certificates
  • sigh to manage provisioning profiles
  • gym to build and sign your apps
  • deliver to upload your apps, screenshots, and metadata to the...

Technical requirements

All the recipes in this chapter assume you have purchased a developer account from Apple and Google. You can also decide to use only one of the two stores. In this case, just follow the instructions for your platform: Android for the Play Store and iOS for the App Store. Also, note that you need a Mac with Xcode to publish to the App Store.

Registering your iOS app on App Store Connect

App Store Connect is a set of tools that you can use to manage the apps you want to publish into the Apple App Store. These include all apps made for mobile devices, such as iPhone, iPad, and Apple Watch, and larger devices such as Mac and Apple TV.

Before using the App Store Connect service, you need to enroll in the Apple Developer Program. See https://developer.apple.com/programs/ for more information.

In this recipe, you will complete the first steps required to publish your app to the App Store.

Getting ready

Before publishing an app to the App Store, you should have an Apple Developer Program subscription. This is a paid subscription and a prerequisite for this recipe and all the other recipes in this chapter that target iOS.

In order to follow the App Store Connect publication steps, you should have a Mac with Xcode installed.

You should also have an app that’s ready to be published, at...

Registering your Android app on Google Play

The hub where you publish and manage apps in the Google Play Store is the Google Play Console, which you can access at https://play.google.com/console.

In this recipe, you will create an entry for your app in the Google Play Console, and thus understand the first step to publish your apps into the main Android store.

This is actually a very quick process.

Getting ready

Before publishing an app to the Google Play Store, you should have a Google Developer account; you can get one for a one-time fee, and it is a prerequisite for this recipe and all the other recipes in this chapter that target Android.

You should also have an app ready to be published, at least in beta.

How to do it...

You will now create a new entry for your app in the Google Play Store. Follow these steps:

  1. Go to the Google Play Console at https://play.google.com/console.
  2. Click on the Create app button at the top right of the page...

Installing and configuring fastlane

Publishing an app to these stores is a long and cumbersome process; it may well take a full day of work for the initial publishing, and then hours for each update you make to the app. That’s why automation tools such as fastlane can boost your productivity by automating several tasks required to deal with the publishing process and keep you focused on designing and developing your apps.

For more information about fastlane, have a look at https://fastlane.tools/.

You will now see the setup and configuration process for fastlane.

Getting ready

Before following along with this recipe, you should have completed the previous recipes in this chapter: Registering your iOS app on App Store Connect for iOS and Registering your Android app on Google Play for Android.

How to do it...

In this recipe, you will set up fastlane for Windows, macOS, Android, and iOS. Follow the steps in the following sections.

Installing...

Generating iOS code signing certificates and provisioning profiles

fastlane contains a set of command-line tools. One of them is fastlane match, which allows sharing a code signing identity with your development team.

In this recipe, you will learn how to leverage fastlane match to create signing certificates for your apps and store them in a Git repository.

Getting ready

Before following along with this recipe, you should have completed the previous recipes in this chapter: Registering your iOS app on App Store Connect and Installing and configuring fastlane.

How to do it...

You will now create a new Git repo and use fastlane match to retrieve and store your certificates in your repository. Follow these steps:

  1. Create a private Git repository at github.com. You can find the details of the procedure at https://docs.github.com/en/github/getting-started-with-github/create-a-repo.
  2. In the ios directory of your project, from the Terminal, type the...

Generating Android release certificates

keytool is a Java utility that manages keys and certificates. The keytool utility stores the keys and certificates in a keystore.

In this recipe, you will understand how to use the keytool utility to generate Android certificates. This step is required to sign and publish your app in the Google Play Store.

Getting ready

Before following along with this recipe, you should have completed the previous recipes in this chapter: Registering your Android app on Google Play and Installing and configuring fastlane.

How to do it...

You will now create an Android keystore. Follow these steps:

  1. On Mac/Linux, use the following command:
    keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
    
  2. On Windows, use the following command:
    keytool -genkey -v -keystore c:\Users\USER_NAME\key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias androidkey
    
    ...

Configuring your app metadata

Before uploading your app to the stores, you need to complete some settings specific to the platform (iOS or Android) you are targeting.

In this recipe, you will learn how to set the AndroidManifest.xml file for Android to add the required metadata and permissions, and the runner.xcworkspace file to edit your app name and bundle ID for iOS.

Getting ready

Before following along with this recipe, you should have completed all the previous recipes in this chapter, or at least those that target your specific platform (iOS or Android).

How to do it...

You will now set some required metadata in the AndroidManifest.xml and runner.xcworkspace files.

Adding Android metadata

By following these steps, you will edit the AndroidManifest.xml file and add the required configuration to publish your app:

  1. Open the AndroidManifest.xml file, in the android/app/src/main directory.
  2. Set the android:label value in the application...

Adding icons to your app

Icons help users identify your app on their devices, and they are also a requirement to publish your app into the stores.

In this recipe, you will see how to automatically add icons to your app in all the required formats by using a Flutter package called flutter_launcher_icons.

Getting ready

Before following along with this recipe, you should have completed all the previous recipes in this chapter, or at least those that target your specific platform (iOS or Android).

How to do it...

You will now add the flutter_launcher_icons package to your app and use it to add icons to your iOS and Android apps. Follow these steps:

  1. Create a new directory in the root of your project, called icons.
  2. Create or retrieve an icon for your app if you haven’t already added one, and place it in the icons directory.

    You can get an icon for free at several websites, including https://remixicon.com/. If you use this specific...

Publishing a beta version of your app in the Google Play Store

Before making your app available in release mode, it’s considered a best practice to have a smaller group of people test your app. It can be a small group of specific people, such as your team or your customers, or a larger group of people. In any case, publishing a beta version can give you invaluable feedback on your app. In this recipe, you will see how to publish your app in a beta track in the Google Play Store.

Getting ready

Before following along with this recipe, you should have completed all the previous recipes in this chapter, or at least those that target Android.

How to do it...

You will compile your app in release mode and upload it to the Google Play Store in beta. To do so, follow these steps:

  1. Open the fastfile file into your project’s android/fastlane directory.
  2. If, in the file, there is already a beta lane, comment it out.
  3. At the bottom of the platform...

Using TestFlight to publish a beta version of your iOS app

TestFlight is a tool developed by Apple that allows you to share your app with other users by inviting them with an email or by creating a link. In this recipe, you will see how to create, sign, and publish an iOS app leveraging fastlane and TestFlight.

Getting ready

Before following along with this recipe, you should have completed all the previous recipes in this chapter that target iOS.

How to do it...

Using the following set of steps, you will build and sign your iOS app and publish it to TestFlight:

  1. From Xcode, open the Runner.xcodeproj file.
  2. Click on the Signing tab and select or add your development team (this is the team associated with your Apple developer account).
  3. Sign in to your Apple ID account page at https://appleid.apple.com/account/manage.
  4. In the Security section, click the Generate Password link under the APP-SPECIFIC PASSWORDS label.
  5. Choose a name for...

Publishing your app to the stores

Once you have released your app as a beta version in the Google Play Console and in TestFlight, publishing it to production is very easy. In this recipe, you will see the steps required to finally see your app in the stores.

Getting ready

Before following along with this recipe, you should have completed all the previous recipes in this chapter, or at least those that target your specific platform (iOS or Android).

How to do it...

You will now see how to move your beta app to production, both in the Google Play Store and in the Apple App Store.

Moving your app to production in the Play Store

Using the following steps, you will move your Android app from beta to production:

  1. Go to the Google Play Console at https://play.google.com/apps/publish and select your app.
  2. On your app dashboard, click on the Releases overview link on the left.
  3. In the Latest releases section, click on your testing release.
  4. ...

Summary

In this chapter, you have seen how to publish your app in the main mobile stores, Google Play and the Apple App Store, and the many small tasks that app developers need to perform when distributing their apps. For some of those, you have leveraged fastlane, a powerful tool that offers a set of scripts to automate the deployment of iOS and Android apps.

You have learned how to register your iOS app on App Store Connect and your Android app on Google Play.

You have learned how to install and configure fastlane, generate iOS code signing certificates and provisioning profiles, and generate Android release certificates.

You have configured your app metadata, providing essential information about your app to users and the stores, and seen how to add icons to your app.

You have looked into the process of publishing beta versions of your app using the Google Play Store for Android and TestFlight for iOS: this enables you to receive feedback from beta testers before...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Flutter Cookbook, Second Edition - Second Edition
Published in: May 2023Publisher: PacktISBN-13: 9781803245430
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Simone Alessandria

Simone Alessandria wrote his first program when he was 12. It was a text-based fantasy game for the Commodore 64. Now, he is a trainer (MCT), author, speaker, passionate software architect, and always a proud coder. He is the founder and owner of Softwarehouseit. His mission is to help developers achieve more through training and mentoring. He has authored several books on Flutter, including Flutter Projects, published by Packt, and web courses on Pluralsight and Udemy.
Read more about Simone Alessandria