GithubHelp home page GithubHelp logo

touchlab / kampkit Goto Github PK

View Code? Open in Web Editor NEW
2.1K 70.0 191.0 5.95 MB

KaMP Kit by Touchlab. A collection of code & tools designed to get your mobile team started quickly w/Kotlin Multiplatform

Home Page: https://touchlab.co/

License: Apache License 2.0

Kotlin 83.03% Swift 13.18% Ruby 3.80%
kotlin kotlin-multiplatform kotlin-native

kampkit's Introduction

KaMP Kit Android KaMP Kit iOS

KaMP Kit

KaMP Kit Image

Welcome to KaMP Kit!

Intro

KaMP Kit started in early 2020 with the goal of helping developers interested in Kotlin Multiplatform (aka KMP) get started quickly with a great set of libraries and patterns. At the time, there were not many sample apps and getting started was not trivial. The KMP situation has improved considerably since then, and various barriers to entry have been removed.

Whereas KaMP Kit started with the goal of being a minimal sample, we now intend it to be less "getting started" and more "best practice model". Watch this repo and follow @TouchlabHQ for updates!

2023 Update

We updated KaMPKit to make sure of Touchlab's new SKIE tool. SKIE allowed use to remove a lot of boilerplate code related to ViewModel sharing, and also we can now use Kotlin sealed classes as Swift enums in iOS code. Take a look at our detailed migration case study

Subscribe!

We build solutions that get teams started smoothly with Kotlin Multiplatform and ensure their success in production. Join our community to learn how your peers are adopting KMP. Sign up here!

Getting Help

KaMP Kit support can be found in the Kotlin Community Slack, request access here. Post in the #touchlab-tools channel.

For direct assistance, please contact Touchlab to discuss support options.

About

Goal

The goal of KaMP Kit is to facilitate your evaluation of KMP. It is a collection of code and tools designed to get you started quickly. It's also a showcase of Touchlab's typical choices for architecture, libraries, and other best practices.

The KMP ecosystem has generated a lot of excitement, and has evolved very rapidly. As a result, there's a lot of old or conflicting documentation, blog posts, tutorials, etc. We, Touchlab, have worked with several teams looking at KMP, and have found that the primary stumbling block is simply getting started.

KaMP Kit is designed to get you past that primary stumbling block. You should be able to set up your development environment, clone the repo, and have a running sample app very quickly. From there, you can focus on what you want to build.

Very Important Message!!!

This kit exists because the info you may find from Google about KMP is likely to be outdated or conflicting with the config here. It is highly recommended that you reach out directly if you run into issues.

Audience

We (Touchlab) are focused primarily on using KMP for native mobile development. As a result, this kit is primarily targeted at native mobile developers (Android or iOS), as well as engineering managers for native mobile teams. You should have little-to-no experience with KMP, although some of the information after setup may be useful if you do have KMP experience.

What's Included?

  1. The Starter App - A native mobile KMP app with a small functional feature set.
  2. Educational Resources - Introductory information on KMP and Kotlin/Native.
  3. Integration Information - If you're integrating shared code into an existing application, guides to assist with that effort.

What's Not Included?

Comprehensive guides, advanced tutorials, or generally support for fixing anything not included in the starter app. The goal is to have a solid starting point from which you can create something meaningful for evaluating KMP. We're intentionally limiting the scope to keep focus.

The Starter App

The central part of the "Kit" is the starter app. It includes a set of libraries that we use in our apps that provide for much of the architectural needs of a native mobile application. We've also included a simple set of features you can use as a reference when adding your features.

1) Dev Environment and Build Setup

You will need the following:

  • JVM 17
  • Android SDK and the latest stable Android Studio (2022.3+) or IntelliJ(2023.2+)
  • Mac with Xcode 14+ for the iOS build

For a more detailed guide targeted at iOS developers, see DETAILED_DEV_SETUP.

2) Clone and Build

See APP_BUILD for detailed build instructions. By the end of that doc you should be able to build and run both Android and iOS apps.


Sanity Check

