A Flutter application where users check if ingredients on packaging are vegan using OCR and AR.
This App is generated using the base_app
brick provided by Baseflow. The app is structured to follow the Clean Architecture principles created by Robert C. Martin.
This means the app is split up into multiple independent packages listed in the packages
folder. The template generates the following packages by default:
- isitvegan_app: Bootstrap project responsible for wiring up all packages in the right order.
- isitvegan_ui: Project representing the presentation layer. This is where all pages, widgets and BLoC classes should go.
- isitvegan_core: Project representing the business logic layer. This is where all use cases, domain classes and repository contracts are defined.
More details on the Baseflow architecture for Flutter applications can be found here.
- Run
melos bootstrap
to initialize the project. - Run
melos get
to run flutter packages get in all packages. - Run
melos generate
to run all needed code generators. - Run
melos fix:apply
to fix any analysis issues created while generating.
The steps below are required to prepare the Android application for release and ensure the continuous delivery scripts work successfully. The commands used in these steps assume you are running on a Linux or macOS machine. If you are on Windows these commands might be slightly different.
Part of these steps use GnuPG (binary name gpg
) to encrypt sensitive information. GnuPG is pre-installed on most Linux distributions, however not on macOS. Installing GnuPG on macOS is done using one of the package managers:
-
Homebrew:
brew install gnupg gnupg2
-
MacPorts:
sudo port install gnupg gnupg2
-
In
packages/*_app/android
runkeytool -genkey -v -keystore ./upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
to generate an upload key. -
Make sure to update
key.properties
with the password. The placeholder values will make release builds fail. -
Do not add key.properties to git.
-
Navigate to
packages/*_app/android
and executegpg -c --armor key.properties
. -
Save the passphrase to Github Actions' secret
ANDROID_KEY_PASSPHRASE
. -
Navigate to
packages/*_app/android
and executegpg -c --armor upload-keystore.jks
. -
Save the passphrase to Github Actions' secret
ANDROID_KEYSTORE_PASSPHRASE
. -
Save the output of
cat key.properties.asc
toANDROID_KEY_ASC
. -
Save the output of
cat upload-keystore.jks.asc
toANDROID_KEYSTORE_ASC
. -
Save the passphrases used in the Baseflow 1password. That way we don't lose them.
-
Save the
key.properties.asc
andupload-keystore.jks.asc
in Baseflow 1password. -
Create a Google play service-account with the customer.
-
Save the Google play service-account JSON as
PLAY_STORE_GSERVICE_ACCOUNT
in the github secrets. -
Run your first Android build using
melos build:android
and manually upload the resulting binary (packages/isitvegan_app/build/app/outputs/bundle/release/isitvegan_app.aab
) to Google Play internal testing.
The steps below are required to prepare the iOS application for release and ensure the continuous delivery scripts work successfully. The steps below require a macOS machine and won't work on a Linux or Windows machine.
Part of these steps use GnuPG (binary name gpg
) to encrypt sensitive information. GnuPG is pre-installed on most Linux distributions, however not on macOS. Installing GnuPG on macOS is done using one of the package managers:
-
Homebrew:
brew install gnupg gnupg2
-
MacPorts:
sudo port install gnupg gnupg2
-
Go to Apple Developer and add com.jwindustries..
-
Go to App Store Connect and add a new app with com.jwindustries. as Bundle ID.
-
SKU (Stock Keeping Unit) is a value Apple will include in the reports and can be used by the organization to identify the app. Usually the value used is the same as the bundle identifier, but could be anything as long as it is unique within the organization.
-
Open KeyChain on you MacOs device. Follow the steps to create a certificate singing request.
-
Go to the Apple Website and select Apple Distribution.
-
Upload the Certificate Signing Request file created with Keychain.
-
Download the certificate after uploading the request.
-
Import the certificate in Keychain.
-
Export a .p12 file from the imported certificate. Save the password to Github Actions Secrets
P12_PASSWORD
. -
Visit Apple Profiles. Select App Store, under Distribution.
-
For
App ID
select the app created previously. -
For
Select certificate
select the certificate created previously. And give the profile a name in the next step. -
Download the provisioning profile.
-
Save all asc outputs and passphrases used in the Baseflow 1password. That way we don't lose them.
-
In your terminal navigate to .p12 file location and execute
gpg -c --armor <name_of_file>.mobileprovision
. -
Save the passphrase to Github Actions' secret
IOS_PROVISIONING_PROFILE_PASSWORD
. -
In your terminal navigate to .cert file location and execute
gpg -c --armor <name_of_file>.p12
. -
Save the passphrase to Github Actions' secret
IOS_CERTIFICATE_PASSWORD
. -
Save the output of
cat <name_of_file>.mobileprovision.asc
toIOS_PROVISIONING_PROFILE_ASC
. -
Save the output of
cat <name_of_file>.p12.asc
toIOS_CERTIFICATE_ASC
. -
Update
export-options.plist
with the TeamID at<ENTER TEAM CODE HERE>
. -
Update
export-options.plist
with the name of the provisioning profile at<ENTER PROVISIONING NAME HERE>
. -
Open the project in XCode and disable automatic code signing in Release flavors and set the provisioning profile to the one imported above.
-
This should change
packages/isitvegan_app/ios/Runner.xcodeproj/project.pbxproj
by addingDEVELOPMENT_TEAM
,PROVISIONING_PROFILE_SPECIFIER
,CODE_SIGN_IDENTITY
andCODE_SIGN_STYLE
. -
Go to AppStoreConnect and create a new API key.
-
Give the API key a name and set
Access
toApp manager
, any other role will fail the deployments. -
Download the API key, and save the
Issuer ID
andKey ID
. -
Go to Github Actions and save the Issuer ID and Key ID in
APP_STORE_ISSUER_ID
andAPP_STORE_API_KEY_ID
respectively.
Managing a project that consists out of multiple packages can be quite challenging. Flutter commands need to be executed in the correct folder and in some cases you just want to execute on command to build the whole solution.
To help simplify working with a multi package application, this project is configured to use Melos.
As Melos is a Dart package installing Melos is as easy as running:
dart pub global activate melos
When the command completes Melos is ready to be used.
The first time this project is generated or everytime new packages are introduced it is important to bootstrap Melos. To do so run the following command:
melos bootstrap
Bootstrapping does two important things:
- Install all packages dependencies (internally using
pub get
). - Locally linking projects together.
After bootstrapping the application it is not yet ready for use. The code generation tools need to generate some files first, run melos generate
.
To simplify the usage of Melos the following scripts are already preconfigured (see the [melos.yaml] file for details):
# Run dart analyze for all packages
melos run analyze
# Run flutter format for all packages
melos run format
# Build the App for all supported platforms
melos run build:all
# Build the App for a specific platform
melos run build:<android|ios|macos|linux|web|windows>
# Run tests for all packages
melos run test
# Run test for a specific package (lets you select the package)
melos run test:selective
# Run the application in debug mode
melos run debug
# Do a deep clean, which can be used to establish "pristine" checkout status
melos run clean:deep # Important: this removes all directories, files and changes that have not been committed.
# Run all code generation tools once (build_runner & l10n)
melos generate
# Run build_runner once in all packages
melos build_runner || melos build_runner:build
# Run build_runner in watch mode
melos build_runner:watch
# Generate the localization files
melos l10n