Closed uOOOO closed 4 years ago
Can you share your gradle configuration?
Can you share your gradle configuration?
Here is the gradle configuration.
isFatBuild was always 'false' during build.
buildscript {
apply from: "build-version.gradle"
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath("com.android.tools.build:gradle:${ver.agp}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${ver.kotlin}")
classpath("org.jetbrains.kotlin:kotlin-serialization:${ver.kotlin}")
classpath("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:${ver.kotlin}")
classpath("com.squareup.sqldelight:gradle-plugin:${ver.sqlDelight}")
classpath 'co.touchlab:kotlinxcodesync:0.2'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://dl.bintray.com/badoo/maven" }
maven { url "https://dl.bintray.com/kodein-framework/kodein-dev/" }
}
}
apply plugin: "com.android.library"
apply plugin: "kotlin-multiplatform"
apply plugin: "kotlin-android-extensions"
apply plugin: "kotlin-kapt"
apply plugin: "kotlinx-serialization"
apply plugin: "com.squareup.sqldelight"
apply plugin: 'co.touchlab.kotlinxcodesync'
def isFatBuild = project.findProperty("isFatBuild") ?: false
if (!isFatBuild) {
apply plugin: "org.jetbrains.kotlin.native.cocoapods"
}
android {
compileSdkVersion ver.compileSdkVersion
defaultConfig {
minSdkVersion ver.minSdkVersion
targetSdkVersion ver.targetSdkVersion
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-proguard-rules.pro"
}
buildTypes {
release {
minifyEnabled false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
sourceSets {
main {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
}
}
packagingOptions {
exclude("META-INF/ktor-http.kotlin_module")
}
testOptions {
unitTests {
includeAndroidResources = true
returnDefaultValues = true
}
}
}
dependencies {
debugImplementation("com.github.chuckerteam.chucker:library:${ver.chucker}")
releaseImplementation("com.github.chuckerteam.chucker:library-no-op:${ver.chucker}")
}
kotlin {
android {
publishLibraryVariants("debug", "release")
}
if (isFatBuild) {
ios {
binaries.framework {
baseName = frameworkId
it.isStatic = false
it.linkerOpts.add("-lsqlite3")
}
}
} else {
def isPhone = System.getenv('SDK_NAME')?.startsWith("iphoneos")
if (isPhone) {
iosArm64("ios")
} else {
iosX64("ios")
}
targets.ios {
binaries.each {
try {
baseName = frameworkId
it.isStatic = false
it.linkerOpts.add("-lsqlite3")
} catch (Throwable ignored) {
}
}
}
}
sourceSets {
commonMain.dependencies {
implementation(kotlin("stdlib-common"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:${ver.kotlinSerialization}")
implementation("io.ktor:ktor-client-core:${ver.ktor}")
implementation("io.ktor:ktor-client-logging:${ver.ktor}")
implementation("io.ktor:ktor-client-serialization:${ver.ktor}")
api("com.badoo.reaktive:reaktive:${ver.reaktive}")
implementation("com.badoo.reaktive:coroutines-interop:${ver.reaktive}")
implementation("com.squareup.sqldelight:coroutines-extensions:${ver.sqlDelight}")
implementation 'org.kodein.di:kodein-di:7.1.0-master-88'
}
commonTest.dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("com.badoo.reaktive:reaktive-testing:${ver.reaktive}")
implementation("io.ktor:ktor-client-mock:${ver.ktor}")
implementation("com.badoo.reaktive:reaktive-testing:${ver.reaktive}")
}
androidMain.dependencies {
implementation(kotlin("stdlib-common"))
implementation("androidx.appcompat:appcompat:${ver.appcompat}")
implementation("androidx.core:core-ktx:${ver.coreKtx}")
implementation("io.ktor:ktor-client-okhttp:${ver.ktor}"
implementation "com.squareup.okhttp3:logging-interceptor:${ver.okhttp}"
api("com.badoo.reaktive:rxjava2-interop:${ver.reaktive}")
implementation("com.squareup.sqldelight:android-driver:${ver.sqlDelight}")
implementation("com.squareup.sqldelight:android-paging-extensions:${ver.sqlDelight}")
implementation 'org.kodein.di:kodein-di-conf-jvm:7.1.0-master-88'
implementation 'org.kodein.di:kodein-di-framework-android-core:7.1.0-master-88'
implementation 'org.kodein.di:kodein-di-framework-android-x:7.1.0-master-88'
}
androidTest.dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
implementation("org.robolectric:robolectric:4.4")
implementation("io.mockk:mockk:${ver.mockk}")
}
iosMain.dependencies {
implementation("io.ktor:ktor-client-ios:${ver.ktor}")
implementation("com.squareup.sqldelight:native-driver:${ver.sqlDelight}")
}
iosTest.dependencies {
}
if (isFatBuild) {
iosArm64Main.dependsOn(iosMain)
}
}
if (!isFatBuild) {
cocoapods {
// Configure fields required by CocoaPods.
summary = "Test"
homepage = "https://www.abcd.com"
frameworkName = frameworkId
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
}
group = "com.abcd"
version = "0.0.1"
artifactId = "abcd-library"
sqldelight {
Database {
packageName = "com.abcd.db"
sourceFolders = ["sqldelight"]
schemaOutputDirectory = file("$buildDir/sqldelight")
}
}
afterEvaluate {
tasks.findByName("allTests").dependsOn(tasks.findByName("testReleaseUnitTest"))
}
xcodeSync {
projectPath = "../../ios/Test2/Test2.xcodeproj"
target = "Test2"
}
apply plugin: 'maven-publish'
afterEvaluate {
publishing {
publications.all {
it.artifactId = it.artifactId.replace(project.name, this.artifactId).toLowerCase()
}
}
}
task linkFatIos(type: org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask) {
doFirst {
if (!isFatBuild) {
logger.error("[isFatBuild] is false. So fat framework is not built.")
return
}
}
def fatBuildType = (project.findProperty("fatBuildType") ?: "debug").toString().toLowerCase()
baseName = frameworkId
destinationDir = file("$buildDir/bin/iosFat/${fatBuildType}Framework")
from kotlin.targets
.findAll { it.name.startsWith("ios") }
.collect { it.binaries.getFramework(fatBuildType) }
}
tasks.getByName("build").dependsOn(linkFatIos)
task linkDebugFatIos(type: Exec) {
executable './gradlew'
args '-PisFatBuild=true', '-PfatBuildType=debug', 'linkFatIos'
}
task linkReleaseFatIos(type: Exec) {
executable './gradlew'
args '-PisFatBuild=true', '-PfatBuildType=release', 'linkFatIos'
}
I found the root cause.
error code
lateinit var di: DI
private set
fun init() {
if (::di.isInitialized) {
return
}
di = DI.lazy {
importAll(
platformModule
)
}
}
working code - remove 'private set'
lateinit var di: DI
fun init() {
if (::di.isInitialized) {
return
}
di = DI.lazy {
importAll(
platformModule
)
}
}
Kodein 7.1.0-master-88 occurs error during linking iOS framework in Kotlin Native MPP.
And ./gradlew publishToMavenLocal command is working without any issue.
Do you have any information about this?