At this point, you should be able to build Android and iOS apps. If you cannot build, you need to get help. This sample app is configured to run out of the box, so if it's not working, you have something wrong with your build setup or config. Please reach out to us so we can improve either the config or troubleshooting docs, and/or the Kotlin Slack group mentioned above.


3) Walk Through App

Take a walk through the app's code and libraries. Make changes, recompile. See how it works.

GENERAL_ARCHITECTURE

4) Background Education

If the app is building, it's a good time to take a break and get some background information.

KMP Intro

It's important to understand not just how to set up the platform, but to get a better perspective on what the tech can do and why we think it'll be very successful. KMP is distinct from other code sharing and "cross platform" systems, and understanding those distinctions is useful.

Longer intro to KaMP Kit - Original version of this doc's intro. Cut because it was pretty long.

Intro to Kotlin Multiplatform - General intro to KMP from Oredev in Nov 2019. Good overall summary of the platform.

"Selling" KMP

KaMPKit can help you demonstrate to management and other stakeholders the value of sharing code with KMP. Check out these resources for more advice on pitching KMP to your team:

Kotlin Multiplatform Mobile for Teams

Building a Business Case for KMP

7 ways to convince your engineering manager to pilot Kotlin Multiplatform

Xcode Debugging

For information on how to debug Kotlin in Xcode, check out the Debugging Kotlin In Xcode doc.

5) Integrating 'shared' With Existing Apps

As part of your evaluation, you'll need to decide if you're going to integrate KMP into existing apps. Some teams feel integrating with their production apps is a better demonstration of KMP's viability. While KMP's interop is great, relative to other technologies, integrating anything into a production app build process can be a difficult task. Once integrated, development is generally smooth, but modifying production build systems can be a time consuming task.

Adopting Kotlin Multiplatform In Brownfield Applications

Android

The Android side is somewhat more straightforward. Android development is Kotlin-first nowadays, and the library can be integrated as just another module library. We'll be updating soon with a general Android integration doc. In the meantime, the simplest method would be to copy the shared module into your standard Android build, and use the app module as a reference for dependency resolution.

iOS

The iOS integration process is relatively new and has been iterating fast. Be prepared to spend more time with config related issues when integrating with a production build.

You can integrate with Cocoapods, or by directly including the Xcode framework. If you are an Android developer without extensive iOS build experience, be aware that this is a risky option. Production build systems, for any ecosystem, tend to be complex. You'll almost certainly need to recruit somebody with experience maintaining your iOS build.

See IOS_PROJ_INTEGRATION.md for iOS integration information.

If you are attempting to integrate your KMP project with a production iOS application, please let us know what issues you run into and reach out with questions if stuck. This is an ongoing area of improvement for the KMP platform and we'd like to help make this as smooth as possible.


Troubleshooting

TROUBLESHOOTING - We'll be growing this file over time, with your help. Please make sure to document any issues you run into and let us know.

More To Come!

KaMP Kit is just the beginning. Our hope is that after KaMP Kit you’ll have a better sense of what a possible KMP implementation might look like.


About Touchlab

Touchlab is a mobile-focused development agency based in NYC. We have been working on Android since the beginning, and have worked on a wide range of mobile and hardware projects for the past decade. Over the past few years, we have invested significantly on R&D for code sharing technologies. We believe strongly in KMP's future and have made the Kotlin multiplatform the focus of our business.

About The Kit

We talked to a few teams early on who got to do a "hack week" with KMP. A common story was, if they didn't abandon the project altogether, they didn't have anything running till the week was half over. Even then, picking libraries and architecture ate the rest of the time. Inevitably the result was, "KMP isn't ready". We know that once you're past the setup phase, KMP is really amazing tech. This Kit exists so you're evaluating KMP on Monday afternoon, not Thursday.

What We Can Do For You

We have made KMP the focus of Touchlab. We had possibly the first KMP* app published in the iOS App Store, and have extensive experience in building libraries and the Kotlin platform, including contributions to Kotlin/Native itself. We can establish and accelerate your adoption of shared Kotlin code. See touchlab.co for more info.

Subscribe!

