Stefan Oltmann
04/19/2023, 8:23 AMImage.makeFromEncoded()
in my compose code gets a unresolved reference as soon as I add the iosArm64()
target. If I try to add api("org.jetbrains.skiko:skiko:0.7.58")
to commonMain
this results in errors like this:
ld: warning: object file (/var/folders/jw/hb2y762x2jg3y14lzck8_fqc0000gn/T/included15295158996419610357/libparticles.a(libparticles.SkParticleBinding.o)) was built for newer iOS version (11.0) than being linked (9.0)
ld: warning: object file (/var/folders/jw/hb2y762x2jg3y14lzck8_fqc0000gn/T/included15295158996419610357/libskresources.a(libskresources.SkResources.o)) was built for newer iOS version (11.0) than being linked (9.0)
ld: warning: object file (/var/folders/jw/hb2y762x2jg3y14lzck8_fqc0000gn/T/included15295158996419610357/libparticles.a(libparticles.SkParticleDrawable.o)) was built for newer iOS version (11.0) than being linked (9.0)
Is this the wrong way to add skiko? I was thinking SKIA should be already used for Compose for iOS.
I'm on Apple Silicon.Oleksandr Karpovich [JB]
04/19/2023, 8:25 AMOleksandr Karpovich [JB]
04/19/2023, 8:29 AMcompose code gets a unresolved reference as soon as I add theDoes it fail to compile? Or it’s only in IDE?targetiosArm64()
Stefan Oltmann
04/19/2023, 8:36 AMUndefined symbols for architecture arm64:
"_CGAffineTransformConcat", referenced from:
SkScalerContext_Mac::generatePath(SkGlyph const&, SkPath*) in libskia.a(fontmgr_mac_ct.SkScalerContext_mac_ct.o)
and the last line is
ld: symbol(s) not found for architecture arm64
My configuration looks like this:
val xcf = XCFramework()
listOf(
/* App Store */
iosArm64(),
/* Apple Silicon iOS Simulator */
iosSimulatorArm64(),
/* macOS Devices */
macosX64(),
macosArm64()
).forEach {
it.binaries.framework(
buildTypes = setOf(NativeBuildType.RELEASE)
) {
baseName = "compose"
/* Part of the XCFramework */
xcf.add(this)
/* Bitcode was deprecated with XCode 14 */
embedBitcode("disable")
}
}
Stefan Oltmann
04/19/2023, 8:41 AMFAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compose:linkReleaseFrameworkIosArm64'.
> Compilation finished with errors
Stefan Oltmann
04/19/2023, 8:43 AMKotlin/Native on iOS(arm64 and x64)
Kotlin/Native on macOS (arm64 and x64)
Both are listed as supported platforms on the skiko project page. So I assumed it should work.
I'm not sure if the way I specified the dependency is correct.Oleksandr Karpovich [JB]
04/19/2023, 8:52 AMSkScalerContext_Mac
it’s rather an unexpected symbol for ios.
Did it fail for iosSimulatorArm64 ?
I’m not sure if Image.makeFromEncoded() is the cause. We use it in demos which worked fine.
Do you have a reproducer that could be shared?Stefan Oltmann
04/19/2023, 8:57 AMMichael Paus
04/19/2023, 11:56 AMimport androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asComposeImageBitmap
import androidx.compose.ui.graphics.toComposeImageBitmap
import de.mpmediasoft.system.ImageFactoryService
import org.jetbrains.skia.Bitmap
import org.jetbrains.skia.ColorAlphaType
import org.jetbrains.skia.Image
import org.jetbrains.skia.ImageInfo
actual class ImageFactoryServiceImpl actual constructor() : ImageFactoryService {
// Desktop and UIKit implementation (actually works on all Skia targets)
override fun imageBitmapFromBytes(encodedImageData: ByteArray): ImageBitmap {
return Image.makeFromEncoded(encodedImageData).toComposeImageBitmap()
}
As you can see I directly use the SKIA binding. This works nicely on the simulator (I don’t have a real device) and I am on an Intel Mac but I would assume that this should work on an M1/M2 Mac too.Dima Avdeev
04/19/2023, 12:20 PMDima Avdeev
04/19/2023, 12:20 PMDima Avdeev
04/19/2023, 12:22 PMStefan Oltmann
04/19/2023, 12:22 PMMichael Paus
04/19/2023, 12:23 PMDima Avdeev
04/19/2023, 12:23 PMDima Avdeev
04/19/2023, 12:24 PMStefan Oltmann
04/19/2023, 12:24 PMStefan Oltmann
04/19/2023, 12:25 PMisStatic = true
only recently in the examples, but I don't know yet what it does.Dima Avdeev
04/19/2023, 12:25 PMDima Avdeev
04/19/2023, 12:25 PMStefan Oltmann
04/19/2023, 12:26 PMDima Avdeev
04/19/2023, 12:26 PMDima Avdeev
04/19/2023, 12:27 PMStefan Oltmann
04/19/2023, 12:43 PMisStatic = true
. I missed this configuration as I just copied the old block from my shared
module over to my compose
module. 🙈 Thank you for pointing that out.Stefan Oltmann
04/19/2023, 12:44 PM