Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ jobs:
xcrun swift package init --type library
xcrun swift build

build_tests_ios:
name: Build iOS Tests
uses: ./.github/workflows/swift_package_test.yml
with:
enable_linux_checks: false
enable_windows_checks: false
# iOS
enable_ios_checks: true
ios_pre_build_command: |
pwd
xcrun swift package init --type library

soundness:
name: Soundness
uses: ./.github/workflows/soundness.yml
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/swift_package_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ on:
type: string
description: "macOS arch list (JSON)"
default: "[\"ARM64\"]"
ios_host_xcode_versions:
type: string
description: "Xcode version list (JSON)"
default: null
ios_host_exclude_xcode_versions:
type: string
description: "Exclude Xcode version list (JSON)"
default: null
ios_host_versions:
type: string
description: "iOS host (macOS) version list (JSON)"
default: null
ios_host_archs:
type: string
description: "iOS host (macOS) arch list (JSON)"
default: null
linux_swift_versions:
type: string
description: "Include Linux Swift version list (JSON)"
Expand Down Expand Up @@ -84,6 +100,14 @@ on:
type: string
description: "macOS command to build and test the package"
default: "xcrun swift test"
ios_pre_build_command:
type: string
description: "macOS command to execute before building the Swift package for iOS"
default: ""
ios_build_command:
type: string
description: "macOS command to build the package for iOS"
default: "xcrun swift build --build-tests --sdk \"$(xcrun --sdk iphoneos --show-sdk-path)\" --triple arm64-apple-ios"
Copy link

@kkebo kkebo Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, it would be better to use $(xcrun -f swift) instead of xcrun swift.

xcrun swift is fine with packages that do not contain executableTarget, but it causes the following errors with packages that contain executableTarget:

clang: warning: using sysroot for 'MacOSX' but targeting 'iPhone' [-Wincompatible-sysroot]

To prevent this, you can use $(xcrun -f swift) instead of xcrun swift.

Related discussion: https://forums.swift.org/t/getting-incompatible-sysroot-warning-when-compiling-for-ios-with-sdk-and-target-set/80584

You can easily reproduce this issue by the following steps:

mkdir foo && cd foo
swift package init --type executable --name Foo
xcrun swift build --sdk "$(xcrun --sdk iphoneos --show-sdk-path)" --triple arm64-apple-ios

linux_build_command:
type: string
description: "Linux command to build and test the package"
Expand All @@ -110,6 +134,9 @@ on:
macos_env_vars:
description: "Newline separated list of environment variables"
type: string
ios_host_env_vars:
description: "Newline separated list of environment variables"
type: string
linux_env_vars:
description: "Newline separated list of environment variables"
type: string
Expand All @@ -136,6 +163,10 @@ on:
type: boolean
description: "Boolean to enable macOS testing. Defaults to false"
default: false
enable_ios_checks:
type: boolean
description: "Boolean to enable iOS testing. Defaults to false"
default: false
enable_windows_checks:
type: boolean
description: "Boolean to enable windows testing. Defaults to true"
Expand Down Expand Up @@ -192,6 +223,42 @@ jobs:
run: ${{ inputs.macos_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
timeout-minutes: 60

ios-build:
name: iOS (Build Only, Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }})
if: ${{ inputs.enable_ios_checks }}
runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"]
strategy:
fail-fast: false
matrix:
xcode_version: ${{ fromJson(inputs.ios_host_xcode_versions || inputs.macos_xcode_versions) }}
os_version: ${{ fromJson(inputs.ios_host_versions || inputs.macos_versions) }}
arch: ${{ fromJson(inputs.ios_host_archs || inputs.macos_archs) }}
exclude:
- ${{ fromJson(inputs.ios_host_exclude_xcode_versions || inputs.macos_exclude_xcode_versions) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Provide token
if: ${{ inputs.needs_token }}
run: |
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
- name: Set environment variables
if: ${{ inputs.ios_host_env_vars }}
run: |
for i in "${{ inputs.ios_host_env_vars }}"
do
printf "%s\n" $i >> $GITHUB_ENV
done
- name: Select Xcode
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV
- name: Swift version
run: xcrun swift --version
- name: Pre-build
run: ${{ inputs.ios_pre_build_command }}
- name: Build
run: ${{ inputs.ios_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
timeout-minutes: 60

linux-build:
name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }})
if: ${{ inputs.enable_linux_checks }}
Expand Down
Loading