We build solutions that get teams started smoothly with Kotlin Multiplatform and ensure their success in production. Join our community to learn how your peers are adopting KMP. Sign up here!

kampkit's People

Contributors

ben-whit-ley avatar brady-aiello avatar chislett avatar ecgreb avatar findjigar avatar jacksonweekes avatar joreilly avatar jqrgen avatar juliajakubcova avatar kevinschildhorn avatar kpgalligan avatar maxdelia avatar mrf7 avatar psh avatar romtsn avatar russhwolf avatar samhill303 avatar seank90 avatar seljabali avatar shalomhalbert avatar stylianosgakis avatar temmax avatar tiwoc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kampkit's Issues

Can't run sample setup on real device.

Environment

Device: iPhone 7
iOS: 13.3.1
XCode: 11.4
SWIFT: 5
Commit: master HEAD, up to date

Problem

Template builds and runs fine on emulator, but when i try to run it on real device it falls with given error:
(lldb)

dyld: Library not loaded: @rpath/shared.framework/shared
  Referenced from: /private/var/containers/Bundle/Application/1AA91D4E-5285-434E-805F-87A8DF71B4A8/KaMPStarteriOS.app/KaMPStarteriOS
  Reason: no suitable image found.  Did find:
	/private/var/containers/Bundle/Application/1AA91D4E-5285-434E-805F-87A8DF71B4A8/KaMPStarteriOS.app/Frameworks/shared.framework/shared: code signature invalid for '/private/var/containers/Bundle/Application/1AA91D4E-5285-434E-805F-87A8DF71B4A8/KaMPStarteriOS.app/Frameworks/shared.framework/shared'

	/private/var/containers/Bundle/Application/1AA91D4E-5285-434E-805F-87A8DF71B4A8/KaMPStarteriOS.app/Frameworks/shared.framework/shared: stat() failed with errno=25
	/private/var/containers/Bundle/Application/1AA91D4E-5285-434E-805F-87A8DF71B4A8/KaMPStarteriOS.app/Frameworks/shared.framework/shared: code signature invalid for '/private/var/containers/Bundle/Application/1AA91D4E-5285-434E-805F-87A8DF71B4A8/KaMPStarteriOS.app/Frameworks/shared.framework/shared'

	/private/var/containers/Bundle/Application/1AA91D4E-5285-434E-805F-87A8DF71B4A8/KaMPStarteriOS.app/Frameworks/shared.framework/shared: stat() failed with errno=1
	/private/var/containers/Bundle/Application/1AA91D4E-5285-434E-805F-87A8DF71B4A8/KaMPStarteriOS.app/Frameworks/shared.framework/shared: code signature invalid for '/private/var/containers/Bundle/Application/1AA91D4E-5285-434E-805F-87A8DF71B4A8/KaMPStarteriOS.app/Frameworks/shared.framework/shared'

	/private/var/containers/Bundle/Application/1AA91D4E-5285-434E-805F-87A8DF71B4A8/KaMPStarteriOS.app/Frameworks/shared.framework/shared: stat() failed with errno=1

jdk7?

is there a reason why you use jdk7 instead of jdk8 ?

from your build.gradle.kts:

implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72")

sdkman jdk issues

Taken from slack...

Sven Bendel Today at 9:25 AM
Hi, I've just started to play around with the kampkit sample app on my Mac. Android works like a charm. However, on iOS I can't seem to build the app. I always get the dreaded "To use the “java” command-line tool you need to install a JDK." dialog. However, I have java and the JDK installed on my system, although not in the default location. I'm using sdkman to manage java versions, current version resides at /Users/ubuntudroid/.sdkman/candidates/java/current. I guess I somehow need to tell xcode to use that. JAVA_HOME environment variable is set to the abovementioned value, but xcode seems not to make use of it (I guess it only looks in the default . Any ideas?

25 replies

Marc Reichelt 1 hour ago
What’s your Java version?

Marc Reichelt 1 hour ago
java -version

Marc Reichelt 1 hour ago
KaMP Kit docs say ‘JVM 8’

