Use binaries DSL in Xcode samples

This commit is contained in:
Ilya Matveev
2019-03-11 17:51:09 +07:00
committed by Ilya Matveev
parent b22404c947
commit 0a6dbbb3b3
3 changed files with 23 additions and 45 deletions
@@ -3,7 +3,9 @@ apply plugin: 'org.jetbrains.kotlin.multiplatform'
kotlin {
targets {
fromPreset(determineIosPreset(), 'ios') {
compilations.main.outputKinds 'FRAMEWORK'
binaries {
framework()
}
}
fromPreset(presets.jvm, 'jvm')
@@ -42,16 +44,21 @@ def determineIosPreset() {
// - calculator.configuration.name=[Release|Debug]
// - calculator.framework.location
task buildFrameworkForXcode {
if (isCalledFromXcode()) {
dependsOn kotlin.targets.ios.binaries.getFramework(getBuildTypeForXcode()).linkTask
}
doLast {
if (!isCalledFromXcode()) {
throw new Exception("Please run 'buildFrameworkForXcode' task with all necessary properties!")
}
println("from: ${kotlin.targets.ios.compilations.main.getBinary('FRAMEWORK', getBuildTypeForXcode()).parentFile}")
def frameworkDir = kotlin.targets.ios.binaries.getFramework(getBuildTypeForXcode()).outputFile
println("from: ${frameworkDir.parentFile}")
println("into: ${getXcodeConfigurationBuildDir()}")
File frameworkDir = kotlin.targets.ios.compilations.main.getBinary('FRAMEWORK', getBuildTypeForXcode())
copy {
from frameworkDir.parentFile
into getXcodeConfigurationBuildDir()
@@ -61,12 +68,6 @@ task buildFrameworkForXcode {
}
}
afterEvaluate {
if (isCalledFromXcode()) {
buildFrameworkForXcode.dependsOn kotlin.targets.ios.compilations.main.linkTaskName('FRAMEWORK', getBuildTypeForXcode())
}
}
private boolean isCalledFromXcode() {
project.hasProperty('calculator.configuration.name') && project.hasProperty('calculator.framework.location')
}
+10 -9
View File
@@ -5,8 +5,11 @@ plugins {
kotlin {
targets {
fromPreset(determinePreset(), 'ios') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'sample.uikit.main'
binaries {
executable {
entryPoint = 'sample.uikit.main'
}
}
}
}
}
@@ -16,13 +19,17 @@ kotlin {
// - uikit.configuration.name=[Release|Debug]
// - uikit.binary.location
task buildAppForXcode {
if (isCalledFromXcode()) {
dependsOn kotlin.targets.ios.binaries.getExecutable(getBuildTypeForXcode()).linkTask
}
doLast {
if (!isCalledFromXcode()) {
throw new Exception("Please run 'buildAppForXcode' task with all necessary properties!")
}
copy {
from file(kotlin.targets.ios.compilations.main.getBinary('EXECUTABLE', getBuildTypeForXcode()))
from file(kotlin.targets.ios.binaries.getExecutable(getBuildTypeForXcode()).outputFile)
into file(getBinaryLocationForXcode().parentFile)
rename {
getBinaryLocationForXcode().name
@@ -31,12 +38,6 @@ task buildAppForXcode {
}
}
afterEvaluate {
if (isCalledFromXcode()) {
buildAppForXcode.dependsOn kotlin.targets.ios.compilations.main.linkTaskName('EXECUTABLE', getBuildTypeForXcode())
}
}
// If custom preset specified in 'uikit.preset.name' property, then use it for building.
// Otherwise build for iPhone simulator (by default).
private def determinePreset() {
+2 -26
View File
@@ -13,12 +13,12 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
2C33F7F822378402009209E2 /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; path = src; sourceTree = SOURCE_ROOT; };
2CB540391F56C2C4006EE521 /* konan.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = konan.app; sourceTree = BUILT_PRODUCTS_DIR; };
2CB540461F56C2C4006EE521 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
2CB540481F56C2C4006EE521 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2CB5404B1F56C2C4006EE521 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2CB5404D1F56C2C4006EE521 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7FE128BC205852380064CE74 /* main.kt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.kt; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -52,11 +52,11 @@
2CB5403B1F56C2C4006EE521 /* konan */ = {
isa = PBXGroup;
children = (
2C33F7F822378402009209E2 /* src */,
2CB540451F56C2C4006EE521 /* Main.storyboard */,
2CB540481F56C2C4006EE521 /* Assets.xcassets */,
2CB5404A1F56C2C4006EE521 /* LaunchScreen.storyboard */,
2CB5404D1F56C2C4006EE521 /* Info.plist */,
7FE128B9205852380064CE74 /* src */,
);
path = konan;
sourceTree = "<group>";
@@ -68,30 +68,6 @@
name = Frameworks;
sourceTree = "<group>";
};
7FE128B9205852380064CE74 /* src */ = {
isa = PBXGroup;
children = (
7FE128BA205852380064CE74 /* main */,
);
path = src;
sourceTree = SOURCE_ROOT;
};
7FE128BA205852380064CE74 /* main */ = {
isa = PBXGroup;
children = (
7FE128BB205852380064CE74 /* kotlin */,
);
path = main;
sourceTree = "<group>";
};
7FE128BB205852380064CE74 /* kotlin */ = {
isa = PBXGroup;
children = (
7FE128BC205852380064CE74 /* main.kt */,
);
path = kotlin;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */