diff --git a/components/resources/library/build.gradle.kts b/components/resources/library/build.gradle.kts index 7387edf05b..a89007462d 100644 --- a/components/resources/library/build.gradle.kts +++ b/components/resources/library/build.gradle.kts @@ -44,6 +44,9 @@ kotlin { val jvmAndAndroidMain by creating { dependsOn(commonMain) } + val nativeMain by creating { + dependsOn(commonMain) + } val desktopMain by getting { dependsOn(skikoMain) dependsOn(jvmAndAndroidMain) @@ -68,6 +71,7 @@ kotlin { val iosMain by getting { dependsOn(skikoMain) dependsOn(commonButJSMain) + dependsOn(nativeMain) } val iosTest by getting val iosSimulatorArm64Main by getting @@ -80,6 +84,7 @@ kotlin { val macosMain by creating { dependsOn(skikoMain) dependsOn(commonButJSMain) + dependsOn(nativeMain) } val macosX64Main by getting { dependsOn(macosMain) diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ComposeResource.common.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ComposeResource.common.kt index bb63b7c6c6..7206e0a56c 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ComposeResource.common.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ComposeResource.common.kt @@ -111,8 +111,7 @@ private fun painterResource( * (https://developer.android.com/reference/android/graphics/drawable/VectorDrawable) * except that external references to Android resources are not supported. * - * Note that XML Vector Drawables are not supported for Web and native MacOS targets currently. - * + * Note that XML Vector Drawables are not supported for Web target currently. */ @ExperimentalResourceApi @Composable diff --git a/components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/Resource.ios.kt b/components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/Resource.ios.kt index 6e39c00bc0..60b950775e 100644 --- a/components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/Resource.ios.kt +++ b/components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/Resource.ios.kt @@ -5,10 +5,8 @@ package org.jetbrains.compose.resources -import org.jetbrains.compose.resources.vector.xmldom.Element import kotlinx.cinterop.addressOf import kotlinx.cinterop.usePinned -import org.jetbrains.compose.resources.vector.xmldom.parse import platform.Foundation.NSBundle import platform.Foundation.NSData import platform.Foundation.NSFileManager @@ -36,5 +34,3 @@ private class UIKitResourceImpl(path: String) : AbstractResourceImpl(path) { internal actual class MissingResourceException actual constructor(path: String) : Exception("Missing resource with path: $path") - -internal actual fun parseXML(byteArray: ByteArray): Element = parse(byteArray.decodeToString()) \ No newline at end of file diff --git a/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/Resource.macos.kt b/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/Resource.macos.kt index c1dcf6ad30..becf5343ef 100644 --- a/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/Resource.macos.kt +++ b/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/Resource.macos.kt @@ -5,7 +5,6 @@ package org.jetbrains.compose.resources -import org.jetbrains.compose.resources.vector.xmldom.Element import kotlinx.cinterop.addressOf import kotlinx.cinterop.usePinned import platform.Foundation.NSData @@ -39,6 +38,3 @@ private class MacOSResourceImpl(path: String) : AbstractResourceImpl(path) { internal actual class MissingResourceException actual constructor(path: String) : Exception("Missing resource with path: $path") -internal actual fun parseXML(byteArray: ByteArray): Element { - throw UnsupportedOperationException("XML Vector Drawables are not supported for MacOS target") -} diff --git a/components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/Resource.native.kt b/components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/Resource.native.kt new file mode 100644 index 0000000000..ab823d68f8 --- /dev/null +++ b/components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/Resource.native.kt @@ -0,0 +1,11 @@ +/* + * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. + * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. + */ + +package org.jetbrains.compose.resources + +import org.jetbrains.compose.resources.vector.xmldom.Element +import org.jetbrains.compose.resources.vector.xmldom.parse + +internal actual fun parseXML(byteArray: ByteArray): Element = parse(byteArray.decodeToString()) diff --git a/components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/xmldom/DomXmlParser.kt b/components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/DomXmlParser.kt similarity index 100% rename from components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/xmldom/DomXmlParser.kt rename to components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/DomXmlParser.kt