Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiplatform empty project #2

Merged
merged 4 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Steps to reproduce

1. Log in
2. Open this screen
3. ...

### Expected behaviour

*Explain what are you expecting to see*

### Actual behavior

*Describe the current behavior and why it is wrong*</td>
24 changes: 24 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
### :pushpin: References
* **Issue:** fixes _your issue goes here_
* **Related pull-requests:** _list of related pull-requests (comma-separated): #1, #2_

### :memo: Notes

_Additional notes for reviewers, point them to the sections you want them to review more carefully, questions you may have, etc_

### :tophat: What is the goal?

_Provide a description of the overall goal (you can usually copy the one from the issue)_

### :memo: How is it being implemented?

_Provide a description of the implementation_

### :boom: How can it be tested?

_If it cannot be tested explain why._

- [ ] **Use case 1:** _A brief description of the use case that should be tested_
- [ ] **Use case 2:** _If the use case requires some complex steps, increase indentation_
- [ ] _Step 1_
- [ ] _Step 2_
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

logs
target
/.idea
/.idea_modules
/.classpath
/.project
/.settings
.vscode
/RUNNING_PID
**/.DS_Store
.gradle/
build
out/
.kotlintest
local.properties
*.iml

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
93 changes: 93 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
plugins {
id 'kotlin-multiplatform' version '1.3.21'
}
repositories {
google()
jcenter()
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
defaultConfig {
applicationId 'com.karumi.dribbble.app'
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName '1.0'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
}

kotlin {
android("android")
// This is for iPhone emulator
// Switch here to iosArm64 (or iosArm32) to build library for iPhone device
iosX64("ios") {
compilations.main.outputKinds("framework")
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
androidMain {
dependencies {
implementation kotlin('stdlib')
}
}
androidTest {
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
iosMain {
}
iosTest {
}
}
}

// This task attaches native framework built from ios module to Xcode project
// (see iosApp directory). Don't run this task directly,
// Xcode runs this task itself during its build process.
// Before opening the project from iosApp directory in Xcode,
// make sure all Gradle infrastructure exists (gradle.wrapper, gradlew).
task copyFramework {
def buildType = project.findProperty('kotlin.build.type') ?: 'DEBUG'
def target = project.findProperty('kotlin.target') ?: 'ios'
dependsOn kotlin.targets."$target".compilations.main.linkTaskName('FRAMEWORK', buildType)

doLast {
def srcFile = kotlin.targets."$target".compilations.main.getBinary('FRAMEWORK', buildType)
def targetDir = getProperty('configuration.build.dir')
copy {
from srcFile.parent
into targetDir
include 'app.framework/**'
include 'app.framework.dSYM'
}
}
}
19 changes: 19 additions & 0 deletions app/src/commonMain/kotlin/sample/Sample.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package sample

expect class Sample() {
fun checkMe(): Int
}

expect object Platform {
val name: String
}

fun hello(): String = "Hello from ${Platform.name}"

class Proxy {
fun proxyHello() = hello()
}

fun main() {
println(hello())
}
16 changes: 16 additions & 0 deletions app/src/commonTest/kotlin/sample/SampleTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package sample

import kotlin.test.Test
import kotlin.test.assertTrue

class SampleTests {
@Test
fun testMe() {
assertTrue(Sample().checkMe() > 0)
}

@Test
fun testProxy() {
assertTrue(Proxy().proxyHello().isNotEmpty())
}
}
9 changes: 9 additions & 0 deletions app/src/iosMain/kotlin/sample/SampleIos.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package sample

actual class Sample {
actual fun checkMe() = 7
}

actual object Platform {
actual val name: String = "iOS"
}
11 changes: 11 additions & 0 deletions app/src/iosTest/kotlin/sample/SampleTestsIOS.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package sample

import kotlin.test.Test
import kotlin.test.assertTrue

class SampleTestsIOS {
@Test
fun testHello() {
assertTrue("iOS" in hello())
}
}
19 changes: 19 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sample">

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="sample.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
22 changes: 22 additions & 0 deletions app/src/main/java/sample/SampleAndroid.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package sample

import android.support.v7.app.AppCompatActivity
import android.os.Bundle

actual class Sample {
actual fun checkMe() = 44
}

actual object Platform {
actual val name: String = "Android"
}

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
hello()
Sample().checkMe()
setContentView(R.layout.activity_main)
}
}
18 changes: 18 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">android-app</string>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
11 changes: 11 additions & 0 deletions app/src/test/java/sample/SampleTestsAndroid.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package sample

import kotlin.test.Test
import kotlin.test.assertTrue

class SampleTestsAndroid {
@Test
fun testHello() {
assertTrue("Android" in hello())
}
}
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
}
}
repositories {
google()
jcenter()
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.code.style=official
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Tue Mar 05 11:07:19 CET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
Loading