我想构建一个可以与Kotlin
和android一起使用的多平台ios
模块。但是当我使用
apply plugin: 'kotlin-platform-android'
我再也无法解决进口中的kotlinx问题。
这是我的Android build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-platform-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.phonepe.mykotlinnativesample"
minSdkVersion 15
targetSdkVersion 28
versionCode 2
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
def butterknife_version = '8.8.1'
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
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'
kapt 'com.jakewharton:butterknife:8.8.1'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
implementation "com.jakewharton:butterknife:$butterknife_version"
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.android.material:material:1.0.0-alpha3'
expectedBy project(":common")
}
这是我常见的 build.gradle
apply plugin: 'konan'
apply plugin: 'kotlin-platform-common'
repositories {
mavenCentral()
}
dependencies {
compile 'org.jetbrains.kotlin:kotlin-stdlib'
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
}
konan.targets = ['iphone', 'iphone_sim']
def frameworkName = 'KotlinHello'
konanArtifacts {
framework(frameworkName)
}
task lipo(type: Exec, dependsOn: 'build') {
def frameworks = files(
"$buildDir/konan/bin/iphone/${frameworkName}.framework/$frameworkName",
"$buildDir/konan/bin/iphone_sim/${frameworkName}.framework/$frameworkName"
)
def output = file("$buildDir/konan/bin/iphone_universal/${frameworkName}.framework/$frameworkName")
inputs.files frameworks
outputs.file output
executable = 'lipo'
args = frameworks.files
args += ['-create', '-output', output]
}
task copyFramework(type: Copy, dependsOn: lipo) {
from("$buildDir/konan/bin/iphone") {
include '*/Headers/*'
include '*/Modules/*'
include '*/Info.plist'
}
from "$buildDir/konan/bin/iphone_universal"
into "${rootProject.rootDir}/ios"
}
答案 0 :(得分:1)
Kotlin / Native当前不支持kapt或任何其他kotlinx库。我们可以在应用程序的android平台中使用kapt,但不能在主要的通用模块本身中使用。