kotlin-native-cocoapods
kotlin-native-cocoapods copied to clipboard
Gradle task not found
trafficstars
Hello,
When setting up this gradle plugin in the new kotlin-multiplatform gradle plugin and building the workspace in xcode I've got the following error:
$PODS_TARGET_SRCROOT/./gradlew -p "$PODS_TARGET_SRCROOT" "createIos${CONFIGURATION}Artifacts"
> Configure project :
Kotlin Multiplatform Projects are an experimental feature.
This build is set up to publish Kotlin multiplatform libraries with experimental Gradle metadata. Future Gradle versions may fail to resolve dependencies on these publications. You can disable Gradle metadata usage during publishing and dependencies resolution by removing `enableFeaturePreview('GRADLE_METADATA')` from the settings.gradle file.
FAILURE: Build failed with an exception.
* What went wrong:
Task 'createIosDebugArtifacts' not found in root project 'analytics-core'.
* Try:
Run gradlew tasks to get a list of available tasks. 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 3s
Command PhaseScriptExecution failed with a nonzero exit code
The task createIosDebugArtifacts does not exist in that project but linkMainDebugFrameworkIos and linkMainReleaseFrameworkIos do exist and are the closed tasks I can find which build a .framework folder.
Thank you in advance, Alex
whats your gradle file in analytics-core?
@AlecStrong This is after removing the plugin but the rest is the same:
group 'com.analytics'
version '0.0.1'
buildscript {
repositories {
mavenLocal()
google()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies' }
}
dependencies {
classpath "com.android.tools.build:gradle:3.2.1" // if updated R not generated
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
ext.experimentalsEnabled = ["-progressive", "-Xuse-experimental=kotlin.Experimental",
"-Xuse-experimental=kotlin.ExperimentalMultiplatform",]
}
repositories {
mavenLocal()
google()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
maven { url "https://kotlin.bintray.com/ktor" }
maven { url "https://kotlin.bintray.com/kotlin/kotlinx" }
maven { url "https://kotlin.bintray.com/kotlinx" }
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-multiplatform'
apply plugin: 'kotlinx-serialization'
apply plugin: 'maven-publish'
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
task.kotlinOptions.freeCompilerArgs += experimentalsEnabled
}
kotlin {
targets {
android("android")
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
? presets.iosArm64 : presets.iosX64
fromPreset(iOSTarget, 'iOS') {
binaries {
framework('Analytics')
}
}
jvm('backend')
js('node') {
tasks.getByName(compilations.main.compileKotlinTaskName).kotlinOptions {
metaInfo = true
sourceMap = true
moduleKind = 'commonjs'
sourceMapEmbedSources = "always"
}
}
}
//println(targets.names)
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlinx_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlinx_serialization_version"
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
backendMain {
dependencies {
implementation kotlin('stdlib-jdk8')
//implementation "io.ktor:ktor-client-jvm:$ktor_version"
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlinx_serialization_version"
}
}
backendTest {
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
nodeMain {
//dependsOn commonClientsMain
dependencies {
implementation kotlin('stdlib-js')
implementation "io.ktor:ktor-client-js:$ktor_version"
implementation "io.ktor:ktor-client-json-js:$ktor_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlinx_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlinx_serialization_version"
}
}
nodeTest {
//dependsOn commonClientsTest
dependencies {
implementation kotlin('test-js')
}
}
android {
publishLibraryVariants("release", "debug")
}
iOSMain {
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$kotlinx_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$kotlinx_serialization_version"
implementation "io.ktor:ktor-client-json-native:$ktor_version"
implementation "io.ktor:ktor-client-ios:$ktor_version"
}
}
iOSTest {
}
}
}
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinx_coroutines_version"
implementation "io.ktor:ktor-client-android:$ktor_version"
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
implementation "io.ktor:ktor-client-gson:$ktor_version"
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0'
}
task packForXCode(type: Sync) {
final File frameworkDir = new File(buildDir, "xcode-frameworks")
final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG'
final def framework = kotlin.targets.iOS.binaries.getFramework("Analytics", mode)
inputs.property "mode", mode
dependsOn framework.linkTask
from { framework.outputFile.parentFile }
into frameworkDir
doLast {
new File(frameworkDir, 'gradlew').with {
text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n"
setExecutable(true)
}
}
}
tasks.build.dependsOn packForXCode
what does your targets block look like when you are using this plugin