Skip to content

Commit 29e7b50

Browse files
committed
Merge branch 'refs/heads/main' into v2_main
# Conflicts: # step2/composeApp/build.gradle.kts # step2/gradle/libs.versions.toml # step3/composeApp/build.gradle.kts # step3/gradle/libs.versions.toml # step4/composeApp/build.gradle.kts # step4/gradle/libs.versions.toml # step4/shared/build.gradle.kts # step5/build.gradle.kts # step5/composeApp/build.gradle.kts # step5/gradle/libs.versions.toml # step5/iosApp/iosApp.xcodeproj/project.pbxproj # step5/shared/build.gradle.kts # step5skie/composeApp/build.gradle.kts # step5skie/gradle/libs.versions.toml # step5skie/shared/build.gradle.kts
2 parents 9eab9c2 + b667c95 commit 29e7b50

File tree

53 files changed

+320
-171
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+320
-171
lines changed

step2/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
This is a Kotlin Multiplatform project targeting Android, iOS.
2+
3+
* `/composeApp` is for code that will be shared across your Compose Multiplatform applications.
4+
It contains several subfolders:
5+
- `commonMain` is for code that’s common for all targets.
6+
- Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name.
7+
For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app,
8+
`iosMain` would be the right folder for such calls.
9+
10+
* `/iosApp` contains iOS applications. Even if you’re sharing your UI with Compose Multiplatform,
11+
you need this entry point for your iOS app. This is also where you should add SwiftUI code for your project.
12+
13+
* `/shared` is for the code that will be shared between all targets in the project.
14+
The most important subfolder is `commonMain`. If preferred, you can add code to the platform-specific folders here too.
15+
16+
17+
Learn more about [Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html)

step2/composeApp/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ kotlin {
3030
implementation(compose.ui)
3131
@OptIn(ExperimentalComposeLibrary::class)
3232
implementation(compose.components.resources)
33+
implementation(compose.components.uiToolingPreview)
3334
implementation(projects.shared)
3435
}
3536
}

step2/composeApp/src/androidMain/kotlin/App.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,30 @@ import androidx.compose.foundation.layout.fillMaxWidth
55
import androidx.compose.material.Button
66
import androidx.compose.material.MaterialTheme
77
import androidx.compose.material.Text
8-
import androidx.compose.runtime.Composable
9-
import androidx.compose.runtime.getValue
10-
import androidx.compose.runtime.mutableStateOf
11-
import androidx.compose.runtime.remember
12-
import androidx.compose.runtime.setValue
8+
import androidx.compose.runtime.*
139
import androidx.compose.ui.Alignment
1410
import androidx.compose.ui.Modifier
1511
import org.jetbrains.compose.resources.ExperimentalResourceApi
1612
import org.jetbrains.compose.resources.painterResource
13+
import org.jetbrains.compose.ui.tooling.preview.Preview
14+
15+
import greetingkmp.composeapp.generated.resources.Res
16+
import greetingkmp.composeapp.generated.resources.compose_multiplatform
1717

1818
@OptIn(ExperimentalResourceApi::class)
1919
@Composable
20+
@Preview
2021
fun App() {
2122
MaterialTheme {
2223
var showContent by remember { mutableStateOf(false) }
23-
val greeting = remember { Greeting().greet() }
2424
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
2525
Button(onClick = { showContent = !showContent }) {
2626
Text("Click me!")
2727
}
2828
AnimatedVisibility(showContent) {
29+
val greeting = remember { Greeting().greet() }
2930
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
30-
Image(painterResource("compose-multiplatform.xml"), null)
31+
Image(painterResource(Res.drawable.compose_multiplatform), null)
3132
Text("Compose: $greeting")
3233
}
3334
}

step2/iosApp/iosApp.xcodeproj/project.pbxproj

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 50;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -17,12 +17,22 @@
1717
058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
1818
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
1919
2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
20-
7555FF7B242A565900829871 /* .app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = .app; sourceTree = BUILT_PRODUCTS_DIR; };
20+
7555FF7B242A565900829871 /* iosApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iosApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
2121
7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
2222
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2323
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
2424
/* End PBXFileReference section */
2525

26+
/* Begin PBXFrameworksBuildPhase section */
27+
B92378962B6B1156000C7307 /* Frameworks */ = {
28+
isa = PBXFrameworksBuildPhase;
29+
buildActionMask = 2147483647;
30+
files = (
31+
);
32+
runOnlyForDeploymentPostprocessing = 0;
33+
};
34+
/* End PBXFrameworksBuildPhase section */
35+
2636
/* Begin PBXGroup section */
2737
058557D7273AAEEB004C7B11 /* Preview Content */ = {
2838
isa = PBXGroup;
@@ -52,7 +62,7 @@
5262
7555FF7C242A565900829871 /* Products */ = {
5363
isa = PBXGroup;
5464
children = (
55-
7555FF7B242A565900829871 /* .app */,
65+
7555FF7B242A565900829871 /* iosApp.app */,
5666
);
5767
name = Products;
5868
sourceTree = "<group>";
@@ -84,17 +94,20 @@
8494
isa = PBXNativeTarget;
8595
buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */;
8696
buildPhases = (
87-
F36B1CEA2AD836FC00CB74D5 /* Compile Kotlin */,
97+
F36B1CEA2AD836FC00CB74D5 /* Compile Kotlin Framework */,
8898
7555FF77242A565900829871 /* Sources */,
99+
B92378962B6B1156000C7307 /* Frameworks */,
89100
7555FF79242A565900829871 /* Resources */,
90101
);
91102
buildRules = (
92103
);
93104
dependencies = (
94105
);
95106
name = iosApp;
107+
packageProductDependencies = (
108+
);
96109
productName = iosApp;
97-
productReference = 7555FF7B242A565900829871 /* .app */;
110+
productReference = 7555FF7B242A565900829871 /* iosApp.app */;
98111
productType = "com.apple.product-type.application";
99112
};
100113
/* End PBXNativeTarget section */
@@ -113,14 +126,16 @@
113126
};
114127
};
115128
buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */;
116-
compatibilityVersion = "Xcode 9.3";
129+
compatibilityVersion = "Xcode 12.0";
117130
developmentRegion = en;
118131
hasScannedForEncodings = 0;
119132
knownRegions = (
120133
en,
121134
Base,
122135
);
123136
mainGroup = 7555FF72242A565900829871;
137+
packageReferences = (
138+
);
124139
productRefGroup = 7555FF7C242A565900829871 /* Products */;
125140
projectDirPath = "";
126141
projectRoot = "";
@@ -143,7 +158,7 @@
143158
/* End PBXResourcesBuildPhase section */
144159

145160
/* Begin PBXShellScriptBuildPhase section */
146-
F36B1CEA2AD836FC00CB74D5 /* Compile Kotlin */ = {
161+
F36B1CEA2AD836FC00CB74D5 /* Compile Kotlin Framework */ = {
147162
isa = PBXShellScriptBuildPhase;
148163
buildActionMask = 2147483647;
149164
files = (
@@ -152,7 +167,7 @@
152167
);
153168
inputPaths = (
154169
);
155-
name = "Compile Kotlin";
170+
name = "Compile Kotlin Framework";
156171
outputFileListPaths = (
157172
);
158173
outputPaths = (
@@ -228,7 +243,7 @@
228243
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
229244
GCC_WARN_UNUSED_FUNCTION = YES;
230245
GCC_WARN_UNUSED_VARIABLE = YES;
231-
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
246+
IPHONEOS_DEPLOYMENT_TARGET = 15.3;
232247
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
233248
MTL_FAST_MATH = YES;
234249
ONLY_ACTIVE_ARCH = YES;
@@ -284,7 +299,7 @@
284299
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
285300
GCC_WARN_UNUSED_FUNCTION = YES;
286301
GCC_WARN_UNUSED_VARIABLE = YES;
287-
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
302+
IPHONEOS_DEPLOYMENT_TARGET = 15.3;
288303
MTL_ENABLE_DEBUG_INFO = NO;
289304
MTL_FAST_MATH = YES;
290305
SDKROOT = iphoneos;
@@ -304,10 +319,10 @@
304319
DEVELOPMENT_TEAM = "${TEAM_ID}";
305320
ENABLE_PREVIEWS = YES;
306321
FRAMEWORK_SEARCH_PATHS = (
307-
"$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
322+
"$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
308323
);
309324
INFOPLIST_FILE = iosApp/Info.plist;
310-
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
325+
IPHONEOS_DEPLOYMENT_TARGET = 15.3;
311326
LD_RUNPATH_SEARCH_PATHS = (
312327
"$(inherited)",
313328
"@executable_path/Frameworks",
@@ -335,10 +350,10 @@
335350
DEVELOPMENT_TEAM = "${TEAM_ID}";
336351
ENABLE_PREVIEWS = YES;
337352
FRAMEWORK_SEARCH_PATHS = (
338-
"$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
353+
"$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
339354
);
340355
INFOPLIST_FILE = iosApp/Info.plist;
341-
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
356+
IPHONEOS_DEPLOYMENT_TARGET = 15.3;
342357
LD_RUNPATH_SEARCH_PATHS = (
343358
"$(inherited)",
344359
"@executable_path/Frameworks",

step2/shared/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ kotlin {
88
androidTarget {
99
compilations.all {
1010
kotlinOptions {
11-
jvmTarget = "1.8"
11+
jvmTarget = "11"
1212
}
1313
}
1414
}
@@ -34,6 +34,10 @@ kotlin {
3434
android {
3535
namespace = "com.jetbrains.greeting.shared"
3636
compileSdk = libs.versions.android.compileSdk.get().toInt()
37+
compileOptions {
38+
sourceCompatibility = JavaVersion.VERSION_11
39+
targetCompatibility = JavaVersion.VERSION_11
40+
}
3741
defaultConfig {
3842
minSdk = libs.versions.android.minSdk.get().toInt()
3943
}

step2/shared/src/androidMain/kotlin/Platform.android.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ class AndroidPlatform : Platform {
44
override val name: String = "Android ${Build.VERSION.SDK_INT}"
55
}
66

7-
actual fun getPlatform(): Platform = AndroidPlatform()
8-
9-
actual val num: Int = 1
7+
actual fun getPlatform(): Platform = AndroidPlatform()

step2/shared/src/commonMain/kotlin/Greeting.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ class Greeting {
66
fun greet(): String {
77
val firstWord = if (Random.nextBoolean()) "Hi!" else "Hello!"
88

9-
return "$firstWord [$num] Guess what this is! > ${platform.name.reversed()}!"
9+
return "$firstWord Guess what this is! > ${platform.name.reversed()}!"
1010
}
1111
}

step2/shared/src/commonMain/kotlin/Platform.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ interface Platform {
22
val name: String
33
}
44

5-
expect fun getPlatform(): Platform
6-
7-
expect val num: Int
5+
expect fun getPlatform(): Platform

step2/shared/src/iosMain/kotlin/Platform.ios.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ class IOSPlatform: Platform {
44
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
55
}
66

7-
actual fun getPlatform(): Platform = IOSPlatform()
8-
9-
actual val num: Int = 2
7+
actual fun getPlatform(): Platform = IOSPlatform()

0 commit comments

Comments
 (0)