Use binaries DSL in Xcode samples
This commit is contained in:
committed by
Ilya Matveev
parent
b22404c947
commit
0a6dbbb3b3
@@ -3,7 +3,9 @@ apply plugin: 'org.jetbrains.kotlin.multiplatform'
|
|||||||
kotlin {
|
kotlin {
|
||||||
targets {
|
targets {
|
||||||
fromPreset(determineIosPreset(), 'ios') {
|
fromPreset(determineIosPreset(), 'ios') {
|
||||||
compilations.main.outputKinds 'FRAMEWORK'
|
binaries {
|
||||||
|
framework()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fromPreset(presets.jvm, 'jvm')
|
fromPreset(presets.jvm, 'jvm')
|
||||||
@@ -42,16 +44,21 @@ def determineIosPreset() {
|
|||||||
// - calculator.configuration.name=[Release|Debug]
|
// - calculator.configuration.name=[Release|Debug]
|
||||||
// - calculator.framework.location
|
// - calculator.framework.location
|
||||||
task buildFrameworkForXcode {
|
task buildFrameworkForXcode {
|
||||||
|
|
||||||
|
if (isCalledFromXcode()) {
|
||||||
|
dependsOn kotlin.targets.ios.binaries.getFramework(getBuildTypeForXcode()).linkTask
|
||||||
|
}
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
if (!isCalledFromXcode()) {
|
if (!isCalledFromXcode()) {
|
||||||
throw new Exception("Please run 'buildFrameworkForXcode' task with all necessary properties!")
|
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()}")
|
println("into: ${getXcodeConfigurationBuildDir()}")
|
||||||
|
|
||||||
File frameworkDir = kotlin.targets.ios.compilations.main.getBinary('FRAMEWORK', getBuildTypeForXcode())
|
|
||||||
|
|
||||||
copy {
|
copy {
|
||||||
from frameworkDir.parentFile
|
from frameworkDir.parentFile
|
||||||
into getXcodeConfigurationBuildDir()
|
into getXcodeConfigurationBuildDir()
|
||||||
@@ -61,12 +68,6 @@ task buildFrameworkForXcode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
if (isCalledFromXcode()) {
|
|
||||||
buildFrameworkForXcode.dependsOn kotlin.targets.ios.compilations.main.linkTaskName('FRAMEWORK', getBuildTypeForXcode())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isCalledFromXcode() {
|
private boolean isCalledFromXcode() {
|
||||||
project.hasProperty('calculator.configuration.name') && project.hasProperty('calculator.framework.location')
|
project.hasProperty('calculator.configuration.name') && project.hasProperty('calculator.framework.location')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ plugins {
|
|||||||
kotlin {
|
kotlin {
|
||||||
targets {
|
targets {
|
||||||
fromPreset(determinePreset(), 'ios') {
|
fromPreset(determinePreset(), 'ios') {
|
||||||
compilations.main.outputKinds 'EXECUTABLE'
|
binaries {
|
||||||
compilations.main.entryPoint 'sample.uikit.main'
|
executable {
|
||||||
|
entryPoint = 'sample.uikit.main'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,13 +19,17 @@ kotlin {
|
|||||||
// - uikit.configuration.name=[Release|Debug]
|
// - uikit.configuration.name=[Release|Debug]
|
||||||
// - uikit.binary.location
|
// - uikit.binary.location
|
||||||
task buildAppForXcode {
|
task buildAppForXcode {
|
||||||
|
if (isCalledFromXcode()) {
|
||||||
|
dependsOn kotlin.targets.ios.binaries.getExecutable(getBuildTypeForXcode()).linkTask
|
||||||
|
}
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
if (!isCalledFromXcode()) {
|
if (!isCalledFromXcode()) {
|
||||||
throw new Exception("Please run 'buildAppForXcode' task with all necessary properties!")
|
throw new Exception("Please run 'buildAppForXcode' task with all necessary properties!")
|
||||||
}
|
}
|
||||||
|
|
||||||
copy {
|
copy {
|
||||||
from file(kotlin.targets.ios.compilations.main.getBinary('EXECUTABLE', getBuildTypeForXcode()))
|
from file(kotlin.targets.ios.binaries.getExecutable(getBuildTypeForXcode()).outputFile)
|
||||||
into file(getBinaryLocationForXcode().parentFile)
|
into file(getBinaryLocationForXcode().parentFile)
|
||||||
rename {
|
rename {
|
||||||
getBinaryLocationForXcode().name
|
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.
|
// If custom preset specified in 'uikit.preset.name' property, then use it for building.
|
||||||
// Otherwise build for iPhone simulator (by default).
|
// Otherwise build for iPhone simulator (by default).
|
||||||
private def determinePreset() {
|
private def determinePreset() {
|
||||||
|
|||||||
@@ -13,12 +13,12 @@
|
|||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference 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; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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 */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -52,11 +52,11 @@
|
|||||||
2CB5403B1F56C2C4006EE521 /* konan */ = {
|
2CB5403B1F56C2C4006EE521 /* konan */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
2C33F7F822378402009209E2 /* src */,
|
||||||
2CB540451F56C2C4006EE521 /* Main.storyboard */,
|
2CB540451F56C2C4006EE521 /* Main.storyboard */,
|
||||||
2CB540481F56C2C4006EE521 /* Assets.xcassets */,
|
2CB540481F56C2C4006EE521 /* Assets.xcassets */,
|
||||||
2CB5404A1F56C2C4006EE521 /* LaunchScreen.storyboard */,
|
2CB5404A1F56C2C4006EE521 /* LaunchScreen.storyboard */,
|
||||||
2CB5404D1F56C2C4006EE521 /* Info.plist */,
|
2CB5404D1F56C2C4006EE521 /* Info.plist */,
|
||||||
7FE128B9205852380064CE74 /* src */,
|
|
||||||
);
|
);
|
||||||
path = konan;
|
path = konan;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -68,30 +68,6 @@
|
|||||||
name = Frameworks;
|
name = Frameworks;
|
||||||
sourceTree = "<group>";
|
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 */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
|
|||||||
Reference in New Issue
Block a user