Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.

Commit c05b817

Browse files
Merge pull request #3 from michalciolek/master
Update libraries and fix build
2 parents a8af520 + 98476a5 commit c05b817

File tree

8 files changed

+84
-28
lines changed

8 files changed

+84
-28
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Check out the [blog post](https://www.bugsnag.com/blog/kotlin-multiplatform) for
88

99
### iOS
1010

11-
`./gradlew build`, then run from XCode targetting a simulator in the Debug Configuration
11+
`xcodebuild -sdk iphonesimulator -arch arm64 -configuration Debug -project "ios-app/ios-app.xcodeproj" -scheme ios-app`
12+
then run from XCode targeting a simulator in the Debug Configuration
1213

1314
### Web
1415

build.gradle.kts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
1111
classpath("com.android.tools.build:gradle:${Versions.agp}")
1212
classpath("com.bugsnag:bugsnag-android-gradle-plugin:${Versions.bugsnagPlugin}")
13-
classpath("org.jetbrains.kotlin:kotlin-frontend-plugin:0.0.37")
13+
classpath("org.jetbrains.kotlin:kotlin-frontend-plugin:${Versions.kotlinFrontentPlugin}")
1414
}
1515
}
1616

@@ -23,4 +23,18 @@ allprojects {
2323
maven("https://dl.bintray.com/kotlin/kotlin-js-wrappers")
2424
maven("https://kotlin.bintray.com/kotlinx")
2525
}
26+
27+
// TODO remove once https://github.com/Kotlin/kotlin-frontend-plugin/issues/141 is fixed
28+
plugins.whenPluginAdded {
29+
if (this.javaClass.name == "org.jetbrains.kotlin.gradle.frontend.FrontendPlugin") {
30+
val fixTask = tasks.register("webpack-config-fix") {
31+
this.doLast { file("webpack.config.d").mkdir() }
32+
}
33+
afterEvaluate {
34+
tasks.named("webpack-config").configure {
35+
this.dependsOn(fixTask)
36+
}
37+
}
38+
}
39+
}
2640
}

buildSrc/src/main/java/Versions.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
object Versions {
2-
val kotlin = "1.3.20"
3-
val agp = "3.2.1"
2+
val kotlin = "1.3.41"
3+
val kotlinxHtml = "0.6.12"
4+
val kotlinReact = "16.9.0-pre.82-kotlin-1.3.41"
5+
val nodeJs = "12.9.0"
6+
val agp = "3.4.2"
47
val androidx = "1.0.0"
58
val bugsnagAndroid = "4.11.0"
69
val bugsnagPlugin = "4.0.0"
710
val bugsnagJvm = "3.4.4"
8-
val springBoot = "2.1.1.RELEASE"
9-
val depManagement = "1.0.6.RELEASE"
10-
}
11+
val kotlinFrontentPlugin = "0.0.45"
12+
val springBoot = "2.1.7.RELEASE"
13+
val depManagement = "1.0.8.RELEASE"
14+
}

common/build.gradle

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ kotlin {
1616
kotlinOptions.main = "call"
1717
}
1818
}
19+
// This is for iPhone emulator
1920
// Switch here to iosArm64 (or iosArm32) to build library for iPhone device, rather than simulator
20-
iosX64("ios") {
21-
compilations.main.outputKinds("framework")
21+
iosX64("ios"){
22+
binaries {
23+
framework()
24+
}
2225
}
2326
}
2427

@@ -44,3 +47,25 @@ kotlin {
4447
configurations {
4548
compileClasspath
4649
}
50+
51+
// This task attaches native framework built from ios module to Xcode project
52+
// (see iosApp directory). Don't run this task directly,
53+
// Xcode runs this task itself during its build process.
54+
// Before opening the project from iosApp directory in Xcode,
55+
// make sure all Gradle infrastructure exists (gradle.wrapper, gradlew).
56+
task copyFramework {
57+
def buildType = project.findProperty('kotlin.build.type') ?: 'DEBUG'
58+
def target = project.findProperty('kotlin.target') ?: 'ios'
59+
dependsOn kotlin.targets."$target".binaries.getFramework(buildType).linkTask
60+
61+
doLast {
62+
def srcFile = kotlin.targets."$target".binaries.getFramework(buildType).outputFile
63+
def targetDir = getProperty('configuration.build.dir')
64+
copy {
65+
from srcFile.parent
66+
into targetDir
67+
include 'common.framework/**'
68+
include 'common.framework.dSYM'
69+
}
70+
}
71+
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip

ios-app/ios-app.xcodeproj/project.pbxproj

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
E7C9B7AE2201EE24001F5774 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E7C9B7AC2201EE24001F5774 /* Main.storyboard */; };
1313
E7C9B7B02201EE27001F5774 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E7C9B7AF2201EE27001F5774 /* Assets.xcassets */; };
1414
E7C9B7B32201EE27001F5774 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E7C9B7B12201EE27001F5774 /* LaunchScreen.storyboard */; };
15-
E7C9B7C22201F4D7001F5774 /* main.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7C9B7C12201F4D7001F5774 /* main.framework */; };
16-
E7C9B7C32201F4D7001F5774 /* main.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E7C9B7C12201F4D7001F5774 /* main.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1715
/* End PBXBuildFile section */
1816

1917
/* Begin PBXCopyFilesBuildPhase section */
@@ -23,7 +21,6 @@
2321
dstPath = "";
2422
dstSubfolderSpec = 10;
2523
files = (
26-
E7C9B7C32201F4D7001F5774 /* main.framework in Embed Frameworks */,
2724
);
2825
name = "Embed Frameworks";
2926
runOnlyForDeploymentPostprocessing = 0;
@@ -38,17 +35,13 @@
3835
E7C9B7AF2201EE27001F5774 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
3936
E7C9B7B22201EE27001F5774 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4037
E7C9B7B42201EE27001F5774 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
41-
E7C9B7BB2201F33C001F5774 /* main.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = main.framework; path = ../common/build/bin/ios/mainDebugFramework/main.framework; sourceTree = "<group>"; };
42-
E7C9B7BD2201F4BF001F5774 /* main.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = main.framework; path = ../common/build/bin/ios/mainDebugFramework/main.framework; sourceTree = "<group>"; };
43-
E7C9B7C12201F4D7001F5774 /* main.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = main.framework; path = ../common/build/bin/ios/mainDebugFramework/main.framework; sourceTree = "<group>"; };
4438
/* End PBXFileReference section */
4539

4640
/* Begin PBXFrameworksBuildPhase section */
4741
E7C9B7A22201EE24001F5774 /* Frameworks */ = {
4842
isa = PBXFrameworksBuildPhase;
4943
buildActionMask = 2147483647;
5044
files = (
51-
E7C9B7C22201F4D7001F5774 /* main.framework in Frameworks */,
5245
);
5346
runOnlyForDeploymentPostprocessing = 0;
5447
};
@@ -58,8 +51,6 @@
5851
E7C9B79C2201EE24001F5774 = {
5952
isa = PBXGroup;
6053
children = (
61-
E7C9B7BD2201F4BF001F5774 /* main.framework */,
62-
E7C9B7C12201F4D7001F5774 /* main.framework */,
6354
E7C9B7A72201EE24001F5774 /* ios-app */,
6455
E7C9B7A62201EE24001F5774 /* Products */,
6556
E7C9B7BA2201F33C001F5774 /* Frameworks */,
@@ -90,7 +81,6 @@
9081
E7C9B7BA2201F33C001F5774 /* Frameworks */ = {
9182
isa = PBXGroup;
9283
children = (
93-
E7C9B7BB2201F33C001F5774 /* main.framework */,
9484
);
9585
name = Frameworks;
9686
sourceTree = "<group>";
@@ -102,6 +92,7 @@
10292
isa = PBXNativeTarget;
10393
buildConfigurationList = E7C9B7B72201EE27001F5774 /* Build configuration list for PBXNativeTarget "ios-app" */;
10494
buildPhases = (
95+
4C53B02D230D6C4E000CC7D3 /* ShellScript */,
10596
E7C9B7A12201EE24001F5774 /* Sources */,
10697
E7C9B7A22201EE24001F5774 /* Frameworks */,
10798
E7C9B7A32201EE24001F5774 /* Resources */,
@@ -162,6 +153,26 @@
162153
};
163154
/* End PBXResourcesBuildPhase section */
164155

156+
/* Begin PBXShellScriptBuildPhase section */
157+
4C53B02D230D6C4E000CC7D3 /* ShellScript */ = {
158+
isa = PBXShellScriptBuildPhase;
159+
buildActionMask = 2147483647;
160+
files = (
161+
);
162+
inputFileListPaths = (
163+
);
164+
inputPaths = (
165+
);
166+
outputFileListPaths = (
167+
);
168+
outputPaths = (
169+
);
170+
runOnlyForDeploymentPostprocessing = 0;
171+
shellPath = /bin/sh;
172+
shellScript = "\"$SRCROOT/../gradlew\" -p \"$SRCROOT/../common\" copyFramework \\\n-Pconfiguration.build.dir=\"$CONFIGURATION_BUILD_DIR\" \\\n-Pkotlin.build.type=\"$KOTLIN_BUILD_TYPE\" \\\n-Pkotlin.target=\"$KOTLIN_TARGET\"\n";
173+
};
174+
/* End PBXShellScriptBuildPhase section */
175+
165176
/* Begin PBXSourcesBuildPhase section */
166177
E7C9B7A12201EE24001F5774 /* Sources */ = {
167178
isa = PBXSourcesBuildPhase;

ios-app/ios-app/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
import UIKit
10-
import main
10+
import common
1111

1212
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
1313

js-app/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
plugins {
2-
id("org.jetbrains.kotlin.frontend")
3-
id("kotlin-dce-js")
42
id("kotlin2js")
53
}
4+
apply {
5+
plugin("org.jetbrains.kotlin.frontend")
6+
plugin("kotlin-dce-js")
7+
}
68

79
dependencies {
810
compile("org.jetbrains.kotlin:kotlin-stdlib-js:$Versions.kotlin")
9-
compile("org.jetbrains.kotlinx:kotlinx-html-js:0.6.11")
11+
compile("org.jetbrains.kotlinx:kotlinx-html:$Versions.kotlinxHtml")
1012

11-
compile("org.jetbrains:kotlin-react:16.6.0-pre.62-kotlin-1.3.0")
12-
compile("org.jetbrains:kotlin-react-dom:16.6.0-pre.62-kotlin-1.3.0")
13+
compile("org.jetbrains:kotlin-react:$Versions.kotlinReact")
14+
compile("org.jetbrains:kotlin-react-dom:$Versions.kotlinReact")
1315
compile(project(":common"))
1416
}
1517

@@ -20,10 +22,9 @@ compileKotlin2Js {
2022
}
2123

2224
kotlinFrontend {
23-
downloadNodeJsVersion = "latest"
25+
downloadNodeJsVersion = Versions.nodeJs
2426

2527
npm {
26-
dependency("kotlinx-html-js")
2728
dependency("react")
2829
dependency("react-dom")
2930
dependency("material-components-web")

0 commit comments

Comments
 (0)