From 49994041131c1ef30e58ee0180b958bc520db328 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 2 Jul 2020 23:14:14 +0200 Subject: [PATCH] Added iOS target --- fints4k/build.gradle | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/fints4k/build.gradle b/fints4k/build.gradle index ffcd2709..96e2ad81 100644 --- a/fints4k/build.gradle +++ b/fints4k/build.gradle @@ -22,6 +22,21 @@ kotlin { android() + targets { + // Select iOS target for real device or emulator. + final def iOSIsRealDevice = System.getenv('SDK_NAME')?.startsWith("iphoneos") + final def iOSTarget = iOSIsRealDevice ? presets.iosArm64 : presets.iosX64 + + // iOS target. + fromPreset(iOSTarget, 'ios') { + binaries { + framework { + baseName = "fints4k" + } + } + } + } + js() { nodejs { @@ -114,6 +129,16 @@ kotlin { } } + iosMain { + dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.5-native-mt" + + implementation "io.ktor:ktor-client-ios:$ktorVersion" + implementation "io.ktor:ktor-client-core-native:$ktorVersion" + } + } + jsMain { dependsOn commonMain @@ -142,6 +167,32 @@ kotlin { } +// Task to generate iOS framework for xcode projects. +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("", 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) + } + } +} + +// Run packForXCode when building. +tasks.build.dependsOn packForXCode + + android { compileSdkVersion androidCompileSdkVersion