Quick question: I want to build an app running on ...
# compose-desktop
j
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
I guess, you have to build on each host separately.
j
I have to do so now..
Copy code
implementation(compose.desktop.currentOs)
I think the root cause is this config
a
It looks like it bundles the runtime according to the current host.
j
Yep, thx Ivan
s
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
Thx Stefan ~ I will have a try later
y
@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
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
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
thanks..! @Stefan Oltmann @Arkadii Ivanov