Marc Reichelt 1 hour ago
if you get openjdk 1.8.0 you should be fine

Sven Bendel 1 hour ago
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)

Sven Bendel 1 hour ago
but I don't think it's being picked up at all by xcode

Marc Reichelt 1 hour ago
yep, definitely try a 1.8.0 openjdk

Sven Bendel 1 hour ago
kk, will try

Sven Bendel 1 hour ago
Now I have
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)

Sven Bendel 1 hour ago
Unfortunately I still get the popup. 😞

Sven Bendel 42 minutes ago
I guess Xcode is trying to execute the gradle task :shared:syncFramework and then gradle (running in the xcode environment) does not find my java environment. :thinking_face:

Marc Reichelt 26 minutes ago
hmm, maybe it chooses the wrong java version

Marc Reichelt 26 minutes ago
when you set JAVA_HOME: did you logout & login your user on your Mac?

Marc Reichelt 25 minutes ago
that might do the trick (because then freshly started apps get the updated env variables)

Marc Reichelt 25 minutes ago
If you can, try to find out which java command Xcode runs

Marc Reichelt 25 minutes ago
which ‘java’ binary exactly

Marc Reichelt 24 minutes ago
it seems on your machine it finds a JRE java binary instead of the JDK one

Marc Reichelt 24 minutes ago
maybe there is the old java binary from Apple installed

Sven Bendel 24 minutes ago
thanks for your outstanding support on this matter 🙏 - I'll restart my Mac (to be on the safe side) and see whether this resolves things. Then I'll try out the other things you've suggested.

Marc Reichelt 23 minutes ago
I usually fix these things by uninstalling all JREs and JDKs on my machine and just installing openjdk 1.8.0 with homebrew 😉

Marc Reichelt 23 minutes ago
glad to help - hope it works 🙂

Sven Bendel 23 minutes ago
haha, I feared that would be the answer 😅

Sven Bendel 18 minutes ago
Hm, okay, restarting didn't work - trying your other recommendations now

Sven Bendel 3 minutes ago
Ha, I've managed to get things up and running by hardcoding JAVACMD in gradlew - it seems that xcode indeed launches the process without properly setting proper environment variables.

Sven Bendel 2 minutes ago
Trying to find a better solution for this while keeping on using sdkman. Will post my findings here if I am successful.

Enable automatic CI builds for iOS

Currently, we don't know if code changes lead to failing builds - until someone tries it out.

Let's enable a CI server that does that! I heard GitHub Actions has Mac build servers as well…

Update to Kotlin 1.3.70

Blocked until libraries release versions compatible with 1.3.70

  • Ktor
  • Serialization
  • Coroutines (multithreaded branch)
  • SqlDelight
  • Settings
  • Stately
  • Koin (multithread-safe fork)

Enable automatic CI builds for Android and iOS

Currently, we don't know if code changes lead to failing builds - until someone tries it out.

Let's enable a CI server that does that! I heard GitHub Actions has Mac build servers as well…

[except-actual]No value passed for parameter 'param'

Kotlin:1.4.0

// commonMain
expect object CommonClass {
    fun someFun(param: String = "default value")
}

// jvmMain
actual object CommonClass {
    actual fun someFun(param: String) {
    }
}

// jvmTest
class JvmTest {
    @Test
    fun test(){
        CommonClass.someFun()
    }
}

then, i got this lint error in jvmTest, but compile successfully and no runtime error. Help me, Thanks.

image

Add experimental coroutines compiler flag

If we add the compiler flag for experimental coroutines we can remove the annotations everywhere we use it.

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]
    }
}

Not possible to debug suspend functions

Whenever I try to debug a suspend function I get the following error:

image

From what I've read online it used to not be possible to debug suspend functions but apparently this has been resolved now. Is it still impossible for MPP?

shared.framework size issue

Running the KampKit as is and building the iOS app, gives out a framework "shared.framework" with a size of 46.3 MB on disk.

Is this normal and ok?

Screenshot 2020-08-09 at 6 09 28 PM

Screenshot 2020-08-09 at 6 10 04 PM

[Question] Why the ViewModel is a shared code here?

Hi. First of all, thanks for sharing this repository, It's very useful to help people like me to learning about KMP.

I was reading your code and I have a question about the way the structure is built. In your ViewCotroller class (inside iOS module) you guys are importing the shared module and instantiating the NativeViewModel directly from there. I know that making the VM code shared will make a lot things easier here, because it should behaves exactly equals on both platforms. However, in this scenario, you guys don't need anything that is very specific from iOS frameworks, but, for example, in sometimes I'll need something like a UIColor on my ViewModel, and creating the ViewModel inside the shared code instead of in the iOS code makes it impossible. My question here is: should we actually share the ViewModels classes when working with KMP or it's better to restrict the code sharing to only our Domain layer?

Thanks in advance.

Duplicate breeds in database

I've seen this on iOS. Haven't confirmed if it occurs on Android yet. If breeds are fetched from the network again (currently after an hour since the last fetch) It seems we are appending them all to the table again rather than updating or replacing the existing rows there.

Add License

Would be great to have a license on this. :)

Avoiding PackForXcode task and using cocoapods instead

When you create a new kotlin kmm project as it is today, in the shared module there is a task

val packForXcode by tasks.creating(Sync::class) {
    group = "build"
    val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
    val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
    val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
    val framework = kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
    inputs.property("mode", mode)
    dependsOn(framework.linkTask)
    val targetDir = File(buildDir, "xcode-frameworks")
    from({ framework.outputDirectory })
    into(targetDir)
}

tasks.getByName("build").dependsOn(packForXcode)

I looked high and low in this repo and its commit history and I never saw this here. I understand using the cocoapods and pod file in the ios project. I was able to generate those same files in my own project. However when I delete the generated task above I get the following error:

Task 'packForXCode' not found in project ':shared'.

I read through the docs of following:
https://github.com/touchlab/KotlinCocoapods
https://github.com/touchlab/KaMPKit/blob/master/docs/IOS_PROJ_INTEGRATION.md

at first I thought it was due to not using: cocoapodsext in the build file but I found a similar repo : https://github.com/joreilly/PeopleInSpace/blob/master/common/build.gradle.kts that manages to do the same logic with the native plugin. I tried looking through the gradle tasks as well and I saw no discernible difference in that regard we well.

I was wondering if you could explain how you came to implement something like this from a purely learning perspective? What were the reasons you implemented this was as opposed the generated task mentioned above?

Thanks for taking the time to read this/ answer my questions!

Refactor/Rename How-To

This is a fantastic starter kit and I thank you all for putting this together for all of us!

Would it be possible to add a "How-To refactor/rename" best practices doc for packages, app name, dependencies, etc. so we're not always using co/touchlab/kampstarter / co.touchlab.kampstarter and we don't break gradle, Xcode, Android builds?

Koin dependency not found in iosMain

We are in the progress of transitioning our Kotlin-based Android app to KMP. KaMPKit is a huge help!
Our targets are specified basically the same way:

    android()
    val onPhone = System.getenv("SDK_NAME")?.startsWith("iphoneos") ?: false
    val nativeTarget = if (onPhone) {
        iosArm64("ios")
    } else {
        iosX64("ios")
    }
    nativeTarget.compilations {
        val main by getting {
            kotlinOptions.freeCompilerArgs += "-Xobjc-generics"
        }
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))
                implementation(Dependencies.Koin.koin)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val iosMain by getting {
            dependencies {
            }
        }

Trying to use Koin on shared module, but in shared ios code, the Koin library as a dependency is not visible. The Koin library is the same 3.0.0-alpha-8 version from the Touchlab bintray.
Is this a gradle glitch? The code is compiling, but it's still pretty annoying to see in iosMain.
If I specify ios() instead, it is found, but the gradle KMP extensions create a sourceset for iosX64 and iosArm64, and that obviously causes problems with the expect-actual warnings.

Unit Tests Failing on iOS Build Attempts via Terminal

After building the Android app without any issues, I go to the terminal to build the iOS app.

