Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖🍏 Enable Alkaa to be multiplatform #531

Merged
merged 119 commits into from
Sep 1, 2023
Merged

Conversation

igorescodro
Copy link
Owner

@igorescodro igorescodro commented Aug 3, 2023

A new `shared` module was create to hold all the shared logic between
the different mobile platforms. Future changes will make the `shared`
module the new `domain` if possible.

Since the `:domain` module is already Kotlin-only, the code was simply
moved and works!
Moved the dependencies from the Kotlin-only to the Kotlin Multiplatform
Mobile one
For some reason, Kotlin-only modules do not find the KMM modules. This
module was temporarily converted to Android to make the code work. In
the future, this module will also be a KMM one.
Small back-and-forth to convert the `shared` to the old `domain`. Now
that everything is set, the module was updated to the original name.
Oopsy, I removed the tests when moving the class between the modules.
The classes are now back and removed the junit dependencies since it
doesn't work well with KMM.
Removing Java's Calendar and adapting the logging tool to its
multiplatform version. Some work was needed for the convertions since
the Android layers will keep using Calendar for now. Future commits will
address the TODOs and make it more clear.
Fix the logging system in the remaining use cases and also some oopsies
along the way.
All the domain tests are working fine again all the Calendar/DateTime
migration
A few lint complaints
Instrumented tests fixed
When renaming the module from "shared" to "domain", one property was
missed. Updated!
When migrating to KMM, the checkers were removed from the Gradle script.
The quality plugin was re-added and the lint fixes updated.
Now that everything is set on the correct KMM directory, no need to keep
this folder anymore.
When running the Android Test task, KMP requires the minimum SDK to 30
to allow space in the test names. Another solution is to remove the
spaces and use simple names. The following regex was used to make the
job easier:

\s+(?=(?:(?:[^`]*`){2})*[^`]*`[^`]*$)
The Instant API requires min SDK 26, so we can't use the emulator on 24
anymore
Previously, some versions were inside the Version Catalog TOML and
others were in the AlkaaVersions file. Since the versioning and
compiling will be even more important now that we will compile with KMP,
all the versions are centralized in a single place.

Also, the VersionCatalogExtensions was broken in several classes to make
it easier to understand. They are: Bundles, Libraries and Versions.
Convert the Domain module to a KMP module
During the file moving, instead of creating "com/escodro/domain", I
created "com.escodro/domain". Now everything is fine again.
🚚 Organize the domain folders
The Repository module was migrated from Android/Kotlin-only module to
KMP. For now, we are not caring too much about ProGuard, so the files
were removed.
For consistency, the class directory was named to "kotlin"
Since one more layer was converted from java.Calendar to
kotlinx.DateTime, now the local layer will be responsible for the
mapping.
Room was removed to make space for the new-shiny-multiplatform
SQLDelight.
Replacing Room with SQLDelight was _delightful_.
A single unit test was updated
Following the KMP module structure, the files were moved accordingly.
Also some minor import changes required regarding the Dispatchers.
One more module receives the power of KMP! ⚡️
Previously, all the common coroutine library code was inside
`:libraries:core`. However, since this module contains a lot of Android
code (this module is practically a utils...), it didn't compile with
KMP. A new `libraries:coroutines` KMP module was created only to hold
this logic.
Using Koin and `expect class`, the code inside `commonMain` is
platform-agnostic. Now, every module implements its own platform driver.
For now, the prepopulation will only be executed in Android platform.
When the time comes, we refactor the code to also make it agnostic.
Tests updated to work properly after all the module changes
DI helper class is now being called in the iOS app. Koin injections!
Linters are now in peace
Update to Gradle 8.1.1 based on build error
# Conflicts:
#	gradle/libs.versions.toml
#	plugins/src/main/java/AlkaaVersions.kt
@igorescodro igorescodro changed the title Enable Alkaa to be multiplatform 🤖🍏 Enable Alkaa to be multiplatform Aug 23, 2023
From "android" to "androidTarget"
Creating plugins to make the setup easier and reduce boilerplate.
Additional changes need to comply with the build checks.
🧃 Improvements for the KMP modules
A new simple Composable was added to make sure that the iOS -> KMP
integration is working properly.
File updated to be more generic in the Gradle directory files
AlertDialog and other Material components were not available in the
1.4.x version
Theme in `shared` replaced with the atual Alkaa Material Design 3 theme
Converting the Design System module to KMP allowing the MaterialTheme to
be used on iOS. In order to do that, the following changes were
required:

- Remove Android annotation (`@StringRes`) and moving to actual Strings
- Disable `@Preview` annotation since it's not available in commonMain
- Delegate the Material You implementation for each platform
Since the Design System APIs are no longer using `@StringRes`, all the
modules that depends on it were updated to use the actual String. The DI
was also added to provide the platform specific theme implementation.
Auto-generated files updated. Not sure if they are required though.
Multiplatform Compose had a missing dependency during the build. Worked
fine to generate both iOS and Android artifacts though.
🍏 Implement a Hello World Composable connecting with the iOS app
When I was trying to integrate iOS and KMP, several issues were faced. I
tried, naively, to add CocoaPods since some of the samples also used
and it worked. Today is clear that it worked due to _other_ reasons,
not CocoaPods, since it's not needed due to
`embedAndSignAppleFrameworkForXcode` Gradle task. Less code is more
code.
One more of the configs that was added but not sure why. By removing it,
the cache and build speed will be faster, based on the warnings. So
far, no issues with the iOS app.
🔧 Update `gradle.properties` to allow native cache
Let's remove every CocoaPod reference from the codebase. For me, still
not clear if I'll need, but for now, it's gone.
🔥 Remove even more CocoaPods
@igorescodro igorescodro merged commit 2726164 into main Sep 1, 2023
2 of 4 checks passed
@igorescodro igorescodro deleted the alkaa-multiplatform branch September 1, 2023 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant