Skip to content

Commit ae72e5b

Browse files
committed
Add workflow to build packages for iOS.
Add workflow to build packages for iOS on a macOS VM. Can't run tests at this time, but we can at least confirm source compiles.
1 parent 1169be7 commit ae72e5b

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

.github/workflows/pull_request.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ jobs:
7777
xcrun swift package init --type library
7878
xcrun swift build
7979
80+
tests_ios:
81+
name: Test iOS
82+
uses: ./.github/workflows/swift_package_test.yml
83+
with:
84+
enable_linux_checks: false
85+
enable_windows_checks: false
86+
# iOS
87+
enable_ios_checks: true
88+
ios_pre_build_command: |
89+
mkdir MyPackage
90+
cd MyPackage
91+
xcrun swift package init --type library
92+
8093
soundness:
8194
name: Soundness
8295
uses: ./.github/workflows/soundness.yml

.github/workflows/swift_package_test.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ on:
1919
type: string
2020
description: "macOS arch list (JSON)"
2121
default: "[\"ARM64\"]"
22+
ios_host_xcode_versions:
23+
type: string
24+
description: "Xcode version list (JSON)"
25+
default: null
26+
ios_host_exclude_xcode_versions:
27+
type: string
28+
description: "Exclude Xcode version list (JSON)"
29+
default: null
30+
ios_host_versions:
31+
type: string
32+
description: "iOS host (macOS) version list (JSON)"
33+
default: null
34+
ios_host_archs:
35+
type: string
36+
description: "iOS host (macOS) arch list (JSON)"
37+
default: null
2238
linux_swift_versions:
2339
type: string
2440
description: "Include Linux Swift version list (JSON)"
@@ -84,6 +100,14 @@ on:
84100
type: string
85101
description: "macOS command to build and test the package"
86102
default: "xcrun swift test"
103+
ios_pre_build_command:
104+
type: string
105+
description: "macOS command to execute before building the Swift package for iOS"
106+
default: ""
107+
ios_build_command:
108+
type: string
109+
description: "macOS command to build the package for iOS"
110+
default: "xcrun swift build --build-tests --sdk \"$(xcrun --sdk iphoneos --show-sdk-path)\" --triple arm64-apple-ios"
87111
linux_build_command:
88112
type: string
89113
description: "Linux command to build and test the package"
@@ -110,6 +134,9 @@ on:
110134
macos_env_vars:
111135
description: "Newline separated list of environment variables"
112136
type: string
137+
ios_host_env_vars:
138+
description: "Newline separated list of environment variables"
139+
type: string
113140
linux_env_vars:
114141
description: "Newline separated list of environment variables"
115142
type: string
@@ -136,6 +163,10 @@ on:
136163
type: boolean
137164
description: "Boolean to enable macOS testing. Defaults to false"
138165
default: false
166+
enable_ios_checks:
167+
type: boolean
168+
description: "Boolean to enable iOS testing. Defaults to false"
169+
default: false
139170
enable_windows_checks:
140171
type: boolean
141172
description: "Boolean to enable windows testing. Defaults to true"
@@ -192,6 +223,42 @@ jobs:
192223
run: ${{ inputs.macos_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
193224
timeout-minutes: 60
194225

226+
ios-build:
227+
name: iOS (Build Only, Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }})
228+
if: ${{ inputs.enable_ios_checks }}
229+
runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"]
230+
strategy:
231+
fail-fast: false
232+
matrix:
233+
xcode_version: ${{ fromJson(inputs.ios_host_xcode_versions || inputs.macos_xcode_versions) }}
234+
os_version: ${{ fromJson(inputs.ios_host_versions || inputs.macos_versions) }}
235+
arch: ${{ fromJson(inputs.ios_host_archs || inputs.macos_archs) }}
236+
exclude:
237+
- ${{ fromJson(inputs.ios_host_exclude_xcode_versions || inputs.macos_exclude_xcode_versions) }}
238+
steps:
239+
- name: Checkout repository
240+
uses: actions/checkout@v4
241+
- name: Provide token
242+
if: ${{ inputs.needs_token }}
243+
run: |
244+
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
245+
- name: Set environment variables
246+
if: ${{ inputs.ios_host_env_vars }}
247+
run: |
248+
for i in "${{ inputs.ios_host_env_vars }}"
249+
do
250+
printf "%s\n" $i >> $GITHUB_ENV
251+
done
252+
- name: Select Xcode
253+
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV
254+
- name: Swift version
255+
run: xcrun swift --version
256+
- name: Pre-build
257+
run: ${{ inputs.ios_pre_build_command }}
258+
- name: Build
259+
run: ${{ inputs.ios_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
260+
timeout-minutes: 60
261+
195262
linux-build:
196263
name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }})
197264
if: ${{ inputs.enable_linux_checks }}

0 commit comments

Comments
 (0)