From 17cb5bac8b79cac7000d0a1c93e1990872fe44ad Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Mon, 2 Apr 2018 20:13:43 +0700 Subject: [PATCH] [samples] Update README.md for calculator --- samples/calculator/README.md | 58 ++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/samples/calculator/README.md b/samples/calculator/README.md index da677b6ba1f..6f99c2ec5a5 100644 --- a/samples/calculator/README.md +++ b/samples/calculator/README.md @@ -1,17 +1,29 @@ # Calculator sample -This example shows how to use Kotlin library (located in [parser/src](parser/src/)) in different environments. +This example shows how to use Kotlin common module (located in [common/](common/)) in different environments. Currently for -* iOS (see [calculator](calculator/)) -* plain JVM (cli) (see [jvmCliApp](jvmCliApp/)) -* Android (see [androidApp](androidApp/)) +* Android (see [android](android/)) +* iOS (see [ios/calculator](ios/calculator/)) +* plain JVM (cli) (see [jvm](jvm/)) + +## Common + +Common Kotlin module contains arithmetic expressions parser. + +## Android App +The common module may be used in an Android application. + +To build and run the Android sample do the following: + +1. Open [android](android/) in Android Studio 3.1 +3. Now build and run the configuration created. ## iOS -The iOS project compile the library to a framework. The framework can easily included in an existing iOS project (e.g. written in Swift or Objective-C) +The iOS project compiles Kotlin module to a framework (see [ios](ios/)). The framework can be easily included in an existing iOS project (e.g. written in Swift or Objective-C) To build and run the iOS sample do the following: -1. Open `samples/calculator/calculator.xcodeproj` with Xcode. +1. Open `ios/calculator.xcodeproj` with Xcode. 2. Open the project's target through project navigator, go to tab 'General'. In 'Identity' section change the bundle ID to the unique string in reverse-DNS format. Then select the team in 'Signing' section. @@ -21,26 +33,14 @@ To build and run the iOS sample do the following: for more info. 3. Now build and run the application with Xcode. -The sample consists of: - -1. Xcode iOS application project, written in Swift. It uses Kotlin library to - parse simple arithmetic expressions. -2. Kotlin library source code and build script. It is built into Objective-C - framework by invoking Gradle from custom "Run Script" build phase, and this - framework is imported into the Xcode project. - -## Using the same code with Kotlin/JVM -The library can also be compiled to a `.jar` by Kotlin/JVM compiler with Gradle. -Just run from the [library dir](parser/): -``` -../../gradlew jar -``` -This will generate an `arithmetic-parser.jar` in `parser/build/libs/`. +The iOS application is written in Swift. It uses Kotlin module as a library. +Kotlin module is built into Objective-C framework by invoking Gradle +from custom "Run Script" build phase, and this framework is imported into +the Xcode project. ## Plain JVM -The plain jvm sample (written in Kotlin/JVM) will use the library as a gradle dependency. - -To build and run it, go to [jvmCliApp](jvmCliApp/) directory and use +The common module can also be used in JVM application built by Kotlin/JVM compiler with Gradle. +To build and run it, go to [jvm](jvm/) directory and use ``` ../../gradlew run ``` @@ -50,12 +50,4 @@ To build the distribution: ../../gradlew distZip ``` (the result will be available as -`jvmCliApp/build/distributions/KotlinCalculator.zip`) - -## Android App -The Android App uses - similar to the plain JVM sample - the library as a gradle dependency. - -To build and run the Android sample do the following: - -1. Open `samples/calculator/androidApp` in Android Studio -2. Now build and run the androidApp application +`jvm/build/distributions/KotlinCalculator.zip`)