Trying to build a DMG for OSX only but it doesn't ...
# compose-desktop
k
Trying to build a DMG for OSX only but it doesn't seem to run on Intel OSX machines (build machine is an M1 Mac Mini). The message is "this application is not support on this mac" but I've had no luck searching for any special configuration for x86 vs. ARM macs and the official compose-MP-template doesn't have any special config for it either: https://github.com/JetBrains/compose-multiplatform-desktop-template/blob/main/build.gradle.kts Has anyone run into this? Compose 1.5.10-beta02 if that matters...a bit puzzled because I thought it was just Java underneath. EDIT: hmm...maybe it's this: https://github.com/JetBrains/compose-multiplatform/issues/1599 EDIT: tried switching to using: _implementation_(compose.desktop.macos_x64) instead of: _implementation_(compose.desktop.currentOs) and it doesn't run on an M1 macbook šŸ¤”
e
the problem is the process for building the dmg… the Java tools that do it don't support cross-platform https://kotlinlang.slack.com/archives/C01D6HTPATV/p1696319005969729?thread_ts=1696265757.819389&cid=C01D6HTPATV
if you run the Intel JDK on your M1 it should work though
k
ahh..I saw a graalvm issue/ticket about supporting universal binaries on MacOS too so that makes sense. For some reason, I thought some magic binary header was just prepended to the binary since it's just Java underneath.
We did end up using an Intel macmini for our builds and it works
m
It’s not ā€œjust Java underneathā€. Every JDK contains lots of platform specific native libraries.
k
Yep, but I expected that to be dumped into the bootstrap into a Java JRE on the user's machine šŸ™‚ If the JRE is bundled in the DMG, that's an entirely different thing...
t
If you run the gradle task using an Intel jdk it will build an Intel version of the app, even on the m1 Mac.
today i learned 2
k
That's a neat workaround...never thought of doing that. Everything Rosetta...
e
that is what I said earlier though šŸ˜›
šŸ˜‚ 3
šŸ¤¦ā€ā™‚ļø 3
m
@Thomas @ephemient Interesting! So, you are saying, that just executing something like this
Copy code
(export JAVA_HOME=~/tools/jdk_x64_mac_hotspot_17.0.8_7/Contents/Home; ./gradlew clean desktopApp:packageReleaseDmg)
in a terminal on an ARM mac would be sufficient to build an Intel version of an app? (Assuming Rosetta 2 was previously installed.) It would be kind if someone with an ARM mac could confirm this as I cannot try it out. I do not own an ARM mac yet and this concept only works in one direction.
s
I recommend looking at https://conveyor.hydraulic.dev/11.4/ It will build any version of your app on any computer. It significantly eases the burden. It's also free for open source projecgts
k
@Sebastian Kürten also pointed this plugin out to me: https://github.com/mobanisto/pinpit-gradle-plugin That describes why the built-in Compose Multiplatform support isn't capable of building a Universal binary.
t
@Michael Paus correct, that’s how I do it. I use fastlane to build the mac app and to upload it to the store, so I just set the env var like this just before the gradle task:
ENV["JAVA_HOME"] = …
. You do need to have rosetta 2 installed ofcourse.
šŸ™ 1
t
@Michael Paus it’s much easier to install jdk with asdf. While before install it, you should run
arch -x86_64 /bin/zsh
(or bash maybe).
m
I just bought a new Mac Mini with an M2 Pro and I can now confirm that it is indeed possible to cross-build the Intel version of an app from this machine with this single command line
Copy code
(export JAVA_HOME=/Users/mpaus/Downloads/jdk-17.0.9+9/Contents/Home; ./gradlew clean desktopApp:packageReleaseDmg)
if JAVA_HOME is pointing to an Intel JDK here and Rosetta 2 is installed. I am still flashed that this works indeed and so easily.
šŸ‘ 1
163 Views