Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- apply plugin: 'kotlin-multiplatform'
- def mobilePlatformAttribute = Attribute.of('com.inspirefitness.mobile', String)
- def consolePlatformAttribute = Attribute.of('com.inspirefitness.console', String)
- configurations {
- mobileConfiguration {
- extendsFrom configurations.default
- attributes.attribute(mobilePlatformAttribute, 'mobile')
- }
- consoleConfiguration {
- extendsFrom configurations.default
- attributes.attribute(consolePlatformAttribute, 'console')
- }
- }
- kotlin {
- targets {
- final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
- ? presets.iosArm64 : presets.iosX64
- fromPreset(iOSTarget, 'iOS') {
- compilations.main.outputKinds('FRAMEWORK')
- }
- }
- jvm('android').attributes {
- attribute(mobilePlatformAttribute, 'mobile')
- }
- jvm('console').attributes {
- attribute(consolePlatformAttribute, 'console')
- }
- sourceSets {
- commonMain.dependencies {
- api 'org.jetbrains.kotlin:kotlin-stdlib-common'
- }
- androidMain.dependencies {
- api 'org.jetbrains.kotlin:kotlin-stdlib'
- }
- consoleMain.dependencies {
- api 'org.jetbrains.kotlin:kotlin-stdlib'
- }
- }
- }
- // workaround for https://youtrack.jetbrains.com/issue/KT-27170
- configurations {
- compileClasspath
- }
- task packForXCode(type: Sync) {
- final File frameworkDir = new File(buildDir, "xcode-frameworks")
- final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG'
- inputs.property "mode", mode
- dependsOn kotlin.targets.iOS.compilations.main.linkTaskName("FRAMEWORK", mode)
- from { kotlin.targets.iOS.compilations.main.getBinary("FRAMEWORK", mode).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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement