Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex009 committed Oct 14, 2019
2 parents a0f01ee + f01d496 commit 327eef8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 41 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This is a Kotlin MultiPlatform library that provides access to the resources on
- 0.1.0
- 0.2.0
- 0.3.0
- 0.4.0

## Installation
root build.gradle
Expand All @@ -39,7 +40,7 @@ buildscript {
}
dependencies {
classpath "dev.icerock.moko:resources-generator:0.3.0"
classpath "dev.icerock.moko:resources-generator:0.4.0"
}
}
Expand All @@ -56,7 +57,11 @@ project build.gradle
apply plugin: "dev.icerock.mobile.multiplatform-resources"
dependencies {
commonMainApi("dev.icerock.moko:resources:0.3.0")
commonMainApi("dev.icerock.moko:resources:0.4.0")
}
multiplatformResources {
multiplatformResourcesPackage = "org.example.library"
}
```

Expand All @@ -67,7 +72,7 @@ enableFeaturePreview("GRADLE_METADATA")

On iOS, in addition to the Kotlin library add Pod in the Podfile.
```ruby
pod 'MultiPlatformLibraryResources', :git => 'https://github.com/icerockdev/moko-resources.git', :tag => 'release/0.2.0'
pod 'MultiPlatformLibraryResources', :git => 'https://github.com/icerockdev/moko-resources.git', :tag => 'release/0.4.0'
```
**`MultiPlatformLibraryResources` CocoaPod requires that the framework compiled from Kotlin be named
`MultiPlatformLibrary` and be connected as a CocoaPod `MultiPlatformLibrary`.
Expand Down
8 changes: 3 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

import java.net.URI

allprojects {
repositories {
mavenLocal()

google()
jcenter()

maven { url = URI("https://kotlin.bintray.com/kotlin") }
maven { url = URI("https://kotlin.bintray.com/kotlinx") }
maven { url = URI("https://dl.bintray.com/icerockdev/moko") }
maven { url = uri("https://kotlin.bintray.com/kotlin") }
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
maven { url = uri("https://dl.bintray.com/icerockdev/moko") }
}

// workaround for https://youtrack.jetbrains.com/issue/KT-27170
Expand Down
4 changes: 3 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ repositories {
}

dependencies {
implementation("dev.icerock:mobile-multiplatform:0.2.0")
implementation("dev.icerock:mobile-multiplatform:0.3.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50")
implementation("com.android.tools.build:gradle:3.5.0")
}

kotlinDslPluginOptions {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object Versions {

const val kotlin = "1.3.50"

private const val mokoResources = "0.3.0"
private const val mokoResources = "0.4.0"

object Plugins {
const val android = "3.4.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ package dev.icerock.gradle.generator
import com.squareup.kotlinpoet.*
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.Copy
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
import org.w3c.dom.Node
import java.io.File
import java.io.FileWriter
import javax.xml.parsers.DocumentBuilderFactory
Expand Down Expand Up @@ -66,42 +64,33 @@ class IosMRGenerator(

val framework = linkTask.binary as? Framework ?: return@forEach

val pack =
project.tasks.create(linkTask.name.replace("link", "pack"), Copy::class.java) {
group = "multiplatform"
linkTask.doLast {
resourcesGenerationDir.copyRecursively(framework.outputFile, overwrite = true)

from(resourcesGenerationDir)
into(framework.outputFile)
val infoPList = File(framework.outputFile, "Info.plist")

// set development region in Info.plist for activate Base.lproj usage
doLast {
val infoPList = File(framework.outputFile, "Info.plist")
val dbFactory = DocumentBuilderFactory.newInstance()
val dBuilder = dbFactory.newDocumentBuilder()
val doc = dBuilder.parse(infoPList)

val dbFactory = DocumentBuilderFactory.newInstance()
val dBuilder = dbFactory.newDocumentBuilder()
val doc = dBuilder.parse(infoPList)
val rootDict = doc.getElementsByTagName("dict").item(0)

val rootDict = doc.getElementsByTagName("dict").item(0)
rootDict.appendChild(doc.createElement("key").apply {
textContent = "CFBundleDevelopmentRegion"
})
rootDict.appendChild(doc.createElement("string").apply {
textContent = "en"
})

rootDict.appendChild(doc.createElement("key").apply {
textContent = "CFBundleDevelopmentRegion"
})
rootDict.appendChild(doc.createElement("string").apply {
textContent = "en"
})
val transformerFactory = TransformerFactory.newInstance()
val transformer = transformerFactory.newTransformer()
transformer.setOutputProperty(OutputKeys.INDENT, "yes");

val transformerFactory = TransformerFactory.newInstance()
val transformer = transformerFactory.newTransformer()
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
val writer = FileWriter(infoPList)
val result = StreamResult(writer)

val writer = FileWriter(infoPList)
val result = StreamResult(writer)

transformer.transform(DOMSource(doc), result)
}
}

linkTask.finalizedBy(pack)
transformer.transform(DOMSource(doc), result)
}
}
}

Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pluginManagement {
maven { url = uri("https://dl.bintray.com/kotlin/kotlin") }
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
maven { url = uri("https://plugins.gradle.org/m2/") }
maven { url = uri("https://dl.bintray.com/icerockdev/plugins") }
}
resolutionStrategy.eachPlugin {
val module = Deps.plugins[requested.id.id] ?: return@eachPlugin
Expand Down

0 comments on commit 327eef8

Please sign in to comment.