In the terminal of the root project folder, I enter the ./gradlew build command. I get an error indicating failed unit tests.
image

This issue looks similar to this issue. Seems to be related to Robolectric. I am using JDK 1.8, not JDK 13.

Error Stacktrace:
image
image

Cannot change generated framework name

Hi,

Trying to change the generated ios framework name without change the 'shared' project name doesn't work.

Trying to generate 'MultiPlatformLibrary.framework' instead of 'shared.framework'.

Pod::Spec.new do |spec|
    spec.name                     = 'MultiPlatformLibrary'
    spec.version                  = '1.1'
    spec.homepage                 = 'home page'
    spec.source                   = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" }
    spec.authors                  = ''
    spec.license                  = ''
    spec.summary                  = 'Common library from KampKit'
    spec.vendored_frameworks      = "build/cocoapods/framework/#{spec.name}.framework"
    spec.libraries                = "c++"
    spec.module_name              = "#{spec.name}_umbrella"

    spec.pod_target_xcconfig = {
        'KOTLIN_TARGET[sdk=iphonesimulator*]' => 'ios_x64',
        'KOTLIN_TARGET[sdk=iphoneos*]' => 'ios_arm',
        'KOTLIN_TARGET[sdk=watchsimulator*]' => 'watchos_x86',
        'KOTLIN_TARGET[sdk=watchos*]' => 'watchos_arm',
        'KOTLIN_TARGET[sdk=appletvsimulator*]' => 'tvos_x64',
        'KOTLIN_TARGET[sdk=appletvos*]' => 'tvos_arm64',
        'KOTLIN_TARGET[sdk=macosx*]' => 'macos_x64'
    }

    spec.script_phases = [
        {
            :name => 'Build MultiPlatformLibrary',
            :execution_position => :before_compile,
            :shell_path => '/bin/sh',
            :script => <<-SCRIPT
                set -ev
                REPO_ROOT="$PODS_TARGET_SRCROOT"
                "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" :shared:syncFramework \
                    -Pkotlin.native.cocoapods.target=$KOTLIN_TARGET \
                    -Pkotlin.native.cocoapods.configuration=$CONFIGURATION \
                    -Pkotlin.native.cocoapods.cflags="$OTHER_CFLAGS" \
                    -Pkotlin.native.cocoapods.paths.headers="$HEADER_SEARCH_PATHS" \
                    -Pkotlin.native.cocoapods.paths.frameworks="$FRAMEWORK_SEARCH_PATHS"
            SCRIPT
        },
        {
        	:name => 'Touch MultiPlatformLibrary.framework',
        	:execution_position => :after_compile,
        	:shell_path =>  '/bin/sh',
        	:script => 'find "${SRCROOT}" -type f -name *frameworks.sh -exec bash -c "touch \"{}\"" \;'
        }
    ]
end

Building the project from XCode keeps producing build/cocoapods/framework/shared.framework instead of build/cocoapods/framework/MultiPlatformLibrary.framework.

Also tried to update the framework name through target configurations, but with no success:

