Discussion: Tauri-inspired workflow and native integrations #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: iOS Build | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| build_python_runtime: | |
| description: 'Build Python.xcframework before the iOS host' | |
| required: false | |
| default: false | |
| type: boolean | |
| pull_request: | |
| paths: | |
| - 'interop/ios/**' | |
| - 'webview/**' | |
| - 'tests/**' | |
| - '.github/workflows/ios-build.yml' | |
| - 'pyproject.toml' | |
| jobs: | |
| simulator: | |
| name: iOS simulator validation | |
| runs-on: macos-latest | |
| timeout-minutes: 60 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install test dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[cli,dev]" | |
| - name: Check Xcode toolchain | |
| run: | | |
| xcodebuild -version | |
| xcode-select -p | |
| - name: Run platform-independent tests | |
| run: >- | |
| pytest -q | |
| tests/test_util.py | |
| tests/test_ios_backend.py | |
| - name: Scaffold test app | |
| run: pywebview2 init testapp --name "CLI Smoke Test" --identifier com.example.clismoketest --yes | |
| - name: Build Python iOS support | |
| if: ${{ inputs.build_python_runtime == true }} | |
| run: | | |
| git clone --depth 1 --branch 3.13 https://github.com/beeware/Python-Apple-support.git .build/python-apple-support | |
| make -C .build/python-apple-support iOS | |
| archive=$(find .build/python-apple-support/dist -type f -name '*.tar.gz' -print -quit) | |
| if [ -z "$archive" ]; then | |
| echo 'Python-Apple-support did not produce an archive' | |
| find .build/python-apple-support/dist -maxdepth 2 -type f 2>/dev/null || true | |
| exit 1 | |
| fi | |
| mkdir -p .build/python-runtime | |
| tar -xzf "$archive" -C .build/python-runtime | |
| runtime=$(find "$GITHUB_WORKSPACE/.build/python-runtime" -type d -name Python.xcframework -print -quit) | |
| if [ -z "$runtime" ]; then | |
| echo 'Python.xcframework was not produced by Python-Apple-support' | |
| find .build/python-apple-support -maxdepth 4 -type f | head -100 | |
| exit 1 | |
| fi | |
| echo "PYWEBVIEW_IOS_PYTHON_XCFRAMEWORK=$runtime" >> "$GITHUB_ENV" | |
| - name: Build native iOS host for simulator | |
| working-directory: testapp | |
| run: | | |
| python - <<'PY' | |
| import json | |
| path = 'pywebview2.conf.json' | |
| with open(path) as f: | |
| config = json.load(f) | |
| config['bundle']['targets'] = ['ios'] | |
| with open(path, 'w') as f: | |
| json.dump(config, f, indent=2) | |
| PY | |
| pywebview2 build --target ios --dist .build | |
| - name: Upload simulator app | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pywebview-ios-simulator | |
| path: testapp/.build/ios/.derived-data/Build/Products/Debug-iphonesimulator/CLI Smoke Test.app |