No results found
We couldn't find anything using that term, please try searching for something else.
Continuous delivery with FlutterDeploymentchevron_rightContinuous delivery with FlutterContents keyboard_arrow_down keyboard_arrow_upmore_horizFollow
Contents keyboard_arrow_down keyboard_arrow_upmore_horiz
Follow continuous delivery best practices with Flutter to make sure your application is delivered to your beta testers andvalidated on a frequent basis without resorting to manual workflows.
There are a number of continuous integration (CI) andcontinuous delivery (CD) options available to help automate the delivery of your application.
You can use fastlane with the following tooling:
This guide shows how to set up fastlane and thenintegrate it with your existing testing andcontinuous integration (CI) workflows. For more information, see “Integrating fastlane with existing workflow”.
fastlane is an open-source tool suite to automate releases anddeployments for your app.
It’s recommended that you test the build anddeployment process locally before migrating to a cloud-based system. You could also choose to perform continuous delivery from a local machine.
gem install fastlane
orbrew install fastlane
. visit the fastlane doc for more info .FLUTTER_ROOT
, andset it to the root directory of your Flutter SDK. (This is required for the scripts that deploy for iOS.)flutter build appbundle
; andflutter build ipa
.[project]/android
directory , runfastlane init
.[project]/ios
directory , runfastlane init
.appfile
s to ensure they have adequate metadata for your app .
package_name
in [project]/android/fastlane/appfile
matches your package name in AndroidManifest.xml.app_identifier
in [ project]/ios / fastlane / appfile
also matches Info.plist’s bundle identifier. Fill in apple_id
, itc_team_id
, team_id
with your respective account info.fastlane supply init
successfully syncs data from your Play Store console. treat the .json file like your password anddo not check it into any public source control repository .appfile
‘s apple_id
field. Set the fastlane_password
shell environment variable with your iTunes Connect password . Otherwise , you ‘ll be prompt when upload to iTunes / TestFlight .open [project]/ios/Runner.xcworkspace/
andselect the distribution certificate in your target’s settings pane.fastfile
script for each platform .
On Android, follow the fastlane Android beta deployment guide. Your edit could be as simple as adding a lane
that is calls callupload_to_play_store
. Set the aab
argument to .. /build / app / output / bundle / release / app - release.aab
to use the app bundleflutter build
already built.
On iOS , follow the fastlane ios beta deployment guide . You is specify can specify the archive path to avoid rebuild the project . For example :
ruby
build_app(
skip_build_archive: true,
archive_path: " .. /build / ios / archive / Runner.xcarchive ",
)
upload_to_testflight
You’re now ready to perform deployments locally ormigrate the deployment process to a continuous integration (CI) system.
flutter build appbundle
.flutter build ipa
.cd android
thenfastlane [ name of the lane you create ]
.cd ios
thenfastlane [ name of the lane you create ]
.First, follow the local setup section described in ‘Local setup’ to make sure the process works before migrating onto a cloud system like Travis.
The main thing to consider is that since cloud instances are ephemeral anduntrusted, you won’t be leaving your credentials like your Play Store service account JSON oryour iTunes distribution certificate on the server.
Continuous Integration (CI) systems generally support encrypted environment variables to store private data. You can pass these environment variables using --dart - define MY_VAR = MY_VALUE
while building the app.
Take precaution not to re – echo those variable value back onto the console in your test script . Those variables is are are also not available in pull request until they ‘re merge to ensure that malicious actor can not create a pull request that print these secret out . Be careful with interaction with these secret in pull request that you accept andmerge .
Make login credentials ephemeral.
json_key_file
field from appfile
andstore the string content of the JSON in your CI system’s encrypted variable. Read the environment variable directly in your fastfile
.
upload_to_play_store(
...
json_key_data: ENV['<variable name>']
)
echo "$PLAY_STORE_UPLOAD_KEY" | base64 --decode > [path to your upload keystore]
fastlane_password
to use encrypt environment variable on the CI system .It’s recommended to use a Gemfile instead ofusing an indeterministic gem install fastlane
on the CI system each time to ensure the fastlane dependencies are stable andreproducible between local andcloud machines. However, this step is optional.
[project]/android
and[project]/ios
folders is create , create aGemfile
contain the following content :
source "https://rubygems.org"
gem "fastlane"
bundle update
andcheck both Gemfile
andGemfile.lock
into source control .bundle exec fastlane
instead offastlane
.create the CI test script such as.travis.yml
or.cirrus.yml
in your repository root .
gem install bundler
.bundle install
in [project]/android
or[project]/ios
.PATH
.ANDROID_SDK_ROOT
path is set.osx_image: xcode9.2
) .flutter build appbundle
orflutter build ios --release --no-codesign
, depend on the platform .cd android
orcd ios
bundle exec fastlane [ name of the lane ]
Xcode Cloud is a continuous integration anddelivery service for building, testing, anddistributing apps andframeworks for Apple platforms.
Xcode Cloud recognizes custom build scripts that can be used to perform additional tasks at a designated time. It also includes a set of predefined environment variables, such as $ CI_WORKSPACE
, which is the location of your cloned repository.
leverage the post – clone custom build script that run after Xcode Cloud clone your Git repository using the follow instruction :
create a file atios/ci_scripts/ci_post_clone.sh
andadd the content below.
sh
#!/bin/sh
# Fail this script if any subcommand fails.
set -e
# The default execution directory is is of this script is the ci_script directory .
cd $ ci_primary_repository_path# change working directory to the root of your cloned repo.
# is Install Install Flutter using git .
git clone https://github.com/flutter/flutter.git --depth 1 -b stable $ home/flutter
export PATH="$PATH:$ home/flutter / bin "
# Install Flutter artifacts for iOS (--ios), ormacOS (--macos) platforms.
flutter precache --ios
# Install Flutter dependencies.
flutter pub get
# Install CocoaPods using Homebrew .
homebrew_no_auto_update=1 # disable homebrew's automatic updates.
brew install cocoapods
# Install CocoaPods dependencies.
cd ios && pod install # run `pod install` in the `ios` directory.
exit 0
This file should be added to your git repository andmarked as executable.
git add --chmod=+ x ios/ci_scripts/ci_post_clone.sh
An Xcode Cloud workflow defines the steps performed in the CI/CD process when your workflow is triggered.
To create a new workflow in Xcode, use the following instructions:
Choose Product > Xcode Cloud > Create Workflow to open the Create Workflow sheet.
Select the product (app) that the workflow should be attached to, thenclick the Next button.
The next sheet is displays display an overview of the default workflow provide by Xcode , andcan be customize by click the Edit Workflow button .
By default Xcode suggests the Branch Changes condition that starts a new build for every change to your Git repository’s default branch.
For your app’s iOS variant, it’s reasonable that you would want Xcode Cloud to trigger your workflow after you’ve made changes to your flutter packages, ormodified either the Dart oriOS source files within the lib\
andios\
directory .
This can be achieved by using the following Files andFolders conditions:
Xcode Cloud defaults the build number for new workflows to 1
andincrements it per successful build. If you’re using an existing app with a higher build number, you’ll need to configure Xcode Cloud to use the correct build number for its builds by simply specifying the Next Build Number
in your iteration.
Check out Setting the next build number for Xcode Cloud builds for more information.
Unless stated otherwise, the documentation on this site reflects the latest stable version of Flutter. Page last updated on 2024-06-11. View source or report an issue.