if (onPhone) {
        iosArm64("ios") {
            binaries {
                framework("MultiPlatformLibrary")
            }
        }
    } else {
        iosX64("ios") {
            binaries {
                framework("MultiPlatformLibrary")
            }
        }

Is it a limitation ? What is the recommended way to change the product framework name without changing the source folder name ?

import error on BreedViewModel.kt

I am getting an error in this file:
app/src/main/java/co/touchlab/kampstarter/android/BreedViewModel.kt

about this import line:
import co.touchlab.kampstarter.db.Breed

Add error handling: Showing white screen when network connection fails

When starting KaMPKit on an Android emulator that has lost its Internet connection, KaMPKit simply shows a white screen:

Screenshot_1581636670

This is weird, especially for newcomers. Also, I think it would be good practice if we could handle errors gracefully - and show a Snackbar on Android for example with a nice error message.

[Feature request]: MP library without the app module

Thanks for the kit. We had tried developing just the MP library without the app module for different reasons and just have the exported artifact used in respective platform app projects.

We used IntelliJ and it had too many pain points for android target. Imported dependencies would not auto complete and/or show as errors in IDE etc.

Would appreciate if the Kit can also support just a MP library.

KaMPKitDB is not accessible from common or Android module

Project is building and running fine (tested on Android), however, IDE (Android Studio 4.1) is having issues with resolving imports from db package from common and Android code, and as a result, IDE is underlining all the time those files and doesn't autocomple when typing their names. Invalidating cache/restart doesn't solve this issue.
image
image
image

Update Dependencies

Need to return to production Koin. Don't think we're on the latest SQLDelight. Also can bump Kotlin to 1.4.10

Improve test functionality

Currently BreedModelTest takes empty callback lambdas in the viewmodel. Improve the test so it's actually verifying that the lambdas behave as expected

Migration of favorite didn't work

I migrated favorite to favorite2 just to play with migrations, and ran into a weird thing. The favorites didn't show on screen, but it seemed to work. Something to look into for later.

iOS dynamic frameworks require Clean for Kotlin changes

Dynamic frameworks are currently necessary to see Kotlin debugging info from iOS. However, dynamic frameworks also require cleaning (CMD+SHIFT+K) and rebuilding to pull in any changes to the Kotlin code, which adds significantly to build times.

If you want to avoid cleaning the iOS project every time you make changes to the Kotlin code, you can still use a static framework, but you will not be able to see useful debugging information.

We're currently working towards a solution to give the best of both worlds.

Create CocoaPod plugin documentation

How CocoaPods is used for importing the shared framework could be better documented. How you make a podspec. How to add the pod to podfile. Where the script in the podspec ends up. What that script does. Why this is much nicer than manually importing the frameworks and writing your own build phases and gradle tasks

No JS target?

I'd like to setup a sample app for my boss and I stumbled upon this awesome template!
My aim is to develop also a react application using the same codebase. Is there a reason why there is no js target in the gradle file and the template is just for android & ios?
Will I be able to add it or are some libraries that you use non-compatible with that platform?

Slow build and failed tests

I am trying to have 1st build of KaMPKit. I was able to successfully build and run it in Android Studio.

Now I am trying to run 1st optional step of iOS build. I have already downloaded and run XCode 11.5.

For unknown reasons the build takes too long and all tests are failing.

Just in case I am running the build on MacBook Pro 16" (2019), MacOS Catalina 10.15.4.

$ ./gradlew clean build
> Task :shared:testReleaseUnitTest

...

> Task :shared:testReleaseUnitTest

co.touchlab.kampkit.KoinTest > checkAllModules FAILED
    org.apache.tools.ant.BuildException
        Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException

co.touchlab.kampkit.ConcurrencyTest > testMain FAILED
    org.apache.tools.ant.BuildException
        Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException

co.touchlab.kampkit.BreedModelTest > updateFavoriteTest FAILED
    org.apache.tools.ant.BuildException
        Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException

co.touchlab.kampkit.BreedModelTest > notifyErrorOnException FAILED
    org.apache.tools.ant.BuildException
        Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException

co.touchlab.kampkit.BreedModelTest > staleDataCheckTest FAILED
    org.apache.tools.ant.BuildException
        Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException

co.touchlab.kampkit.SqlDelightTest > Select All Items Success FAILED
    org.apache.tools.ant.BuildException
        Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException

co.touchlab.kampkit.SqlDelightTest > Update Favorite Success FAILED
    org.apache.tools.ant.BuildException
        Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException

co.touchlab.kampkit.SqlDelightTest > Select Item by Id Success FAILED
    org.apache.tools.ant.BuildException
        Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException

co.touchlab.kampkit.SqlDelightTest > Delete All Success FAILED
    org.apache.tools.ant.BuildException
        Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException

9 tests completed, 9 failed

> Task :shared:testReleaseUnitTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:testReleaseUnitTest'.
> There were failing tests. See the report at: file:///Users/otrotsenko/dev/repos/3rd_party/kmp/KaMPKit/shared/build/reports/tests/testReleaseUnitTest/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 47m 53s

And then in the index.html for each test I see the same:

Unable to resolve artifact: Missing:
----------
1) org.robolectric:android-all:jar:4.1.2_r1-robolectric-r1

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=4.1.2_r1-robolectric-r1 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=4.1.2_r1-robolectric-r1 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
  	1) org.apache.maven:super-pom:pom:2.0
  	2) org.robolectric:android-all:jar:4.1.2_r1-robolectric-r1

