Skip to main content

FIRST APP GUIDE

Set Up App Distribution

Let's tackle app store distribution now! It's nice to have this "scary part" out of the way early, so do yourself a favor and take the time to follow this section - even if you're just working with a test app. Getting familiar with the process in this low-pressure environment will make it much less daunting for your real projects.

Prerequisites

Make sure you've completed the Configuration Guide.

Getting Codemagic Ready

Initial Setup

Let's get your automated builds configured:

  1. Connect your GitHub repo to a new Codemagic project
  2. Pick the Flutter workflow
  3. Switch to YAML config

Hook Up GitHub

To get those auto-builds working:

  1. Grab the webhook URL from your Codemagic project
  2. Add it to your GitHub repo under Settings > Webhooks

Get the Codika Codemagic Config

Codemagic uses workflow files to know how to build your app. We'll help create this file, but first we need to gather some project information:

bash

codika codemagic-get-config

This command adds config fields with default settings in your .codika/config/codika_config.yaml file. You'll just need to update two key pieces:

  • codemagic_app_id: Your project's ID (find it in the Webhooks section)
  • app_id_ios: The app ID from App Store Connect for each environment (it's in your app's URL)

Setting Up iOS

First, let's get your app registered with Apple. For each environment (except Development), you'll need to:

  1. Set up bundle IDs in the Developer Console
  2. Create provisioning profiles with your certificate
  3. Create your apps in App Store Connect
  4. Add an "Internal Testers" group in TestFlight

iOS Signing Setup

Now for the iOS signing magic. Codemagic needs your certificates to build iOS apps:

  1. Find your codemagic_provisioning_profile_name in the config file
  2. Go to Team > Code signing identities > iOS provisioning profiles in Codemagic
  3. Use "Fetch profiles" to import your certificates
  4. Match the profile names with what's in your config

Setting Up Android

To allow codemagic to publish your app to the Google Play Store we have to create a service account and provide its JSON key to Codemagic.

Create a service account

  1. Open the Google Cloud Plateform Console and navigate to your project.
  2. Enable the Google Play Developer Reporting API and the Google Play Android Developer API.
  3. Go to the APIs & Services > Credentials section.
  4. Click on Create credentials and select Service account.
  5. Fill in the required fields and click on Create.
  6. Once created, copy the service key email address for later use and click on the service account edit button.
  7. Go to the Permission tab and click on GRANT ACCESS.
  8. Paste the service key email address in the New principals and in the Role look for Service Account User and press save.
  9. Go to IAM and admin/Sercice accounts and in the actions column click on Manage keys.
  10. Click on Add key/Create new key and select JSON.
  11. Save the JSON file in the root of you project and name it google-services.json.

Enable the service account to publish on the Google Play Store

  1. Open the Google Play Console and navigate to Users and permissions.
  2. Click on Invite new user and paste the service key email address.
  3. Add the app to which you want to give access to the service account.
  4. As permissions select Admin
  5. Click on Send invitation.

Finish Codemagic Setup

Now we can tie everything together:

bash

codika codemagic-setup

This command creates your codemagic.yaml workflow file and securely uploads all you secret files to Codemagic. The workflow file tells Codemagic exactly how to build your app for each environment.

Build Time!

With everything configured, let's trigger your first build:

bash

codika build --prod

What's Next?

Great job! You've accomplished quite a bit:

  • Set up your app in the Apple Developer Console
  • Created your Codemagic build pipeline
  • Got your first build ready for testing

In the next section, we'll add a new feature to your app using the Codika CLI. We'll integrate the FAQ block - a simple feature that lets you add a FAQ section to your app.

We've specifically chosen this feature for the next step because it's the perfect way to show you how Codika works under the hood. You'll explore the architecture, see DDD in action, and check out all the cool automations that make your life easier. After that, we'll use Shorebird to deploy this new feature to your users through a live update - no app store submission needed!