Sort of related to the above, I’m now trying to cr...
# compose-desktop
k
Sort of related to the above, I’m now trying to create and run the app, I’ve tried ‘packageReleaseDistributionForCurrentOS’ and ‘packageReleasePkg’ but when I install and run the app I get java.lang.UnsatisfiedLinkError: Can’t load library: /Applications/drawgrid.app/Contents/app/libskiko-macos-arm64.dylib This answer on SO (https://stackoverflow.com/questions/70150052/org-jetbrains-skiko-libraryloadexception-cannot-find-libskiko-macos-arm64-dylib) says to change the compose.desktop reference or to update to the latest plugins (the answer is from over a year ago) I get the same behaviour if I just create and build an empty ‘demo’ project
m
Instead of relying on some possibly outdated SO recommendations I’d start with the official template from JetBrains https://github.com/JetBrains/compose-multiplatform/tree/master/templates/desktop-template and then fill that with your own content. I just did that this morning and it worked like a charm on my (Intel) Mac.
k
I’m building the code from the IntelliJ wizard, does that not use the latest template?
m
According to my experience, no. The wizard is often outdated.
If you like you can try my example which I created this morning as a demo for someone else. https://github.com/mipastgt/PolySpiralDesktop It should work out of the box. If not, then there is something wrong with your system setup or with the M1 support in general.
k
Thanks Michael, I’m getting exactly the same issue (remember this is the M1 mac, not the Intel mac hence the need to link to the ARM64 dynlib)
m
Just for clarification. Do you only get this error when you use a packaged app or do you also get this error when you just run the app via Gradle?
k
Only the packaged app
m
Did you look into the generated package? Is the lib really missing or does it contain the wrong architecture? Did you try packaging a DMG instead of a PKG? That’s what I am always doing. Actually I am wondering where you got your packageReleasePkg from. I don’t have that in my project. As far as I know PKG is not supported.
k
It’s a DMG I’m creating (I meant to type packageReleaseDmg, fat fingers). When I run the app from Finder then it doesn’t start, running it from the terminal as /Applications/PolySpiral\ Desktop.app/Contents/MacOS/PolySpiral\ Desktop Gives me the error
Copy code
Exception in thread “main” java.lang.UnsatisfiedLinkError: Can’t load library: /Applications/PolySpiral <http://Desktop.app/Contents/app/libskiko-macos-arm64.dylib|Desktop.app/Contents/app/libskiko-macos-arm64.dylib>
but if I look in /Applications/PolySpiral Desktop.app/Contents/app then the libskiko-macos-arm64.dylib is there, so now I’m really confused
I have two M1 machines and it fails with the same error on both
So, if I run the app from the IDE it creates a ~/.skiko direcrtory and copys a version of the dylib into that directory. If I take that copy of the dylib and copy it into the .app/Contents/app directory then I can run the app from the Applications directory (make sense?) So it looks like the wrong dylib is being copied into the .app file
m
It would be interesting to know whether others have observed the same behaviour. I can’t help here because I only have an Intel Mac. What JDK do you use for the packaging? I read somewhere, but haven’t tried it myself yet, that it is possible to cross-package from macOS Intel to Arm and vice versa with some tricks. Is it possible that something is misconfigured in that direction? Otherwise I wonder why nobody else is complaining about this problem.
k
The project JDK is set to 17.0.3, I assume that’s being used to build the package. I’ve raised an issue on GitHub, however, I’ve just installed SDK v20 (from Temurin) and the app now works 🤷
m
Not necessarily because that can be configured. See: https://github.com/JetBrains/compose-multiplatform/tree/master/tutorials/Native_distributions_and_local_execution#customizing-jdk-version I am glad it works now, so better don’t touch anything anymore 😉.
a
Hey, @kevin Do you resolve this problem? I have a same problem.
👍 1
c
The
packagePkg
gradle task gets generated when you add the
.pkg
target, in
build.gradle:composeApp
like so:
Copy code
compose.desktop {
    application {
        mainClass = "MainKt"

        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Pkg)
This is the required format for applications uploaded to the Apple AppStore.