Add XML Vector Drawables to MacOS native target. (#2756)

This commit is contained in:
Nikita Lipsky
2023-02-16 20:28:21 +02:00
committed by GitHub
parent 614fe78d71
commit 05ee5aef35
6 changed files with 17 additions and 10 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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())

View File

@@ -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")
}

View File

@@ -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())