├── .gitignore ├── .idea ├── artifacts │ └── SharedCode_android.xml ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── runConfigurations.xml ├── sqldelight │ └── SharedCode │ │ └── .sqldelight └── vcs.xml ├── LICENSE ├── README.md ├── SharedCode ├── build.gradle └── src │ ├── androidMain │ └── kotlin │ │ └── actual.kt │ ├── commonMain │ ├── kotlin │ │ ├── Api.kt │ │ ├── TodoRepository.kt │ │ ├── TodoViewModel.kt │ │ └── common.kt │ └── sqldelight │ │ └── com │ │ └── inovex │ │ └── cpsample │ │ └── shared │ │ └── Database.sq │ └── iosMain │ └── kotlin │ └── actual.kt ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── inovex │ │ └── cpsample │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── inovex │ │ │ └── cpsample │ │ │ └── MainActivity.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── menu │ │ └── main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── inovex │ └── cpsample │ └── TodoViewModelTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── native └── CPSample │ ├── CPSample.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── jfreymann.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist │ └── CPSample │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── TableViewCell.swift │ └── ViewController.swift └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | native/CPSample/CPSample.xcodeproj/project.xcworkspace/xcuserdata/ 2 | /SharedCode/build 3 | *.iml 4 | .gradle 5 | /local.properties 6 | /.idea/caches 7 | /.idea/libraries 8 | /.idea/modules.xml 9 | /.idea/workspace.xml 10 | /.idea/navEditor.xml 11 | /.idea/assetWizardSettings.xml 12 | .DS_Store 13 | /build 14 | /captures 15 | .externalNativeBuild 16 | -------------------------------------------------------------------------------- /.idea/artifacts/SharedCode_android.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/SharedCode/build/libs 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | xmlns:android 14 | 15 | ^$ 16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | xmlns:.* 25 | 26 | ^$ 27 | 28 | 29 | BY_NAME 30 | 31 |
32 |
33 | 34 | 35 | 36 | .*:id 37 | 38 | http://schemas.android.com/apk/res/android 39 | 40 | 41 | 42 |
43 |
44 | 45 | 46 | 47 | .*:name 48 | 49 | http://schemas.android.com/apk/res/android 50 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | 58 | name 59 | 60 | ^$ 61 | 62 | 63 | 64 |
65 |
66 | 67 | 68 | 69 | style 70 | 71 | ^$ 72 | 73 | 74 | 75 |
76 |
77 | 78 | 79 | 80 | .* 81 | 82 | ^$ 83 | 84 | 85 | BY_NAME 86 | 87 |
88 |
89 | 90 | 91 | 92 | .* 93 | 94 | http://schemas.android.com/apk/res/android 95 | 96 | 97 | ANDROID_ATTRIBUTE_ORDER 98 | 99 |
100 |
101 | 102 | 103 | 104 | .* 105 | 106 | .* 107 | 108 | 109 | BY_NAME 110 | 111 |
112 |
113 |
114 |
115 | 116 | 118 |
119 |
-------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/sqldelight/SharedCode/.sqldelight: -------------------------------------------------------------------------------- 1 | {"databases":[{"packageName":"com.inovex.cpsample.shared","compilationUnits":[{"name":"androidMain","sourceFolders":[{"path":"src/androidMain/sqldelight","dependency":false},{"path":"src/commonMain/sqldelight","dependency":false}]},{"name":"iOSMain","sourceFolders":[{"path":"src/commonMain/sqldelight","dependency":false},{"path":"src/iOSMain/sqldelight","dependency":false}]},{"name":"metadataMain","sourceFolders":[{"path":"src/commonMain/sqldelight","dependency":false}]}],"outputDirectory":"build/sqldelight/Database","className":"Database","dependencies":[]}]} -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 inovex GmbH 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Clean Architecture With Kotlin Multiplatform Example 2 | 3 | A minimal example app for Android and iOS, based on the MVVM pattern and using Kotlin Multiplatform. 4 | 5 | For more information, see blog post: [https://www.inovex.de/blog/kotlin-multiplatform-for-clean-architecture/](https://www.inovex.de/blog/kotlin-multiplatform-for-clean-architecture/) 6 | 7 | ### Android 8 | 9 | Use Android studio to open the project's root folder. Build and run the `app` configuration. 10 | 11 | ### iOS 12 | 13 | To build the app for iOS, you need a machine with OS X, Xcode the Xcode developer tools. 14 | 15 | 1. open terminal and navigate to root folder 16 | 2. run `./gradlew packForXcode` 17 | 3. open project in Xcode, located in `native/CPSample/` 18 | 4. build and run 19 | -------------------------------------------------------------------------------- /SharedCode/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'kotlin-multiplatform' 2 | apply plugin: 'com.squareup.sqldelight' 3 | apply plugin: 'kotlinx-serialization' 4 | apply plugin: 'kotlinx-atomicfu' 5 | 6 | kotlin { 7 | targets { 8 | final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \ 9 | ? presets.iosArm64 : presets.iosX64 10 | 11 | fromPreset(iOSTarget, 'iOS') { 12 | binaries { 13 | framework('SharedCode') 14 | } 15 | } 16 | 17 | fromPreset(presets.jvm, 'android') 18 | } 19 | 20 | sourceSets { 21 | commonMain { 22 | dependencies { 23 | api 'org.jetbrains.kotlin:kotlin-stdlib-common' 24 | api "com.squareup.sqldelight:runtime:$rootProject.sqldelight_version" 25 | implementation "io.ktor:ktor-client-core:$rootProject.ktor_version" 26 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines_version" 27 | implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$rootProject.serialization_version" 28 | } 29 | } 30 | 31 | androidMain { 32 | dependencies { 33 | api 'org.jetbrains.kotlin:kotlin-stdlib' 34 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines_version" 35 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines_version" 36 | implementation "io.ktor:ktor-client-android:$rootProject.ktor_version" 37 | implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$rootProject.serialization_version" 38 | } 39 | } 40 | 41 | iOSMain { 42 | dependencies { 43 | implementation "io.ktor:ktor-client-ios:$rootProject.ktor_version" 44 | implementation "com.squareup.sqldelight:ios-driver:$rootProject.sqldelight_version" 45 | implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$rootProject.serialization_version" 46 | } 47 | } 48 | 49 | all { 50 | languageSettings.progressiveMode = true 51 | } 52 | } 53 | } 54 | 55 | sqldelight { 56 | Database { 57 | packageName = "com.inovex.cpsample.shared" 58 | } 59 | } 60 | 61 | // workaround for https://youtrack.jetbrains.com/issue/KT-27170 62 | configurations { 63 | compileClasspath 64 | } 65 | // Xcode-specific 66 | task packForXCode(type: Sync) { 67 | final File frameworkDir = new File(buildDir, "xcode-frameworks") 68 | final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG' 69 | final def framework = kotlin.targets.iOS.binaries.getFramework("SharedCode", mode) 70 | 71 | inputs.property "mode", mode 72 | dependsOn framework.linkTask 73 | 74 | from { framework.outputFile.parentFile } 75 | into frameworkDir 76 | 77 | doLast { 78 | new File(frameworkDir, 'gradlew').with { 79 | text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n" 80 | setExecutable(true) 81 | } 82 | } 83 | } 84 | tasks.build.dependsOn packForXCode 85 | dependencies { 86 | } -------------------------------------------------------------------------------- /SharedCode/src/androidMain/kotlin/actual.kt: -------------------------------------------------------------------------------- 1 | package com.inovex.cpsample.shared 2 | 3 | import com.squareup.sqldelight.db.SqlDriver 4 | import kotlinx.coroutines.CoroutineDispatcher 5 | import kotlinx.coroutines.Dispatchers 6 | 7 | // This works on iOS only. 8 | actual fun getDriver(): SqlDriver? { 9 | return null 10 | } 11 | 12 | actual val mainDispatcher = Dispatchers.Main as CoroutineDispatcher 13 | actual val backgroundDispatcher = Dispatchers.Default -------------------------------------------------------------------------------- /SharedCode/src/commonMain/kotlin/Api.kt: -------------------------------------------------------------------------------- 1 | package com.inovex.cpsample.shared 2 | import io.ktor.client.HttpClient 3 | import io.ktor.client.call.call 4 | import io.ktor.client.request.url 5 | import io.ktor.client.response.readText 6 | import kotlinx.coroutines.GlobalScope 7 | import kotlinx.coroutines.Job 8 | import kotlinx.coroutines.launch 9 | import kotlinx.serialization.Serializable 10 | import kotlinx.serialization.json.Json 11 | import kotlinx.serialization.list 12 | 13 | internal class Api(private val repo: TodoRepository) { 14 | private val client = HttpClient() 15 | 16 | val baseUrl = "https://jsonplaceholder.typicode.com/" 17 | 18 | @Serializable 19 | data class ApiTodo(val title: String, val completed: Boolean) 20 | 21 | fun getTodos(): Job { 22 | val url = baseUrl + "todos/" 23 | return GlobalScope.launch(backgroundDispatcher) { 24 | val result = client.call { 25 | url(url) 26 | }.response.readText() 27 | val apiTodos = Json.nonstrict.parse(ApiTodo.serializer().list, result) 28 | CommonDatabase.database.transaction { 29 | apiTodos.forEach { 30 | repo.addTodo(it.title, it.completed) 31 | } 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /SharedCode/src/commonMain/kotlin/TodoRepository.kt: -------------------------------------------------------------------------------- 1 | package com.inovex.cpsample.shared 2 | 3 | class TodoRepository { 4 | fun addTodo(title: String, completed: Boolean) { 5 | CommonDatabase.addTodo(title, completed) 6 | } 7 | 8 | fun observeTodos(id: Int, onChangeCallback: (List) -> Unit) { 9 | CommonDatabase.observeTodos(id, onChangeCallback) 10 | } 11 | 12 | fun stopObservingTodos(id: Int) { 13 | CommonDatabase.stopObservingTodos(id) 14 | } 15 | 16 | fun deleteAll() { 17 | CommonDatabase.deleteAll() 18 | } 19 | } -------------------------------------------------------------------------------- /SharedCode/src/commonMain/kotlin/TodoViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.inovex.cpsample.shared 2 | 3 | import kotlinx.coroutines.GlobalScope 4 | import kotlinx.coroutines.launch 5 | 6 | class TodoViewModel(private val repo: TodoRepository = TodoRepository()) { 7 | private val id: Int = idCounter.getAndIncrement() 8 | 9 | private val api by lazy { Api(repo) } 10 | 11 | fun observeTodos(onChangeCallback: (List) -> Unit) { 12 | repo.observeTodos(id) { 13 | GlobalScope.launch(mainDispatcher) { 14 | onChangeCallback(it) 15 | } 16 | } 17 | } 18 | 19 | fun clearTodos() { 20 | repo.deleteAll() 21 | } 22 | 23 | fun triggerSync() { 24 | api.getTodos() 25 | } 26 | 27 | fun onDestroy() { 28 | repo.stopObservingTodos(id) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SharedCode/src/commonMain/kotlin/common.kt: -------------------------------------------------------------------------------- 1 | package com.inovex.cpsample.shared 2 | 3 | import com.squareup.sqldelight.Query 4 | import com.squareup.sqldelight.db.SqlDriver 5 | import kotlinx.atomicfu.atomic 6 | import kotlinx.coroutines.CoroutineDispatcher 7 | import kotlin.native.concurrent.ThreadLocal 8 | 9 | expect fun getDriver(): SqlDriver? 10 | 11 | @ThreadLocal 12 | expect val mainDispatcher: CoroutineDispatcher 13 | 14 | @ThreadLocal 15 | expect val backgroundDispatcher: CoroutineDispatcher 16 | 17 | @ThreadLocal 18 | object CommonDatabase { 19 | var driver: SqlDriver? = getDriver() 20 | val database: Database by lazy { 21 | Database(driver!!) 22 | } 23 | 24 | private val observers: MutableMap = mutableMapOf() 25 | 26 | fun addTodo(title: String, completed: Boolean) { 27 | val completedNum = if (completed) 1L else 0L 28 | database.databaseQueries.insert(title, completedNum) 29 | } 30 | 31 | fun observeTodos(id: Int, onChangeCallback: (List) -> Unit) { 32 | if (observers.containsKey(id)) { 33 | throw RuntimeException("Already observing with id $id") 34 | } else { 35 | val listener = object : Query.Listener { 36 | override fun queryResultsChanged() { 37 | onChangeCallback(database.databaseQueries.selectAll().executeAsList()) 38 | } 39 | } 40 | observers[id] = listener 41 | database.databaseQueries.selectAll().addListener(listener) 42 | } 43 | } 44 | 45 | fun stopObservingTodos(id: Int) { 46 | observers[id]?.let { 47 | database.databaseQueries.selectAll().removeListener(it) 48 | } 49 | } 50 | 51 | fun deleteAll() { 52 | database.databaseQueries.deleteAll() 53 | } 54 | } 55 | 56 | internal val idCounter = atomic(0) 57 | -------------------------------------------------------------------------------- /SharedCode/src/commonMain/sqldelight/com/inovex/cpsample/shared/Database.sq: -------------------------------------------------------------------------------- 1 | CREATE TABLE todo( 2 | id INTEGER PRIMARY KEY AUTOINCREMENT, 3 | title TEXT NOT NULL, 4 | completed INTEGER 5 | ); 6 | 7 | 8 | selectAll: 9 | SELECT * 10 | FROM todo; 11 | 12 | insert: 13 | INSERT INTO todo(title, completed) 14 | VALUES (?, ?); 15 | 16 | deleteAll: 17 | DELETE FROM todo; -------------------------------------------------------------------------------- /SharedCode/src/iosMain/kotlin/actual.kt: -------------------------------------------------------------------------------- 1 | package com.inovex.cpsample.shared 2 | 3 | import com.squareup.sqldelight.db.SqlDriver 4 | import com.squareup.sqldelight.drivers.ios.NativeSqliteDriver 5 | import kotlinx.coroutines.CoroutineDispatcher 6 | import kotlinx.coroutines.Runnable 7 | import platform.Foundation.NSRunLoop 8 | import platform.Foundation.performBlock 9 | import platform.darwin.dispatch_async 10 | import platform.darwin.dispatch_get_global_queue 11 | import platform.darwin.dispatch_get_main_queue 12 | import platform.darwin.dispatch_queue_t 13 | import platform.posix.QOS_CLASS_BACKGROUND 14 | import kotlin.coroutines.CoroutineContext 15 | 16 | actual fun getDriver(): SqlDriver? { 17 | return NativeSqliteDriver(Database.Schema, "main.db") 18 | } 19 | 20 | // see https://github.com/Kotlin/kotlinx.coroutines/issues/470#issuecomment-414635811 21 | actual val mainDispatcher = object : CoroutineDispatcher() { 22 | override fun dispatch(context: CoroutineContext, block: Runnable) { 23 | dispatch_async(dispatch_get_main_queue()) { 24 | block.run() 25 | } 26 | } 27 | } 28 | 29 | 30 | // At the moment, background threads for corotuines are not supported in Kotlin Native :( 31 | // see https://github.com/Kotlin/kotlinx.coroutines/issues/462 32 | actual val backgroundDispatcher = mainDispatcher 33 | 34 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion 28 7 | defaultConfig { 8 | applicationId "com.inovex.cpsample" 9 | minSdkVersion 23 10 | targetSdkVersion 28 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | 22 | packagingOptions { 23 | exclude 'META-INF/*.kotlin_module' 24 | } 25 | } 26 | 27 | dependencies { 28 | implementation fileTree(include: ['*.jar'], dir: 'libs') 29 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 30 | implementation 'androidx.appcompat:appcompat:1.0.0-beta01' 31 | implementation 'androidx.core:core-ktx:1.1.0-alpha05' 32 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 33 | androidTestImplementation 'androidx.test:runner:1.1.0-alpha4' 34 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4' 35 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1' 36 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1' 37 | implementation "com.squareup.sqldelight:runtime-jvm:1.1.3" 38 | implementation "com.squareup.sqldelight:android-driver:1.1.3" 39 | 40 | // Testing 41 | testImplementation 'junit:junit:4.12' 42 | testImplementation "io.mockk:mockk:1.9.3" 43 | testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" 44 | 45 | implementation project(':SharedCode') 46 | 47 | } 48 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/inovex/cpsample/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.inovex.cpsample 2 | 3 | import androidx.test.InstrumentationRegistry 4 | import androidx.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.inovex.cpsample", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/inovex/cpsample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.inovex.cpsample 2 | 3 | import android.os.Bundle 4 | import android.view.Menu 5 | import android.view.MenuItem 6 | import android.widget.ArrayAdapter 7 | import android.widget.ListView 8 | import android.widget.Toast 9 | import androidx.appcompat.app.AppCompatActivity 10 | import com.inovex.cpsample.shared.CommonDatabase 11 | import com.inovex.cpsample.shared.Database 12 | import com.inovex.cpsample.shared.TodoViewModel 13 | import com.squareup.sqldelight.android.AndroidSqliteDriver 14 | 15 | 16 | class MainActivity : AppCompatActivity() { 17 | val todoList by lazy { findViewById(R.id.list_todo) } 18 | var adapter: ArrayAdapter? = null 19 | 20 | private val viewModel = TodoViewModel() 21 | 22 | override fun onCreate(savedInstanceState: Bundle?) { 23 | super.onCreate(savedInstanceState) 24 | setContentView(R.layout.activity_main) 25 | 26 | // Init driver (with multiple activities, this should be moved to the Application class) 27 | val driver = AndroidSqliteDriver(Database.Schema, this.applicationContext, "main.db") 28 | CommonDatabase.driver = driver 29 | 30 | viewModel.observeTodos { todos -> 31 | if (adapter == null) { 32 | adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, todos.map { it.title }) 33 | todoList.adapter = adapter 34 | } else { 35 | adapter!!.apply { 36 | clear() 37 | todos.forEach { insert(it.title, count) } 38 | notifyDataSetChanged() 39 | } 40 | } 41 | Toast.makeText(this, "Updated TODO list", Toast.LENGTH_SHORT).show() 42 | } 43 | 44 | } 45 | 46 | override fun onCreateOptionsMenu(menu: Menu?): Boolean { 47 | menuInflater.inflate(R.menu.main, menu) 48 | return super.onCreateOptionsMenu(menu) 49 | } 50 | 51 | override fun onOptionsItemSelected(item: MenuItem?): Boolean { 52 | return when (item?.itemId) { 53 | R.id.action_sync -> { 54 | viewModel.triggerSync() 55 | true 56 | } 57 | R.id.action_clear -> { 58 | viewModel.clearTodos() 59 | true 60 | } 61 | else -> super.onOptionsItemSelected(item) 62 | } 63 | } 64 | 65 | override fun onDestroy() { 66 | viewModel.onDestroy() 67 | super.onDestroy() 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inovex/kotlin-multiplatform-sample/bd2e19bfe322600f858d5c7c4969070c07120503/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inovex/kotlin-multiplatform-sample/bd2e19bfe322600f858d5c7c4969070c07120503/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inovex/kotlin-multiplatform-sample/bd2e19bfe322600f858d5c7c4969070c07120503/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inovex/kotlin-multiplatform-sample/bd2e19bfe322600f858d5c7c4969070c07120503/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inovex/kotlin-multiplatform-sample/bd2e19bfe322600f858d5c7c4969070c07120503/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inovex/kotlin-multiplatform-sample/bd2e19bfe322600f858d5c7c4969070c07120503/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inovex/kotlin-multiplatform-sample/bd2e19bfe322600f858d5c7c4969070c07120503/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inovex/kotlin-multiplatform-sample/bd2e19bfe322600f858d5c7c4969070c07120503/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inovex/kotlin-multiplatform-sample/bd2e19bfe322600f858d5c7c4969070c07120503/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inovex/kotlin-multiplatform-sample/bd2e19bfe322600f858d5c7c4969070c07120503/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Cross Platform Sample 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/inovex/cpsample/TodoViewModelTest.kt: -------------------------------------------------------------------------------- 1 | package com.inovex.cpsample 2 | 3 | import com.inovex.cpsample.shared.Todo 4 | import com.inovex.cpsample.shared.TodoRepository 5 | import com.inovex.cpsample.shared.TodoViewModel 6 | import io.mockk.every 7 | import io.mockk.mockk 8 | import io.mockk.verify 9 | import kotlinx.coroutines.Dispatchers 10 | import kotlinx.coroutines.newSingleThreadContext 11 | import kotlinx.coroutines.test.setMain 12 | import org.junit.Before 13 | import org.junit.Test 14 | import java.util.concurrent.CountDownLatch 15 | import java.util.concurrent.TimeUnit 16 | 17 | class TodoViewModelTest { 18 | private val mockedRepo = mockk(relaxed = true) 19 | private val viewModel = TodoViewModel(mockedRepo) 20 | 21 | private val mainThreadSurrogate = newSingleThreadContext("UI thread") 22 | 23 | @Before 24 | fun init() { 25 | Dispatchers.setMain(mainThreadSurrogate) 26 | } 27 | 28 | @Test 29 | fun testObserveTodos() { 30 | val latch = CountDownLatch(1) 31 | var resultList: List? = null 32 | val mockedTodo = mockk() 33 | every { mockedRepo.observeTodos(any(), any()) } answers { 34 | secondArg<(List) -> Unit>().invoke(listOf(mockedTodo)) 35 | } 36 | viewModel.observeTodos { 37 | resultList = it 38 | latch.countDown() 39 | } 40 | latch.await(500L, TimeUnit.MILLISECONDS) 41 | assert(resultList != null) 42 | } 43 | 44 | @Test 45 | fun testClearTodos() { 46 | viewModel.clearTodos() 47 | verify { 48 | mockedRepo.deleteAll() 49 | } 50 | } 51 | 52 | @Test 53 | fun testOnDestroy() { 54 | viewModel.onDestroy() 55 | verify { mockedRepo.stopObservingTodos(any()) } 56 | } 57 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.3.30' 5 | ext.sqldelight_version = '1.1.3' 6 | ext.ktor_version = '1.2.1' 7 | ext.coroutines_version = '1.2.2' 8 | ext.serialization_version = '0.11.0' 9 | ext.atomicfu_version = '0.12.7' 10 | repositories { 11 | google() 12 | jcenter() 13 | maven { url "https://kotlin.bintray.com/kotlinx" } // for kotlinx-serialization 14 | } 15 | dependencies { 16 | classpath 'com.android.tools.build:gradle:3.4.0' 17 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 18 | classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" 19 | classpath 'com.squareup.sqldelight:gradle-plugin:1.1.3' 20 | classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version" 21 | // NOTE: Do not place your application dependencies here; they belong 22 | // in the individual module build.gradle files 23 | } 24 | } 25 | 26 | allprojects { 27 | repositories { 28 | google() 29 | jcenter() 30 | mavenCentral() 31 | } 32 | } 33 | 34 | task clean(type: Delete) { 35 | delete rootProject.buildDir 36 | } 37 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | 23 | org.gradle.parallel=true 24 | 25 | # disable on demand config, see https://github.com/square/sqldelight/issues/1300 26 | org.gradle.configureondemand=false -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/inovex/kotlin-multiplatform-sample/bd2e19bfe322600f858d5c7c4969070c07120503/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue May 07 07:15:38 CEST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /native/CPSample/CPSample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 13167FEF2264B51C00E62544 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13167FEE2264B51C00E62544 /* AppDelegate.swift */; }; 11 | 13167FF12264B51C00E62544 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13167FF02264B51C00E62544 /* ViewController.swift */; }; 12 | 13167FF42264B51C00E62544 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 13167FF22264B51C00E62544 /* Main.storyboard */; }; 13 | 13167FF62264B51D00E62544 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13167FF52264B51D00E62544 /* Assets.xcassets */; }; 14 | 13167FF92264B51D00E62544 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 13167FF72264B51D00E62544 /* LaunchScreen.storyboard */; }; 15 | 131680062264B85A00E62544 /* SharedCode.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 131680012264B72900E62544 /* SharedCode.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 16 | 13504AFD22684C2200FA458D /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 13504AFC22684C2200FA458D /* libsqlite3.tbd */; }; 17 | 137C058322A121D2007ACF6D /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 137C058222A121D2007ACF6D /* TableViewCell.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXCopyFilesBuildPhase section */ 21 | 131680072264B85A00E62544 /* Embed Frameworks */ = { 22 | isa = PBXCopyFilesBuildPhase; 23 | buildActionMask = 2147483647; 24 | dstPath = ""; 25 | dstSubfolderSpec = 10; 26 | files = ( 27 | 131680062264B85A00E62544 /* SharedCode.framework in Embed Frameworks */, 28 | ); 29 | name = "Embed Frameworks"; 30 | runOnlyForDeploymentPostprocessing = 0; 31 | }; 32 | /* End PBXCopyFilesBuildPhase section */ 33 | 34 | /* Begin PBXFileReference section */ 35 | 13167FEB2264B51C00E62544 /* CPSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CPSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | 13167FEE2264B51C00E62544 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 13167FF02264B51C00E62544 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 38 | 13167FF32264B51C00E62544 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 39 | 13167FF52264B51D00E62544 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 40 | 13167FF82264B51D00E62544 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 41 | 13167FFA2264B51D00E62544 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | 131680012264B72900E62544 /* SharedCode.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SharedCode.framework; path = "../../SharedCode/build/xcode-frameworks/SharedCode.framework"; sourceTree = ""; }; 43 | 13504AFC22684C2200FA458D /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; }; 44 | 137C058222A121D2007ACF6D /* TableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewCell.swift; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 13167FE82264B51C00E62544 /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | 13504AFD22684C2200FA458D /* libsqlite3.tbd in Frameworks */, 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXFrameworksBuildPhase section */ 57 | 58 | /* Begin PBXGroup section */ 59 | 13167FE22264B51C00E62544 = { 60 | isa = PBXGroup; 61 | children = ( 62 | 13167FED2264B51C00E62544 /* CPSample */, 63 | 13167FEC2264B51C00E62544 /* Products */, 64 | 131680002264B72900E62544 /* Frameworks */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | 13167FEC2264B51C00E62544 /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 13167FEB2264B51C00E62544 /* CPSample.app */, 72 | ); 73 | name = Products; 74 | sourceTree = ""; 75 | }; 76 | 13167FED2264B51C00E62544 /* CPSample */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 13167FEE2264B51C00E62544 /* AppDelegate.swift */, 80 | 13167FF02264B51C00E62544 /* ViewController.swift */, 81 | 13167FF22264B51C00E62544 /* Main.storyboard */, 82 | 13167FF52264B51D00E62544 /* Assets.xcassets */, 83 | 13167FF72264B51D00E62544 /* LaunchScreen.storyboard */, 84 | 13167FFA2264B51D00E62544 /* Info.plist */, 85 | 137C058222A121D2007ACF6D /* TableViewCell.swift */, 86 | ); 87 | path = CPSample; 88 | sourceTree = ""; 89 | }; 90 | 131680002264B72900E62544 /* Frameworks */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 13504AFC22684C2200FA458D /* libsqlite3.tbd */, 94 | 131680012264B72900E62544 /* SharedCode.framework */, 95 | ); 96 | name = Frameworks; 97 | sourceTree = ""; 98 | }; 99 | /* End PBXGroup section */ 100 | 101 | /* Begin PBXNativeTarget section */ 102 | 13167FEA2264B51C00E62544 /* CPSample */ = { 103 | isa = PBXNativeTarget; 104 | buildConfigurationList = 13167FFD2264B51D00E62544 /* Build configuration list for PBXNativeTarget "CPSample" */; 105 | buildPhases = ( 106 | 131680042264B74700E62544 /* ShellScript */, 107 | 13167FE72264B51C00E62544 /* Sources */, 108 | 13167FE82264B51C00E62544 /* Frameworks */, 109 | 13167FE92264B51C00E62544 /* Resources */, 110 | 131680072264B85A00E62544 /* Embed Frameworks */, 111 | ); 112 | buildRules = ( 113 | ); 114 | dependencies = ( 115 | ); 116 | name = CPSample; 117 | productName = CPSample; 118 | productReference = 13167FEB2264B51C00E62544 /* CPSample.app */; 119 | productType = "com.apple.product-type.application"; 120 | }; 121 | /* End PBXNativeTarget section */ 122 | 123 | /* Begin PBXProject section */ 124 | 13167FE32264B51C00E62544 /* Project object */ = { 125 | isa = PBXProject; 126 | attributes = { 127 | LastSwiftUpdateCheck = 1020; 128 | LastUpgradeCheck = 1020; 129 | ORGANIZATIONNAME = "Jan Freymann"; 130 | TargetAttributes = { 131 | 13167FEA2264B51C00E62544 = { 132 | CreatedOnToolsVersion = 10.2; 133 | }; 134 | }; 135 | }; 136 | buildConfigurationList = 13167FE62264B51C00E62544 /* Build configuration list for PBXProject "CPSample" */; 137 | compatibilityVersion = "Xcode 9.3"; 138 | developmentRegion = en; 139 | hasScannedForEncodings = 0; 140 | knownRegions = ( 141 | en, 142 | Base, 143 | ); 144 | mainGroup = 13167FE22264B51C00E62544; 145 | productRefGroup = 13167FEC2264B51C00E62544 /* Products */; 146 | projectDirPath = ""; 147 | projectRoot = ""; 148 | targets = ( 149 | 13167FEA2264B51C00E62544 /* CPSample */, 150 | ); 151 | }; 152 | /* End PBXProject section */ 153 | 154 | /* Begin PBXResourcesBuildPhase section */ 155 | 13167FE92264B51C00E62544 /* Resources */ = { 156 | isa = PBXResourcesBuildPhase; 157 | buildActionMask = 2147483647; 158 | files = ( 159 | 13167FF92264B51D00E62544 /* LaunchScreen.storyboard in Resources */, 160 | 13167FF62264B51D00E62544 /* Assets.xcassets in Resources */, 161 | 13167FF42264B51C00E62544 /* Main.storyboard in Resources */, 162 | ); 163 | runOnlyForDeploymentPostprocessing = 0; 164 | }; 165 | /* End PBXResourcesBuildPhase section */ 166 | 167 | /* Begin PBXShellScriptBuildPhase section */ 168 | 131680042264B74700E62544 /* ShellScript */ = { 169 | isa = PBXShellScriptBuildPhase; 170 | buildActionMask = 2147483647; 171 | files = ( 172 | ); 173 | inputFileListPaths = ( 174 | ); 175 | inputPaths = ( 176 | ); 177 | outputFileListPaths = ( 178 | ); 179 | outputPaths = ( 180 | ); 181 | runOnlyForDeploymentPostprocessing = 0; 182 | shellPath = /bin/sh; 183 | shellScript = "# Type a script or drag a script file from your workspace to insert its path.\ncd \"$SRCROOT/../../SharedCode/build/xcode-frameworks\"\n./gradlew :SharedCode:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION}\n"; 184 | }; 185 | /* End PBXShellScriptBuildPhase section */ 186 | 187 | /* Begin PBXSourcesBuildPhase section */ 188 | 13167FE72264B51C00E62544 /* Sources */ = { 189 | isa = PBXSourcesBuildPhase; 190 | buildActionMask = 2147483647; 191 | files = ( 192 | 137C058322A121D2007ACF6D /* TableViewCell.swift in Sources */, 193 | 13167FF12264B51C00E62544 /* ViewController.swift in Sources */, 194 | 13167FEF2264B51C00E62544 /* AppDelegate.swift in Sources */, 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | }; 198 | /* End PBXSourcesBuildPhase section */ 199 | 200 | /* Begin PBXVariantGroup section */ 201 | 13167FF22264B51C00E62544 /* Main.storyboard */ = { 202 | isa = PBXVariantGroup; 203 | children = ( 204 | 13167FF32264B51C00E62544 /* Base */, 205 | ); 206 | name = Main.storyboard; 207 | sourceTree = ""; 208 | }; 209 | 13167FF72264B51D00E62544 /* LaunchScreen.storyboard */ = { 210 | isa = PBXVariantGroup; 211 | children = ( 212 | 13167FF82264B51D00E62544 /* Base */, 213 | ); 214 | name = LaunchScreen.storyboard; 215 | sourceTree = ""; 216 | }; 217 | /* End PBXVariantGroup section */ 218 | 219 | /* Begin XCBuildConfiguration section */ 220 | 13167FFB2264B51D00E62544 /* Debug */ = { 221 | isa = XCBuildConfiguration; 222 | buildSettings = { 223 | ALWAYS_SEARCH_USER_PATHS = NO; 224 | CLANG_ANALYZER_NONNULL = YES; 225 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 226 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 227 | CLANG_CXX_LIBRARY = "libc++"; 228 | CLANG_ENABLE_MODULES = YES; 229 | CLANG_ENABLE_OBJC_ARC = YES; 230 | CLANG_ENABLE_OBJC_WEAK = YES; 231 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 232 | CLANG_WARN_BOOL_CONVERSION = YES; 233 | CLANG_WARN_COMMA = YES; 234 | CLANG_WARN_CONSTANT_CONVERSION = YES; 235 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 236 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 237 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 238 | CLANG_WARN_EMPTY_BODY = YES; 239 | CLANG_WARN_ENUM_CONVERSION = YES; 240 | CLANG_WARN_INFINITE_RECURSION = YES; 241 | CLANG_WARN_INT_CONVERSION = YES; 242 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 243 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 244 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 245 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 246 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 247 | CLANG_WARN_STRICT_PROTOTYPES = YES; 248 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 249 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 250 | CLANG_WARN_UNREACHABLE_CODE = YES; 251 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 252 | CODE_SIGN_IDENTITY = "iPhone Developer"; 253 | COPY_PHASE_STRIP = NO; 254 | DEBUG_INFORMATION_FORMAT = dwarf; 255 | ENABLE_BITCODE = NO; 256 | ENABLE_STRICT_OBJC_MSGSEND = YES; 257 | ENABLE_TESTABILITY = YES; 258 | GCC_C_LANGUAGE_STANDARD = gnu11; 259 | GCC_DYNAMIC_NO_PIC = NO; 260 | GCC_NO_COMMON_BLOCKS = YES; 261 | GCC_OPTIMIZATION_LEVEL = 0; 262 | GCC_PREPROCESSOR_DEFINITIONS = ( 263 | "DEBUG=1", 264 | "$(inherited)", 265 | ); 266 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 267 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 268 | GCC_WARN_UNDECLARED_SELECTOR = YES; 269 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 270 | GCC_WARN_UNUSED_FUNCTION = YES; 271 | GCC_WARN_UNUSED_VARIABLE = YES; 272 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 273 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 274 | MTL_FAST_MATH = YES; 275 | ONLY_ACTIVE_ARCH = YES; 276 | SDKROOT = iphoneos; 277 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 278 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 279 | }; 280 | name = Debug; 281 | }; 282 | 13167FFC2264B51D00E62544 /* Release */ = { 283 | isa = XCBuildConfiguration; 284 | buildSettings = { 285 | ALWAYS_SEARCH_USER_PATHS = NO; 286 | CLANG_ANALYZER_NONNULL = YES; 287 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 288 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 289 | CLANG_CXX_LIBRARY = "libc++"; 290 | CLANG_ENABLE_MODULES = YES; 291 | CLANG_ENABLE_OBJC_ARC = YES; 292 | CLANG_ENABLE_OBJC_WEAK = YES; 293 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 294 | CLANG_WARN_BOOL_CONVERSION = YES; 295 | CLANG_WARN_COMMA = YES; 296 | CLANG_WARN_CONSTANT_CONVERSION = YES; 297 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 298 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 299 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 300 | CLANG_WARN_EMPTY_BODY = YES; 301 | CLANG_WARN_ENUM_CONVERSION = YES; 302 | CLANG_WARN_INFINITE_RECURSION = YES; 303 | CLANG_WARN_INT_CONVERSION = YES; 304 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 305 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 306 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 307 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 308 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 309 | CLANG_WARN_STRICT_PROTOTYPES = YES; 310 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 311 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 312 | CLANG_WARN_UNREACHABLE_CODE = YES; 313 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 314 | CODE_SIGN_IDENTITY = "iPhone Developer"; 315 | COPY_PHASE_STRIP = NO; 316 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 317 | ENABLE_BITCODE = NO; 318 | ENABLE_NS_ASSERTIONS = NO; 319 | ENABLE_STRICT_OBJC_MSGSEND = YES; 320 | GCC_C_LANGUAGE_STANDARD = gnu11; 321 | GCC_NO_COMMON_BLOCKS = YES; 322 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 323 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 324 | GCC_WARN_UNDECLARED_SELECTOR = YES; 325 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 326 | GCC_WARN_UNUSED_FUNCTION = YES; 327 | GCC_WARN_UNUSED_VARIABLE = YES; 328 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 329 | MTL_ENABLE_DEBUG_INFO = NO; 330 | MTL_FAST_MATH = YES; 331 | SDKROOT = iphoneos; 332 | SWIFT_COMPILATION_MODE = wholemodule; 333 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 334 | VALIDATE_PRODUCT = YES; 335 | }; 336 | name = Release; 337 | }; 338 | 13167FFE2264B51D00E62544 /* Debug */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 342 | CODE_SIGN_STYLE = Automatic; 343 | FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../../SharedCode/build/xcode-frameworks"; 344 | INFOPLIST_FILE = CPSample/Info.plist; 345 | LD_RUNPATH_SEARCH_PATHS = ( 346 | "$(inherited)", 347 | "@executable_path/Frameworks", 348 | ); 349 | PRODUCT_BUNDLE_IDENTIFIER = com.inovex.CPSample; 350 | PRODUCT_NAME = "$(TARGET_NAME)"; 351 | SWIFT_VERSION = 5.0; 352 | TARGETED_DEVICE_FAMILY = "1,2"; 353 | }; 354 | name = Debug; 355 | }; 356 | 13167FFF2264B51D00E62544 /* Release */ = { 357 | isa = XCBuildConfiguration; 358 | buildSettings = { 359 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 360 | CODE_SIGN_STYLE = Automatic; 361 | FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../../SharedCode/build/xcode-frameworks"; 362 | INFOPLIST_FILE = CPSample/Info.plist; 363 | LD_RUNPATH_SEARCH_PATHS = ( 364 | "$(inherited)", 365 | "@executable_path/Frameworks", 366 | ); 367 | PRODUCT_BUNDLE_IDENTIFIER = com.inovex.CPSample; 368 | PRODUCT_NAME = "$(TARGET_NAME)"; 369 | SWIFT_VERSION = 5.0; 370 | TARGETED_DEVICE_FAMILY = "1,2"; 371 | }; 372 | name = Release; 373 | }; 374 | /* End XCBuildConfiguration section */ 375 | 376 | /* Begin XCConfigurationList section */ 377 | 13167FE62264B51C00E62544 /* Build configuration list for PBXProject "CPSample" */ = { 378 | isa = XCConfigurationList; 379 | buildConfigurations = ( 380 | 13167FFB2264B51D00E62544 /* Debug */, 381 | 13167FFC2264B51D00E62544 /* Release */, 382 | ); 383 | defaultConfigurationIsVisible = 0; 384 | defaultConfigurationName = Release; 385 | }; 386 | 13167FFD2264B51D00E62544 /* Build configuration list for PBXNativeTarget "CPSample" */ = { 387 | isa = XCConfigurationList; 388 | buildConfigurations = ( 389 | 13167FFE2264B51D00E62544 /* Debug */, 390 | 13167FFF2264B51D00E62544 /* Release */, 391 | ); 392 | defaultConfigurationIsVisible = 0; 393 | defaultConfigurationName = Release; 394 | }; 395 | /* End XCConfigurationList section */ 396 | }; 397 | rootObject = 13167FE32264B51C00E62544 /* Project object */; 398 | } 399 | -------------------------------------------------------------------------------- /native/CPSample/CPSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /native/CPSample/CPSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /native/CPSample/CPSample.xcodeproj/xcuserdata/jfreymann.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CPSample.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /native/CPSample/CPSample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CPSample 4 | // 5 | // Created by Jan Freymann on 15.04.19. 6 | // Copyright © 2019 Jan Freymann. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /native/CPSample/CPSample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /native/CPSample/CPSample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /native/CPSample/CPSample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /native/CPSample/CPSample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /native/CPSample/CPSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /native/CPSample/CPSample/TableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewCell.swift 3 | // CPSample 4 | // 5 | // Created by Jan Freymann on 31.05.19. 6 | // Copyright © 2019 Jan Freymann. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class TableViewCell: UITableViewCell { 12 | 13 | @IBOutlet weak var label: UILabel! 14 | 15 | override func awakeFromNib() { 16 | super.awakeFromNib() 17 | // Initialization code 18 | } 19 | 20 | override func setSelected(_ selected: Bool, animated: Bool) { 21 | super.setSelected(selected, animated: animated) 22 | 23 | // Configure the view for the selected state 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /native/CPSample/CPSample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CPSample 4 | // 5 | // Created by Jan Freymann on 15.04.19. 6 | // Copyright © 2019 Jan Freymann. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SharedCode 11 | 12 | class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { 13 | @IBOutlet weak var tableView: UITableView! 14 | 15 | var todos: [String]? 16 | let viewModel = TodoViewModel(repo: TodoRepository()) 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | viewModel.observeTodos(onChangeCallback: { (list: [Todo]) -> KotlinUnit in 21 | self.todos = list.map { (t) -> String in return t.title } 22 | self.tableView.reloadData() 23 | return KotlinUnit() 24 | }) 25 | syncData(self) 26 | } 27 | 28 | @IBAction func clearData(_ sender: Any) { 29 | viewModel.clearTodos() 30 | } 31 | 32 | @IBAction func syncData(_ sender: Any) { 33 | viewModel.triggerSync() 34 | } 35 | 36 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 37 | guard let todoList = todos else { 38 | return 0 39 | } 40 | 41 | return todoList.count 42 | } 43 | 44 | deinit { 45 | viewModel.onDestroy() 46 | } 47 | 48 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 49 | let cell = self.tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewCell 50 | 51 | cell.label.text = todos![indexPath.row] 52 | return cell 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | include ':SharedCode' 3 | 4 | 5 | enableFeaturePreview('GRADLE_METADATA') 6 | --------------------------------------------------------------------------------