name: iOS

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

permissions:
  contents: read

jobs:
  build_x86_64:
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: true

    - name: Unbreak Python in GitHub Actions
      run: |
        find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
        sudo rm -rf /Library/Frameworks/Python.framework/
        brew install --force python3 && brew unlink python3 && brew link --overwrite python3

    - name: Install Packages
      run: |
        export HOMEBREW_NO_INSTALL_FROM_API=1
        brew update
        brew install meson

    - name: Build
      run: |
        meson setup build -Dlog=true -Dloaders=all -Dsavers=all -Dbindings=capi -Dstatic=true --cross-file ./cross/ios_x86_64.txt
        ninja -C build install

    - uses: actions/upload-artifact@v4
      with:
        name: result_x86_64
        path: build/src/libthorvg*

  build_arm64:
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: true

    - name: Unbreak Python in GitHub Actions
      run: |
        find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
        sudo rm -rf /Library/Frameworks/Python.framework/
        brew install --force python3 && brew unlink python3 && brew link --overwrite python3

    - name: Install Packages
      run: |
        export HOMEBREW_NO_INSTALL_FROM_API=1
        brew update
        brew install meson

    - name: Build
      run: |
        meson setup build -Dlog=true -Dloaders=all -Dsavers=all -Dbindings=capi -Dstatic=true --cross-file ./cross/ios_arm64.txt
        ninja -C build install

    - uses: actions/upload-artifact@v4
      with:
        name: result_arm64
        path: build/src/libthorvg*