https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
j

Jerry Yion

07/26/2022, 7:28 AM
Quick question: I want to build an app running on desktop (mac, win, linux). The issue I met is the package I ran build on mac cannot run on windows well (some class def not found)
a

Arkadii Ivanov

07/26/2022, 7:34 AM
I guess, you have to build on each host separately.
j

Jerry Yion

07/26/2022, 7:36 AM
I have to do so now..
Copy code
implementation(compose.desktop.currentOs)
I think the root cause is this config
a

Arkadii Ivanov

07/26/2022, 7:41 AM
It looks like it bundles the runtime according to the current host.
j

Jerry Yion

07/26/2022, 7:44 AM
Yep, thx Ivan
s

Stefan Oltmann

07/26/2022, 8:29 AM
Yes, it does. For the macOS version you need to execute
createDistributable
on a Mac.
I think on Windows it uses tools like WiX that are only available there.
In my case I use GitHub actions with the macOS & Windows runners to create the binaries I need.
j

Jerry Yion

07/26/2022, 8:31 AM
Thx Stefan ~ I will have a try later
y

Yogeshvu

07/26/2022, 3:32 PM
@Stefan Oltmann would you happen to have an example with the mac/windows github actions with compose executable build that we could access? thanks
s

Stefan Oltmann

07/27/2022, 6:38 AM
It's really simple. Windows for example has this entry in my `ci.yml`:
Copy code
windows:
  name: Windows
  needs: build
  runs-on: windows-latest
  timeout-minutes: 60
  steps:
    - name: Checkout workspace
      uses: actions/checkout@v3
    - name: Gradle Cache
      uses: actions/cache@v3
      with:
        path: |
          ~/.gradle/caches
          ~/.gradle/wrapper
          ~/.gradle/native
        key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
        restore-keys: ${{ runner.os }}-gradle-
    - name: Set up Java JDK 17
      uses: actions/setup-java@v3
      with:
        distribution: 'temurin'
        java-version: '17.0.3+7'
    - name: Build
      run: |
        chmod +x ./gradlew
        ./gradlew createDistributable -x test --parallel
        move "desktop\build\compose\binaries\main\app\MyApp" .
        Compress-Archive -Path "MyApp" -DestinationPath my-app.zip
    - uses: actions/upload-artifact@v3
      with:
        if-no-files-found: error
        name: windows
        path: my-app.zip
For a mac build you just change
runs-on
to
macos-latest
a

Arkadii Ivanov

07/27/2022, 7:06 AM
Just in case, I'm using packageDeb, packageMsi etc. tasks. Then just actions/upload-artifact after that. Works fine for me. However, I haven't setup macOS yet because I don't have the developer account and can't to sign the app. https://github.com/arkivanov/MVIKotlin/blob/62fceaaab920c7ea2460ec82c22c99a35cf12b95/.github/workflows/package-time-travel-app.yml#L24
y

Yogeshvu

07/27/2022, 3:40 PM
thanks..! @Stefan Oltmann @Arkadii Ivanov
57 Views