----------
1 required artifact is missing.

for artifact: 
  org.apache.maven:super-pom:pom:2.0

from the specified remote repositories:
  adeya.central (https://nexus.adeya.ch/content/repositories/adeya.central/)


	at org.apache.maven.artifact.ant.DependenciesTask.doExecuteResolution(DependenciesTask.java:268)

Could not find org.koin:koin-core-jvm:3.0.0-alpha-4

Here is my root build.gradle.kts buildscript

    repositories {
        gradlePluginPortal()
        jcenter()
        google()
        mavenCentral()

        maven(url = "https://dl.bintray.com/ekito/koin")
    }

And I added the dependency in commonMain sourceSets for the shared module I have
implementation("org.koin:koin-core:3.0.0-alpha-4")

While trying to build the project I get

Execution failed for task ':androidApp:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':androidApp:debugRuntimeClasspath'.
   > Could not find org.koin:koin-core-jvm:3.0.0-alpha-4.
     Searched in the following locations:
       - https://plugins.gradle.org/m2/org/koin/koin-core-jvm/3.0.0-alpha-4/koin-core-jvm-3.0.0-alpha-4.pom
       - https://dl.google.com/dl/android/maven2/org/koin/koin-core-jvm/3.0.0-alpha-4/koin-core-jvm-3.0.0-alpha-4.pom
       - https://jcenter.bintray.com/org/koin/koin-core-jvm/3.0.0-alpha-4/koin-core-jvm-3.0.0-alpha-4.pom
       - https://repo.maven.apache.org/maven2/org/koin/koin-core-jvm/3.0.0-alpha-4/koin-core-jvm-3.0.0-alpha-4.pom
     Required by:
         project :androidApp > project :shared > org.koin:koin-core:3.0.0-alpha-4

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

It looks to me like the jvm version of the library is not released, and also I don't understand why my core library depends on the jvm library. Am I doing something wrong?

the dreaded NDK version is UNKNOWN

Hi,

Apologies if this is too generic and/or ignorant, but both my clones in the latest OSX and Windows Android Studio would fail at syncing with the

NDK Resolution Outcome: Project settings: Gradle model version=5.6.2, NDK version is UNKNOWN

This failure persisted after setting the NDK path under Project Structure, in Windows there is a "Download" button to get the NDK, in MacOS I pointed to a manually unpacked NDK.

The "sync" and eventually the build completed successfully after closing the projects on both platforms and clicking Import Project, which revealed that the UKNOWN message is still in the log, but somehow not the showstopper that it was before the import, no clue what is happening there. I am also confused why Android Studio does not automagically fetch and configure an NDK when required in a project, is it possible that KaMPKit is using an antipattern here, or hitting a Google bug (I saw there is an open issue in Google's Issue Tracker)?

Thanks!

[QUESTION] Support of KaMPKit in the future

Hi all,

first of all - I want to compliment identifying necessity of creating project like this and puting it all together - well done.

I have a question about whole KaMPKit project - would you recommend to start using this project example as a base template for the new (production-level) project ?

I see big advantage in using this project as a template - everytime Kotlin & libraries versions will be updated, I will just use same versions and gradle settings as KaMPKit, and I don't have to go through tedious trial error process of resolving which versions of libraries/Kotlin work well together.

Is there some sort of roadmap that shows planned commitment to support KaMPKit / Stately in the future?

Thanks.

Initialize Koin from AppDelegate

We currently init Koin directly in Kotlin from iOS, which I think is not a good way to do it. In larger projects, we'll certainly want to pass in Swift stuff, and KaMP Kit is kind of a template for what you should do.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.