Codelab - Mature KMP Team Adoption Models

· 3 min read

Author: Kevin Galligan

Install GitPortal

Start This Now!!!

The Homebrew build can take several minutes if you’re in “power saver” mode.

Run the following in a terminal.

brew tap touchlab/homebrew-gitportal
brew install gitportal

GitPortal is a new tool by Touchlab. I’ll be talking about it in a bit, but you’ll definitely need it to participate in the lab.

GitHub Org

Type a GitHub org in the box and hit enter. You’ll need admin access to this org. You can use your personal org.

Hit “refresh” if you typed it incorrectly. Alternatively, just replace specified instances with your org name in the commands found later in this doc.

Requirements

Lab setup

In the codelab we’ll be using 3 GitHub repos. One KMP source repo, and 2 app repos (Android and iOS). These repos will be your repos, created from our templates.

To simplify this process, we’ll be using the GitHub Cli tool.

Install GitHub Cli

Run the following from a terminal

brew install gh

Authenticate with GitHub

gh auth login

Setup “Everything”

Open a terminal and create a directory for the lab repos. cd into that directory.

Run each of the statements in the following code block. If you did not enter your org name in the box above, be sure to replace each relevant instance with your GitHub org.

Note: As mentioned, you’ll need admin access to that org

gh repo create YOUR_ORG/GitPortalTemplateLibrary --private \
    -p touchlab/GitPortalTemplateLibrary
gh repo create YOUR_ORG/GitPortalDemoAndroid --private \
    -p touchlab/GitPortalDemoAndroid
gh repo create YOUR_ORG/GitPortalDemoIos --private \
    -p touchlab/GitPortalDemoIos

gh release create "0.1.0" -R YOUR_ORG/GitPortalTemplateLibrary \
    -t "0.1.0" -n "Tutorial release" --latest

gh repo clone https://github.com/YOUR_ORG/GitPortalTemplateLibrary.git
gh repo clone https://github.com/YOUR_ORG/GitPortalDemoAndroid.git
gh repo clone https://github.com/YOUR_ORG/GitPortalDemoIos.git

The brew install command is actually building the cli tool with Kotlin/Native. It may take a little while…

Stop!

Everything below this is part of the lab

It’s here so you can copy/paste.

Part 1

Make sure terminal is in the folder you cloned everything to.

Open local repos in Intellij

You can do this manually, or use Android Studio, but this is for convenience…

idea GitPortalDemoAndroid
idea GitPortalDemoIos
idea GitPortalTemplateLibrary
gitportal setup library -r https://github.com/YOUR_ORG/GitPortalTemplateLibrary.git -t 0.1.0
gitportal setup library -r https://github.com/YOUR_ORG/GitPortalTemplateLibrary.git -t 0.1.0
gitportal deploykey -k YOUR_ORG/GitPortalTemplateLibrary \
    -a YOUR_ORG/GitPortalDemoAndroid -a YOUR_ORG/GitPortalDemoIos

For iOS stuff

The body of the “Run Script” section

cd "$SRCROOT/library"
./gradlew embedAndSignAppleFrameworkForXcode

Part 2

Running “check”

gitportal check library

Adding a tag

git tag -a "0.1.1" -m "Version 0.1.1"
git push origin --tags

Pulling from the KMP repo

gitportal pull library -t "0.1.1"

Part 3

Pushing

gitportal push library -b "newcomment"

Check command (again)

gitportal check library

Pull with a branch

gitportal pull library -b "newcomment"

Finally, pulling back into Android

gitportal pull library pull -t "0.1.2" -f