Codelab - Mature KMP Team Adoption Models

· 3 min read

Author: Kevin Galligan

Prep

Clean up old repos

gh repo delete kpgalligan/GitPortalTemplateLibrary --yes
gh repo delete kpgalligan/GitPortalDemoAndroid --yes
gh repo delete kpgalligan/GitPortalDemoIos --yes
rm -rdf *

Part 1

Create a folder

Create and clone templates

Create

gh repo create "kpgalligan/GitPortalTemplateLibrary" --private -p touchlab/GitPortalTemplateLibrary
gh repo create "kpgalligan/GitPortalDemoAndroid" --private -p touchlab/GitPortalDemoAndroid
gh repo create "kpgalligan/GitPortalDemoIos" --private -p touchlab/GitPortalDemoIos

Clone

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

Link folders

Android

gitportal bidir.setup library -r https://github.com/kpgalligan/GitPortalTemplateLibrary.git -b main -c android

iOS

gitportal bidir.setup library -r https://github.com/kpgalligan/GitPortalTemplateLibrary.git -b main -c ios

CI Deploy Key Setup

gitportal deploykey -k kpgalligan/GitPortalTemplateLibrary -a kpgalligan/GitPortalDemoAndroid -a kpgalligan/GitPortalDemoIos

Setup Android

Android Setup

Setup iOS

iOS Setup

Commit both

Make KMP change to Android

Add comment to DatabaseHelper. Commit.

In iOS, Run check

gitportal bidir.compare -c android

Pull merge

gitportal bidir.pullmerge -c android

Discuss CI config

Auto-push vs manual push. We’re exploring alternative metadata options, but for now, each merge with KMP changes triggers an extra config. Not an issue for larger commits, but a lot of smaller merges will result in a cluttered history.

Updates coming will involve other features and probably change the overall operation, but stay tuned.

Open local repos in Intellij

idea GitPortalDemoAndroid
idea GitPortalDemoIos
idea GitPortalTemplateLibrary

Open Android in Intellij

Open terminal (option+f12)

gitportal setup library -r https://github.com/kpgalligan/GitPortalTemplateLibrary.git -t 0.1.0

In the library folder, there’s a config file. That tracks things for you. It’s in the library folder, but

Open Ios in Intellij

Open terminal (option+f12)

gitportal setup library -r https://github.com/kpgalligan/GitPortalTemplateLibrary.git -t 0.1.0

Open Template in Intellij

Open terminal (option+f12)

gitportal deploykey -k kpgalligan/GitPortalTemplateLibrary \
    -a kpgalligan/GitPortalDemoAndroid -a kpgalligan/GitPortalDemoIos

Show repos and what it does

Open https://github.com/kpgalligan/GitPortalTemplateLibrary

Open Settings, Deploy Keys

Open https://github.com/kpgalligan/GitPortalDemoAndroid

Open Settings, Actions Secrets

Wire android

Open Intellij

Open settings.gradle.kts

Change projects

Open app/build.gradle.kts

Uncomment

implementation(project(":analytics"))
implementation(project(":breeds"))

Wire iOS

Open Intellij

Open terminal (option+f12)

open ios.xcproject

“I’ll show this, but probably best to do on your own, as Xcode will probably be less familiar”

“We’re going to use direct linking instead of CocoaPods or other options”

Add Run Script

Add, move to top

Copy into field

cd "$SRCROOT/library"
./gradlew embedAndSignAppleFrameworkForXcode

In “Other Linker Flags” add -framework allshared

In “Framework Search Paths” add

$(SRCROOT)/library/allshared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)

Build the app

Part 2

Show how to check

Open Android in Intellij

Open terminal (option+f12)

gitportal check library

Add a comment to build gradle

gitportal check library

Push code

Show fail

Run check again, copy diff apply line, run

Add/commit

Run check again

push

Open GitPortalTemplateLibrary in Intellij

Make the same change

Open terminal (option+f12)

Add/commit

Create a new version

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

Open android in Intellij

Open terminal (option+f12)

gitportal pull library -t "0.1.1"

Open .gitportal and show changes

Part 3

Open Android in Intellij

Open DatabaseHelper and add another comment

Open terminal (option+f12)

Add/commit

gitportal push library -b "newcomment"

Run check

gitportal check library

Fail, explain

Open Ios in Intellij

Open terminal (option+f12)

gitportal pull library -b "newcomment"

“Now we can do iOS stuff, then submit”

Open https://github.com/kpgalligan/GitPortalTemplateLibrary

Create PR, Merge

Create release in Browser

0.1.2

“That also creates a tag”

Open Android

gitportal pull library pull -t "0.1.2" -f

OK